terraform untaint: Usage & Common CI Errors
Undo a taint so Terraform stops planning to recreate a resource.
terraform untaint removes the tainted mark from a resource in state, so the next apply no longer destroys and recreates it.
What it does
terraform untaint <address> clears the "tainted" status that a manual taint, a failed create, or a provider set on a resource instance. After untainting, plan no longer proposes recreation for that resource (assuming its config still matches).
Common usage
# Clear a taint so the resource is not recreated
terraform untaint aws_instance.web
# Untaint a specific indexed instance
terraform untaint 'aws_instance.web[0]'Common error in CI: resource is not tainted / not found
untaint fails with "Error: resource ... is not tainted" or "No instance found for the given address". The first means there is nothing to clear; the second means a wrong or unquoted for_each/count address. Fix: verify the resource and its status with terraform state show <address>, quote bracketed addresses, and only untaint when a plan actually shows an unwanted recreation you want to cancel.
Key options
| Option | Purpose |
|---|---|
| <address> | Required: the instance to untaint |
| -lock=false | Skip state locking |
| -state=FILE | Operate on a specific state file |