Skill 6.4.2
Resolving drift and replacing resources
Key Concepts
To revert drift, run a normal terraform apply: Terraform changes the object back to match the configuration. To keep the manual change, update the configuration to match it, and the next plan shows no changes. If an attribute is legitimately managed by another process, such as an autoscaler changing a desired count, add it to lifecycle { ignore_changes = [...] }. If an object was deleted outside Terraform, the next plan proposes to create it again.
When an object is damaged or degraded but its configuration has not changed, terraform apply -replace=ADDRESS destroys and recreates it in one reviewed plan. It replaces the deprecated terraform taint command, which marked an object for replacement without showing a plan.