What is it?

Brings existing AWS resources into Terraform management — without recreating them.


The Problem it Solves

Resource already exists in AWS (created manually)
         ↓
You write HCL and run terraform apply
         ↓
ERROR: resource already exists!

Import fixes this by linking the existing resource to your HCL code.


When to Use


Import Workflow

1. Resource exists in AWS (created manually)
2. Write empty resource block in HCL
3. terraform import <resource_address> <aws_id>
4. terraform state show <resource> — see what was imported
5. Copy config from state into your HCL code
6. terraform plan — verify no changes
7. Done — Terraform now manages this resource

Real Example — S3 Bucket

You created daksh-ex-demo bucket in AWS Console months ago. Now you want Terraform to manage it.

Step 1 — Write empty resource block

resource "aws_s3_bucket" "main" {
  # empty for now
}

Step 2 — Import