Manages Terraform state operations including importing existing resources, moving resources between states, removing resources from state, and migrating state backends. This skill should be used when users need to import infrastructure into Terraform, refactor resource addresses, fix state issues, or migrate state storage locations.
View on GitHubarmanzeroeight/fastagent-plugins
terraform-toolkit
plugins/terraform-toolkit/skills/terraform-state-manager/SKILL.md
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/armanzeroeight/fastagent-plugins/blob/main/plugins/terraform-toolkit/skills/terraform-state-manager/SKILL.md -a claude-code --skill terraform-state-managerInstallation paths:
.claude/skills/terraform-state-manager/# Terraform State Manager
This skill provides safe workflows for Terraform state operations and troubleshooting.
## When to Use
Use this skill when:
- Importing existing infrastructure into Terraform
- Moving resources to different addresses (renaming)
- Removing resources from state without destroying them
- Migrating state between backends (local to S3, etc.)
- Recovering from state corruption or conflicts
- Splitting or merging state files
## Critical Safety Rules
**ALWAYS follow these rules when working with state:**
1. **Backup first**: Create state backup before any operation
2. **Plan after**: Run `terraform plan` after state changes to verify
3. **One at a time**: Make incremental changes, not bulk operations
4. **Test in non-prod**: Practice state operations in dev/test first
5. **Version control**: Commit code changes with state operations
## Common Operations
### 1. Import Existing Resources
**Workflow:**
```bash
# Step 1: Write the resource configuration in .tf file
# Step 2: Import the resource
terraform import <resource_address> <resource_id>
# Step 3: Verify with plan (should show no changes)
terraform plan
```
**Example - Import AWS S3 Bucket:**
```hcl
# 1. Add to main.tf
resource "aws_s3_bucket" "existing" {
bucket = "my-existing-bucket"
}
# 2. Import
terraform import aws_s3_bucket.existing my-existing-bucket
# 3. Verify
terraform plan # Should show: No changes
```
**Tips:**
- Find resource ID format in provider docs
- Import one resource at a time
- Some resources require multiple imports (bucket + versioning + encryption)
- Use `terraform show` to see imported attributes
### 2. Move Resources (Rename/Refactor)
**Workflow:**
```bash
# Move resource to new address
terraform state mv <source> <destination>
# Verify
terraform plan # Should show: No changes
```
**Example - Rename Resource:**
```bash
# Before: aws_s3_bucket.bucket
# After: aws_s3_bucket.main
terraform state mv aws_s3_bucket.bucket aws_s3_bucket.main
```
**Ex