How to handle tainted interpolation in terraform

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,
        }
    }
  }
}

Hi @ramuklawjju,

Some situations where a resource has failed and the configuration has been incompletely applied are difficult to automatically recover from. The -target flag is often helpful here for applying or destroying smaller portions of the configuration to get unblocked. For starters though, are you using the latest Terraform release?

@jbardin thank you for replying.

Yes, I am on 1.4, it gets resolved on 1.5.3(the latest)

Further this is the issue with 1.2-1.4 versions of terraform