Refactor with moved block terraform
Rename addresses in code with no destroy/recreate; survives in version control
cat >> moved.tf <<'EOF'
moved {
from = aws_instance.web
to = aws_instance.app
}
EOF
more terraform
all 43 commands →
Replace resource (modern taint)
terraform apply -replace='aws_instance.web'
Surgical targeted plan
terraform plan -target='module.db.aws_db_instance.main'
Refresh-only plan (detect drift)
terraform plan -refresh-only
Migrate backend on init
terraform init -migrate-state -backend-config=backend.hcl
Query outputs with jq
terraform output -json | jq -r '.endpoints.value[]'