Back to Skills

terraform-state-manager

verified

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 GitHub

Marketplace

fastagent-marketplace

armanzeroeight/fastagent-plugins

Plugin

terraform-toolkit

Infrastructure as Code

Repository

armanzeroeight/fastagent-plugins
20stars

plugins/terraform-toolkit/skills/terraform-state-manager/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
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-manager

Installation paths:

Claude
.claude/skills/terraform-state-manager/
Powered by add-skill CLI

Instructions

# 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

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5201 chars