What is Terraform import?

Answer

Terraform import brings existing infrastructure (created manually or by other tools) under Terraform management. Without importing, Terraform would try to create duplicate resources. Classic syntax: terraform import aws_instance.web i-0abc123def — adds the existing EC2 instance to state. You must write the corresponding resource block in your configuration before importing. After import, run terraform plan — if the configuration matches reality, it shows no changes; if not, the plan shows what Terraform would change to match your config. New import block (Terraform 1.5+): declarative import in HCL: import { to = aws_instance.web; id = "i-0abc123def" }. Run terraform plan -generate-config-out=generated.tf to auto-generate the resource block. Import does not modify the actual infrastructure — it only updates state. Avoid importing large numbers of resources manually; consider tools like Terraformer or cf2tf for bulk import.