`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.
More on Import, Already Exists and State Surgery
Apply fails with `EntityAlreadyExists: Role with name app-role already exists.`Beginner`terraform apply` on a new bucket fails with `BucketAlreadyExists`. You have never created that bucket.Beginner`Error: Resource already managed by Terraform` when running `terraform import aws_s3_bucket.logs acme-logs`.Beginner`Error: Cannot import non-existent remote object` for a resource you can see in the console.Intermediate`terraform plan -generate-config-out=generated.tf` fails with `Conflicting configuration arguments` in the generated file.IntermediateAfter importing an S3 bucket, the plan still shows `+ force_destroy = false` as an update.Beginner