Terraform-provider-aws: Terraform does not error if an S3 bucket already exists

Created on 16 Nov 2018  路  3Comments  路  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.7
terraform-provider-aws v1.45.0

Affected Resource(s)

aws_s3_bucket

Terraform Configuration Files

resource "aws_s3_bucket" "bucket" {
  bucket = "bucket-name-that-already-exists"
  acl    = "private"
}

Expected Behavior

Error: S3 bucket with name "bucket-name-that-already-exists" already exists

Actual Behavior

Upon plan/apply, Terraform acts as if it created the resource and begins managing it in state, leaving the bucket under two different Terraform configurations management/state files.

Steps to Reproduce

Define two resources with the same bucket name. Can be in the same Terraform configuration or different ones.

Important Factoids

We keep all SDLC environments in separate Terraform workspaces. When develops work locally, they get a workspace with the name of their git branch. This was discovered by a developer copy/pasting the name of an existing bucket while testing into a resource within their branch that already existed.

After that we were able to confirm if we simply copy/paste the resource N times and change the resource name (but not the bucket name), they all create successfully.

bug servics3

Most helpful comment

It is nuts that this is still open! We just encountered a problem with this where someone created a bucket in a new project but messed up the name, and terraform said the bucket created successfully and added it to its state. When we went back and fixed the name, terraform tried to delete the bucket (it was in two different tfstates at that point).

+1'ed

All 3 comments

I submitted a pull request for this issue, if someone could take a look at it that would be great

It is nuts that this is still open! We just encountered a problem with this where someone created a bucket in a new project but messed up the name, and terraform said the bucket created successfully and added it to its state. When we went back and fixed the name, terraform tried to delete the bucket (it was in two different tfstates at that point).

+1'ed

Was this page helpful?
0 / 5 - 0 ratings