Terraform Import Planner
v1.0.0Generate import blocks from a list of existing resources — addresses, IDs, providers.
Terraform Import Plan
# Step 1: Write the resource block (empty / approximate)
resource "aws_s3_bucket" "my_bucket" {
# Leave empty or with minimal config initially
}
# Step 2: Import existing resource state
terraform import aws_s3_bucket.my_bucket my-bucket-name
# Step 3: Show current state
terraform state show aws_s3_bucket.my_bucket
# Step 4: Update resource block to match state
# Copy attributes from step 3 into the resource block
# Step 5: Plan (should show no changes)
terraform plan
# Terraform 1.5+ import block (declarative, recommended):
import {
to = aws_s3_bucket.my_bucket
id = "my-bucket-name"
}
# Generate config from import (1.5+):
terraform plan -generate-config-out=generated.tf