Use Terraform import blocks with a generate configuration approach to import existing cloud resources and produce the corresponding resource configuration

domain: developer.hashicorp.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add import blocks to a Terraform configuration file specifying the to address of the resource block and the id string that uniquely identifies the existing cloud resource
  2. Run terraform plan with the -generate-config-out flag pointing to an output file to have Terraform generate the initial resource configuration based on the imported resource's current state
  3. Review the generated configuration file for accuracy, removing read-only attributes that Terraform manages internally and adjusting computed fields that should not appear in the desired-state config
  4. Run terraform plan again without the generate flag to confirm the import produces no planned changes, indicating the generated configuration matches the live resource state
  5. Commit the import blocks and resource configuration to version control, noting that import blocks are idempotent and safe to leave in the configuration after the initial import

Known gotchas

Related routes

Import existing cloud resources into Terraform without recreating them
terraform · 4 steps · unrated
Configure Terraform S3 backend with native state locking (use_lockfile) without DynamoDB
developer.hashicorp.com/terraform/language/backend/s3 · 6 steps · unrated
Use Terraform moved blocks to refactor a flat root module into child modules without destroying and recreating resources
terraform.io · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans