I have a terraform module
resource "abc" "example" {
....
}
data "abc_links" "example" {
links = abc.example.id
}
output "example" {
value = data.abc_links.example
}
output "examples" {
value = abc_link.example.links
}
and on calling this module, I have locals like this
locals {
links = {
user = {
link = {
linkname = module.module_name.example.name,
default = "0.0.0.0",
id = module.module_name.examples,
}
}
}
}
resource abc
doesn’t get created, it fails and gets tainted. And my terraform stops citing the error message.
On terraform destroy, I am not able to destroy all, as I get the error saying references doesn’t exist
│ Error: Unsupported attribute
│
│ on test.tf line 45, in locals:
│ 45: linkname = module.module_name.example.name,
│ ├────────────────
│ │ module.module_name is object with 1 attribute "example"
│
│ This object does not have an attribute named "name".
╵
Anyway to resolve this ? I tried with conditional operator, checking if module is tainted then assign null to entire locals, but that also checks the or option
something like this I tried
locals {
links = module.module_name == "tainted" ? null : {
user = {
link = {
linkname = module.module_name.example.name,
default = "0.0.0.0",
id = module.module_name.examples,
}
}
}
}