원클릭으로
terraform-state-operations
Use when performing Terraform state surgery - state mv, import, rm operations. Requires extra safety measures.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when performing Terraform state surgery - state mv, import, rm operations. Requires extra safety measures.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when executing implementation plans with independent tasks in the current session
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Use when generating documentation for Terraform modules, infrastructure, or runbooks. Creates READMEs, operational guides, and architecture docs.
Use before any Terraform or AWS operation to verify correct credentials and profile are active. Prevents cross-environment accidents.
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
| name | terraform-state-operations |
| description | Use when performing Terraform state surgery - state mv, import, rm operations. Requires extra safety measures. |
State operations modify Terraform's understanding of infrastructure without changing actual resources. These are dangerous because mistakes can orphan resources or cause Terraform to recreate existing infrastructure.
Announce at start: "I'm using the terraform-state-operations skill for safe state surgery."
ALWAYS create a backup before ANY state operation:
# Create timestamped backup
BACKUP_NAME="state-backup-$(date +%Y%m%d-%H%M%S).tfstate"
# For local state
cp terraform.tfstate "$BACKUP_NAME"
# For remote state (S3 example)
terraform state pull > "$BACKUP_NAME"
echo "Backup created: $BACKUP_NAME"
Before proceeding, create a record:
## State Operation Record
**Date:** [timestamp]
**Environment:** [env name]
**Operator:** [user]
**Reason:** [why this operation is needed]
### Planned Operations
1. [operation 1]
2. [operation 2]
### Backup Location
- Local: [path]
- Remote: [if applicable]
### Rollback Plan
[How to restore if something goes wrong]
Present the plan and require explicit approval before executing.
Use case: Rename resources, reorganize modules, refactor code
# List current resources
terraform state list
# Move/rename a resource
terraform state mv aws_instance.old_name aws_instance.new_name
# Move into a module
terraform state mv aws_instance.web module.web.aws_instance.this
# Move between modules
terraform state mv module.old.aws_instance.web module.new.aws_instance.web
Verification after mv:
# Should show no changes
terraform plan
Use case: Remove from state without destroying actual resource (adopting externally-managed resources)
# Remove single resource
terraform state rm aws_instance.legacy
# Remove module
terraform state rm module.legacy
WARNING: The actual resource continues to exist but is no longer managed by Terraform.
Verification after rm:
# Resource should appear as "new" if still in code
# Remove from code if intentionally unmanaging
terraform plan
Use case: Bring existing infrastructure under Terraform management
# Import existing resource
terraform import aws_instance.web i-1234567890abcdef0
# Import with module path
terraform import module.web.aws_instance.this i-1234567890abcdef0
Before import:
Verification after import:
# Should show no changes (or only acceptable differences)
terraform plan
Use case: Backup, migrate, or restore state
# Pull current state
terraform state pull > state.json
# Push state (DANGEROUS - can overwrite!)
# terraform state push state.json # BLOCKED by hook
# Restore from backup
cp "$BACKUP_NAME" terraform.tfstate
# For remote state - may need to disable locking temporarily
# Consult your backend documentation
terraform import ...# Restore backup
cp "$BACKUP_NAME" terraform.tfstate
# Re-initialize to sync with backend
terraform init -reconfigure
Hook blocks this command. If genuinely needed:
Before any state operation:
After operation: