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

`Error: Resource already managed by Terraform` when running `terraform import aws_s3_bucket.logs acme-logs`.

BeginnerTroubleshootingImport, Already Exists and State Surgery
Answer

Likely causes → That address already has an object in state. Terraform refuses to import over it.

Diagnose → terraform state show aws_s3_bucket.logs — is it the same bucket or a different one?

Fix → If it's the same bucket, nothing to do. If the state points to a wrong/deleted object, terraform state rm aws_s3_bucket.logs first, then import.

Prevent → Use import blocks in PRs so the plan shows what will be imported before anything changes.

All Terraform questions Roadmap: Terraform in production

More on Import, Already Exists and State Surgery