I am trying to write a clear documentation/description of my terraform modules.
According to Hashicorp’s doc, the description
attribute will permit that, but I cannot find a way to describe an object
type variable in details.
Here’s more or less I want to do :
variable "sa_to_impersonate_info" {
type = object(
{
id = string
email = string
belonging_org_id = string
belonging_project_id = string
token_scopes = list(string)
token_lifetime = string
}
)
description = {
id : "an identifier for the resource with format projects/{{project}}/serviceAccounts/{{email}}"
email : "Email of the service account to impersonate"
belonging_org_id : "Organization ID where the service account belongs"
belonging_project_id : "Porject ID where the service account belongs"
token_scopes : "List of scopes affected by this service account impersonation"
token_lifetime : "Time the token will be active"
}
}
For this format I get this error when I perform a terraform plan
:
Error: Unsuitable value type
>Solution :
You can have it in below format with EOT
delimiter.
variable "sa_to_impersonate_info" {
type = object(
{
id = string
email = string
belonging_org_id = string
belonging_project_id = string
token_scopes = list(string)
token_lifetime = string
}
)
description = <<EOT
sa_to_impersonate_info = {
id : "an identifier for the resource with format projects/{{project}}/serviceAccounts/{{email}}"
email : "Email of the service account to impersonate"
belonging_org_id : "Organization ID where the service account belongs"
belonging_project_id : "Porject ID where the service account belongs"
token_scopes : "List of scopes affected by this service account impersonation"
token_lifetime : "Time the token will be active"
}
EOT
}