Replace a resource (modern taint)

Force one resource to be destroyed and created again; replaces the deprecated terraform taint

terraform apply -replace='aws_instance.web'

tool
terraform43 commands
tags
terraformtroubleshootingcloud

More terraform commands

  • terraform plan -target='module.db.aws_db_instance.main'

    Limit the plan to one address; -target is for emergencies and can hide drift

  • terraform plan -refresh-only

    Compare state with the real infrastructure without proposing changes; shows drift made outside Terraform

  • terraform init -migrate-state -backend-config=backend.hcl

    Move state to a new backend; use -reconfigure to skip the migration and reset the backend settings

  • terraform output -json | jq -r '.endpoints.value[]'

    Pipe machine-readable outputs to jq for scripts and other tools

  • TF_LOG=DEBUG TF_LOG_PATH=tf.log terraform plan

    Write provider and API debug logs to a file; TRACE is the most verbose level

all 43 terraform commands