Remove orphan from state terraform
Forget resource from state without deleting real infra; note: object keeps existing
terraform state rm 'aws_s3_bucket.legacy'
more terraform
all 43 commands →
Inspect single resource state
terraform state show 'module.vpc.aws_subnet.private[0]'
Grep the state list
terraform state list | grep -i 'aws_iam'
Config-driven import block
cat > import.tf <<'EOF'
import {
to = aws_instance.web
id = "<id>"
}
EOF
terraform plan -generate-config-out=generated.tf
Refactor with moved block
cat >> moved.tf <<'EOF'
moved {
from = aws_instance.web
to = aws_instance.app
}
EOF
Replace resource (modern taint)
terraform apply -replace='aws_instance.web'