Skip to content
Latchkey

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

Terminal
# 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

OptionPurpose
<address>Required: the instance to untaint
-lock=falseSkip state locking
-state=FILEOperate on a specific state file

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →