Terraform v0.11.7
terraform-provider-aws v1.45.0
aws_s3_bucket
resource "aws_s3_bucket" "bucket" {
bucket = "bucket-name-that-already-exists"
acl = "private"
}
Error: S3 bucket with name "bucket-name-that-already-exists" already exists
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.
Define two resources with the same bucket name. Can be in the same Terraform configuration or different ones.
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.
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
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