Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

7.1.1. terraform import and Import Blocks

💡 First Principle: Import is fundamentally a state operation — it binds an existing real resource to a configuration address — so the address you import to must already (or eventually) have a matching resource block, or Terraform will plan to destroy the unmanaged-looking entry.

The classic CLI command maps one real resource ID to one configuration address:

terraform import aws_instance.web i-1234567890abcdef0

This writes the resource into state but does not create configuration. You must write a matching resource "aws_instance" "web" block; if its arguments don't match reality, the next plan shows changes.

Import blocks (Terraform 1.5+) make import declarative and reviewable:

import {
  to = aws_instance.web
  id = "i-1234567890abcdef0"
}

Because they live in configuration, import blocks are planned (you see the import in terraform plan), version-controlled, and can import many resources at once — a big improvement over the imperative command.

⚠️ Exam Trap: Classic terraform import imports into state only, one resource at a time, and never generates config. Import blocks are declarative, plannable, and support bulk import. Don't attribute config generation to the classic command.

Reflection Question: After running classic terraform import for a resource but before writing its resource block, what would the next terraform plan propose, and why?

Alvin Varughese
Written byAlvin Varughese
Founder18 professional certifications