What exactly tainted mean in terraform

what exactly tainted mean in terraform

Mohamed Ayman:
Hello @venedara,
taint informs Terraform that a particular object has become degraded or damaged. Check this useful document https://developer.hashicorp.com/terraform/cli/commands/taint

sure thank you

tainted is it means the resource which is having wrong details?

Cai Walkowiak:
Not exactly.

Think of tainted as being a marker put on the resource which instructs Terraform to destroy and recreate that resource.

When you terraform taint resource.name you are putting a marker on resource.name for TF to treat it like it needs to be replaced.

You can taint a resource for any reasons. ex:
In AWS you might want to update the user data on an ec2 instance, but that doesn’t inherently destroy the instance so you can taint it and it will rebuild the instance with the new userdata

Cai Walkowiak:
Be aware that taint is not recommended any longer though the new call -replace would be better for my example.
taint makes a change in the state file, so with multiple users you could have unintended consequences.
-replace makes the call in the apply and does not persist if you cancel the apply