Interview Prep/Terraform/Import, Already Exists and State Surgery

`Error: Configuration for import target does not exist` when running `terraform plan` with an `import` block.

BeginnerTroubleshootingImport, Already Exists and State Surgery
Answer

Likely causes → The to address has no matching resource block (typo, different name, missing module path or instance key).

Diagnose → Compare to = aws_instance.app with grep -rn 'resource "aws_instance"' .

Fix → Write the resource block, or let Terraform generate it:

terraform plan -generate-config-out=generated.tf

Then clean up generated.tf and move it into proper files.

Prevent → Review generated config before merging; it often contains defaults and conflicting arguments.

All Terraform questions Roadmap: Terraform in production

More on Import, Already Exists and State Surgery