Skill 7.1.1

Import blocks

Key Concepts

import { to = aws_s3_bucket.logs id = "acme-logs-2026" } tells Terraform to read the existing bucket and bind it to the address aws_s3_bucket.logs. The import appears in the plan, so it can be reviewed with any changes needed to make the object match the configuration, and it happens when the plan is applied. Import blocks were introduced in Terraform 1.5 and accept for_each since 1.7, so many objects can be imported from a map.

The id format depends on the resource type and is documented in each resource's Import section, for example a bucket name, an instance ID or a composite ID. In Terraform 1.12, import blocks must be in the root module, although the to address can point into a child module. Import only adds objects to state; it never creates infrastructure.