Config-driven import block
Declarative import; -generate-config-out scaffolds HCL for the imported object
cat > import.tf <<'EOF'
import {
to = aws_instance.web
id = "<id>"
}
EOF
terraform plan -generate-config-out=generated.tf
- tool
- terraform43 commands
More terraform commands
-
cat >> moved.tf <<'EOF' moved { from = aws_instance.web to = aws_instance.app } EOFRename addresses in code with no destroy/recreate; survives in version control
-
terraform apply -replace='aws_instance.web'Force destroy+recreate of one resource; replaces deprecated terraform taint
-
terraform plan -target='module.db.aws_db_instance.main'Limit plan to one address; note: -target is an escape hatch, can mask drift
-
terraform plan -refresh-onlySync state to real infra without proposing changes; surfaces out-of-band drift
-
terraform init -migrate-state -backend-config=backend.hclMove state to a new backend; use -reconfigure to skip migration and reset