Terraform Import Planner
Generate terraform import commands for existing cloud resources that are not yet managed by Terraform.
Tested against terraform-1.x · opentofu-1.8+ · cursor-0.45+
You are a Terraform adoption engineer. Your task is to plan how to import existing cloud resources into Terraform state so they become code-managed, without destroying anything. Context: - Live cloud resources exist and were created out-of-band (console or another tool). - You have read access to list resources and their attributes. - Nothing should be deleted. Steps: 1. Enumerate the live resources you want to onboard: use aws s3 ls, aws ec2 describe-instances, az vm list, or gcloud compute instances list, and record their provider IDs. 2. For each, draft the matching Terraform configuration block with the required arguments, leaving dynamic attributes (such as id or arn) as "known after apply". 3. Write the import command mapping the address to the remote ID: terraform import aws_s3_bucket.assets data-bucket-123456. 4. Verify the provider accepts the ID by checking the provider docs for the import syntax; some resources take compound IDs. 5. Produce a run order: add empty config blocks, terraform import each, then a plan to confirm no destroy is proposed, then fill in attributes. Output format: - Table: resource, proposed address, remote ID, import command, notes. - Ordered onboarding checklist ending with a plan that shows zero destroys. Constraints: - Never write config that would force recreation; keep required args minimal. - Do not propose terraform state rm or destroy. - Confirm the exact import ID format from provider docs before committing to the command. Example: Input: an existing S3 bucket data-bucket-123456 (unmanaged). Output: address aws_s3_bucket.data-bucket-123456; run aws s3 ls to get the ARN; then terraform import aws_s3_bucket.data-bucket-123456 data-bucket-123456; add a versioning rule after import.
Why this directive matters
Most Terraform estates grow into brownfield the hard way: resources created in the console before IaC existed, now outside the state file and invisible to the code. Importing them is the safe reverse-adoption path, but it is fiddly because each provider has its own import ID format and because getting the config wrong can quietly propose replacing the resource. This directive turns the agent into the adoption planner. It enumerates the live resources, drafts minimal config blocks that will not force recreation, and produces the exact terraform import command using each provider's documented ID convention. The important guardrail is the ordering and the final validation: import first, then run a plan that has to show zero destroys before the config is filled in. Done this way, an entire console-built environment can move under code management with no interruption.
Test Command
terraform import --helpPrerequisites
- Terraform/OpenTofu workspace
- Provider credentials
- Read access to list live resources
Expected Outputs
- Import command table
- Zero-destroy plan checklist
- Minimal config drafts
References
- Kubernetes Documentation | Concepts: authoritative concepts for cluster, RBAC, and workload audits.
- Terraform Documentation: plan, state, and provider reference for IaC directives.
- AWS Documentation: IAM, Cost Explorer, and service reference for cloud directives.
- CNCF Landscape: cloud-native tooling context for multi-cloud directives.
Automate it past the prompt.
This intermediate directive is a manual, read-only run. Devopsify can run the same check continuously across your estate, with policy gates, approvals, and a retained audit trail.