Terraform: Error: creating S3 Bucket (my-bucket): BucketAlreadyOwnedByYou / EntityAlreadyExists: Role with name x already exists
The resource exists outside Terraform's state (created manually or by another stack), so create fails.
Error: creating S3 Bucket (my-bucket): BucketAlreadyOwnedByYouEntityAlreadyExists: Role with name x already existsError: error creating IAM Role: EntityAlreadyExistsResourceAlreadyExistsException: The specified log group already existsError: creating EC2 Security Group: InvalidGroup.Duplicate Meaning
Import it into state (terraform import aws_iam_role.x role-name, or an import {} block in 1.5+), then let Terraform manage it. Or use a different name, or remove the duplicate resource. For multi-environment name clashes add suffixes. After import run plan to reconcile differences.
Common causes
- Resource created manually previously
- State lost/different backend/workspace
- Two stacks managing the same resource
- Name collision across environments
- Failed apply left a resource created but not in state
⚡ Quick fix
terraform import ADDRESS ID(orimport { to = ..., id = "..." }) thenterraform plan- Use unique names per environment
- Check you're using the right workspace/backend
Detailed fix by platform
Terraform
terraform import aws_s3_bucket.logs my-logs-bucket
How to diagnose
- Exists — In the cloud?
- State — Tracked?
- Workspace — Right?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AlreadyExists Error from server (AlreadyExists): ... already exists
- Cannot import non-existent remote object Terraform: Error: Cannot import non-existent remote object — While attempting to import an existing object to "aws_s3_bucket.logs", the provider detected that no object exists with the given id
- Error running command: exit status 1 (local-exec/remote-exec) Terraform: Error: local-exec provisioner error — Error running command './deploy.sh': exit status 1. Output: ...
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026