npx claudepluginhub joshuarweaver/cascade-code-devops-misc-1 --plugin lgbarn-terraform-aws-eks<resource_address> <resource_id>state/# Import Resources into Terraform Import existing AWS resources into Terraform state. Arguments: $ARGUMENTS ## When to Use Import - Bringing existing resources under Terraform management - Recovering from accidental state deletion - Migrating from other IaC tools - Adopting Terraform for existing infrastructure ## Import Process ### 1. Write Resource Configuration Before importing, you must have the resource defined in Terraform: ### 2. Run Import Command ### 3. Fill in Configuration After import, update the resource to match actual state. ## Common Import Commands ### EC2 Insta...
/importImports external plan file (--from <filepath>) into GSD PLAN.md with conflict detection against PROJECT.md before writing, then validates.
/importDisplays migration notice for removed JSONL issue import command, instructing use of bd init --from-jsonl flag with Dolt backend.
/importImports instincts from an export file into inherited/ directory after confirmation, prefixing filenames to avoid conflicts and updating identity counts.
/importImports CSV, JSON, JSONL, or PDF files into a Weaviate collection with mapping, field skipping, multi-tenancy, and batching options.
/importImports memories from Codex CLI (AGENTS.md), Cursor (.cursor/rules/), and Windsurf (.windsurfrules) into Nemp with conflict detection and guided resolution. Pro feature.
/importImports document from file path (MD/TXT/PDF) or pasted text, extracts/maps content to PR/FAQ sections, launches /prfaq workflow.
Import existing AWS resources into Terraform state. Arguments: $ARGUMENTS
Before importing, you must have the resource defined in Terraform:
# This must exist BEFORE import
resource "aws_instance" "web" {
# Configuration will be filled after import
}
# Terraform
terraform import <resource_address> <resource_id>
# OpenTofu
tofu import <resource_address> <resource_id>
After import, update the resource to match actual state.
terraform import aws_instance.web i-1234567890abcdef0
terraform import aws_security_group.web sg-1234567890abcdef0
terraform import aws_s3_bucket.data my-bucket-name
terraform import aws_iam_role.app my-role-name
terraform import aws_db_instance.main my-database-id
terraform import aws_vpc.main vpc-1234567890abcdef0
terraform import aws_subnet.private subnet-1234567890abcdef0
terraform import aws_eks_cluster.main my-cluster-name
terraform import aws_eks_node_group.main my-cluster:my-node-group
Use import blocks for declarative imports:
# imports.tf
import {
to = aws_instance.web
id = "i-1234567890abcdef0"
}
import {
to = aws_security_group.web
id = "sg-1234567890abcdef0"
}
Then run:
terraform plan -generate-config-out=generated.tf
## Import Resource: [Resource Type]
### Resource Details
- **Address**: aws_instance.web
- **ID**: i-1234567890abcdef0
- **Type**: aws_instance
### Pre-Import Checklist
- [ ] Resource configuration exists in .tf files
- [ ] Resource ID verified in AWS console
- [ ] No conflicting resource in state
- [ ] Backup of current state exists
### Import Command
```bash
terraform import aws_instance.web i-1234567890abcdef0
aws_instance.web: Importing from ID "i-1234567890abcdef0"...
aws_instance.web: Import prepared!
Prepared aws_instance for import
aws_instance.web: Refreshing state...
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
View imported state
terraform state show aws_instance.web
Update configuration to match
resource "aws_instance" "web" {
ami = "ami-0abcdef1234567890"
instance_type = "t3.large"
vpc_security_group_ids = [aws_security_group.web.id]
subnet_id = aws_subnet.private.id
tags = {
Name = "myproject-prod-web"
}
}
Verify no changes
terraform plan
# Should show: No changes. Infrastructure is up-to-date.
Based on the imported resource, here's a configuration template:
resource "aws_instance" "web" {
ami = "ami-0abcdef1234567890" # From state
instance_type = "t3.large" # From state
subnet_id = "subnet-xxx" # Replace with reference
vpc_security_group_ids = ["sg-xxx"] # Replace with reference
root_block_device {
volume_size = 100
volume_type = "gp3"
}
tags = {
Name = "myproject-prod-web"
Project = var.project
Environment = var.environment
Terraform = "true"
}
}
| Issue | Cause | Solution |
|---|---|---|
| Resource already in state | Duplicate import | Remove first: terraform state rm |
| Cannot find resource | Wrong ID | Verify ID in AWS console |
| Configuration mismatch | Missing attributes | Add required attributes to config |
## Workflow
1. Verify resource exists in AWS
2. Get resource ID from AWS console
3. Write minimal resource configuration
4. Run import command
5. View imported state
6. Update configuration to match state
7. Run plan to verify no changes
8. Add proper references and variables