Closed
Description
It happened to me multiple times that, when the FAST resman stage destroy process breaks half way through -for whatever reason- and I run terraform destroy
again I get:
Error: Unsupported attribute
│
│ on outputs.tf line 226, in locals:
│ 226: tag_keys = { for k, v in module.organization.tag_keys : k => v.id }
│ ├────────────────
│ │ module.organization is object with 8 attributes
│
│ This object does not have an attribute named "tag_keys".
╵
╷
│ Error: Unsupported attribute
│
│ on outputs.tf line 228, in locals:
│ 228: tag_values = { for k, v in module.organization.tag_values : k => v.id }
│ ├────────────────
│ │ module.organization is object with 8 attributes
│
│ This object does not have an attribute named "tag_values".
I usually solve this adding a try in the related stage outputs:
...
tfvars = {
folder_ids = local.folder_ids
service_accounts = local.service_accounts
tag_keys = { for k, v in try(module.organization.tag_keys, {}) : k => v.id }
tag_names = var.tag_names
tag_values = { for k, v in try(module.organization.tag_values, {}) : k => v.id }
}
...
Before committing this fix, I was wondering if we can state why this happens and if we can make any change at the module level. Anyway, the organization module should at most return empty dictionaries, so I don't see anything wrong there:
output "tag_keys" {
description = "Tag key resources."
value = {
for k, v in google_tags_tag_key.default : k => v if(
v.purpose == null || v.purpose == ""
)
}
}
output "tag_values" {
description = "Tag value resources."
value = {
for k, v in google_tags_tag_value.default :
k => v if !local.tag_values[k].tag_network
}
}
Thoughts?
Activity