The terraform taint command

Learn how to taint a resource in the state using terraform taint command.

What is terraform taint command?

The terraform taint command taints a resource in the state. Terraform will destroy and re-create the resource the next time the configuration is applied.

Running terraform taint on its own won’t destroy the resource immediately; it simply edits the state. Running terraform plan on the root module taints a resource that will be re-created on the next execution of terraform apply. Running terraform apply executes the plan, destroys the resource, and then re-creates it.

Syntax

The terraform taint command has the syntax terraform taint [options] <address>.

Arguments

The <address> argument refers to the address of a resource using the same syntax we’d use inside a configuration. For example, let’s say we have an aws_s3_bucket resource with a name label of nginx. Running terraform taint aws_s3_bucket.terraform_test_bucket_edu will result in the following output.

Get hands-on with 1200+ tech skills courses.