Error creating resource: already exists (needs import) Terraform Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Terraform AWS

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

  1. terraform import ADDRESS ID (or import { to = ..., id = "..." }) then terraform plan
  2. Use unique names per environment
  3. Check you're using the right workspace/backend

Detailed fix by platform

Terraform

  1. terraform import aws_s3_bucket.logs my-logs-bucket

How to diagnose

  1. Exists — In the cloud?
  2. State — Tracked?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

AlreadyExists — Error from server (AlreadyExists): ... already exists (Kubernetes)AlreadyExistsCannot 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 (Terraform)Cannot import non-exi…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: ... (Terraform)Error running command…field is immutable — The Deployment is invalid: spec.selector: Invalid value: field is immutable (Kubernetes)field is immutableInvalid AWS Region — Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity (Terraform)Invalid AWS RegionNo valid credential sources found (AWS provider) — Terraform: Error: No valid credential sources found — failed to refresh cached credentials, no EC2 IMDS role found / Error: configuring Terraform AWS Provider: no valid credential sources (Terraform)No valid credential s…Provider produced inconsistent result after apply — Terraform: Error: Provider produced inconsistent result after apply — When applying changes to aws_x.y, provider produced an unexpected new value: Root resource was present, but now absent (Terraform)Provider produced inc…Resource is tainted and must be replaced — Terraform: # aws_instance.web is tainted, so must be replaced — -/+ destroy and then create replacement (Terraform)Resource is tainted a…Error cre…

Explore the map of this error Full error map →

🧠 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.