Hi everyone!
My code produce the following output:
+ file = {
+ orange = {
+ json_data = [
+ {
+ branch = null
+ commit_message = null
+ content = jsonencode(
{
+ evironment = "developer"
+ name = "orange"
+ location = "us-east-1"
}
)
+ file = "environments/stating.tfvars.json"
+ overwrite_on_create = false
},
]
+ repository_id = (known after apply)
}
+ banana = {
+ json_data = [
+ {
+ branch = null
+ commit_message = null
+ content = jsonencode(
{
+ evironment = "staging"
+ name = "banana"
+ location = "us-east-2"
}
)
+ file = "environments/stating.tfvars.json"
+ overwrite_on_create = false
},
]
+ repository_id = (known after apply)
}
+ apple = {
+ json_data = [
+ {
+ branch = null
+ commit_message = null
+ content = jsonencode(
{
+ evironment = "production"
+ name = "apple"
+ location = "us-east-2"
}
)
+ file = "environments/stating.tfvars.json"
+ overwrite_on_create = false
},
]
+ repository_id = (known after apply)
}
}
I need to get a values into content output:
content = jsonencode(
{
+ evironment = "production"
+ name = "apple"
+ location = "us-east-2"
}
)
But all I tested don’t do worng.
locals.tf
file = flatten([
for file in var.repository : [
for fruit in file.file : fruit
]
])
output.tf - on child module
output "file" {
value = local.file
}
output.tf - on parent module
output "file" {
value = module.repository.file
}
│ Error: Unsupported attribute
│
│ on outputs.tf line 103, in output "file":
│ 103: value = module.repository.file
│ ├────────────────
│ │ module.repository is object with no attributes
│
│ This object does not have an attribute named "file".