You ran `terraform state rm aws_db_instance.main` to "fix" a plan error. The next apply fails with `DBInstanceAlreadyExists`.
IntermediateTroubleshootingImport, Already Exists and State Surgery
Answer
Likely causes → state rm only forgets the object; the database still exists. The code still declares it, so Terraform tries to create a new one with the same identifier.
Diagnose → aws rds describe-db-instances --db-instance-identifier prod-db
Fix → Re-import it:
terraform import aws_db_instance.main prod-db
terraform plan
Prevent → Use state rm only when you also remove the block (or use a removed block, which does both in one reviewed change).
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`Error: Configuration for import target does not exist` when running `terraform plan` with an `import` block.Beginner`terraform plan -generate-config-out=generated.tf` fails with `Conflicting configuration arguments` in the generated file.Intermediate