Interview Prep/Terraform/State Internals

How do import blocks improve on the CLI command?

IntermediateConceptState Internals
Answer

Since Terraform 1.5 you declare import { to = ..., id = ... } in code, so imports appear in plan, can be reviewed in PRs and run through CI. terraform plan -generate-config-out=generated.tf drafts the resource configuration for you.

import {
  to = aws_s3_bucket.logs
  id = "acme-logs"
}

Remove the import block after apply (or leave it; it is idempotent).

All Terraform questions Roadmap: Terraform in production

More on State Internals