Comments (15)
@sev3ryn Note that S3 bucket names must be globally unique amongst all AWS customers.
from terraform-aws-tfstate-backend.
Hi @organicnz This is normal behavior with S3 buckets, when buckets have deleted the names takes some time to be released so that it can be reused, this is not a bug on the module or terraform, this is how the AWS S3 api works
from terraform-aws-tfstate-backend.
I have same issue - I'm creating bucket that never existed before with just random name but receive Error creating S3 bucket: BucketAlreadyExists
from terraform-aws-tfstate-backend.
To make your bucket name unique, you can add random string after attributes. In my case, i define it like this
resource "random_string" "random" {
length = 12
upper = false
number = false
lower = true
special = false
}
module "terraform_state_backend" {
source = "cloudposse/tfstate-backend/aws"
# Cloud Posse recommends pinning every module to a specific version
version = "0.33.1"
namespace = "eg"
stage = "test"
name = "terraform"
attributes = ["state-${random_string.random.result}"]
terraform_backend_config_file_path = "."
terraform_backend_config_file_name = "backend.tf"
force_destroy = false
}
This is more easier than searching new unique name since S3 bucket name is globally unique.
from terraform-aws-tfstate-backend.
@sev3ryn Note that S3 bucket names must be globally unique amongst all AWS customers.
thanks for reminding, it helped :)
cheers!
from terraform-aws-tfstate-backend.
@organicnz is you did not destroy the bucket before creating this is going to happen.
this is not a bug AFAIK
from terraform-aws-tfstate-backend.
are you cleaning the .terraform dir and such when switching to another region? this is to create the bucket for the state to be stored so it should not exist in the state until is created.
I will assume you switched to another region because you do not have a state so in that case, you need to reinitialize the project which can be done by rm -rf .terraform
and then terraform init
and then apply or plan
from terraform-aws-tfstate-backend.
yes, thanks, thats was it. Interesting what is aws reasoning behind that if bucket is not even public :)
from terraform-aws-tfstate-backend.
@organicnz is you did not destroy the bucket before creating this is going to happen.
this is not a bug AFAIK
Just tried it again and it spews the same error :)
terraform destroy -refresh=false
var.region
AWS Region the S3 bucket should reside in
Enter a value: us-west-2
provider.aws.region
The region where AWS operations will take place. Examples
are us-east-1, us-west-2, etc.
Enter a value: us-west-2
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
Destroy complete! Resources: 0 destroyed.
terraform apply -auto-approve
var.region
AWS Region the S3 bucket should reside in
Enter a value: us-west-2
provider.aws.region
The region where AWS operations will take place. Examples
are us-east-1, us-west-2, etc.
Enter a value: us-west-2
data.aws_iam_policy_document.prevent_unencrypted_uploads[0]: Refreshing state...
module.terraform_state_backend.data.aws_iam_policy_document.prevent_unencrypted_uploads[0]: Refreshing state...
module.terraform_state_backend.aws_dynamodb_table.with_server_side_encryption[0]: Creating...
aws_dynamodb_table.with_server_side_encryption[0]: Creating...
module.terraform_state_backend.aws_s3_bucket.default: Creating...
aws_s3_bucket.default: Creating...
module.terraform_state_backend.aws_dynamodb_table.with_server_side_encryption[0]: Still creating... [10s elapsed]
aws_dynamodb_table.with_server_side_encryption[0]: Still creating... [10s elapsed]
module.terraform_state_backend.aws_dynamodb_table.with_server_side_encryption[0]: Creation complete after 10s [id=eg-test-terraform-state-lock]
aws_dynamodb_table.with_server_side_encryption[0]: Creation complete after 12s [id=terraform-state-lock]
Error: Error creating S3 bucket: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
status code: 409, request id: 4A229001A6A1EA6C, host id: LlszF09zWpcTVFKP0IEWt52qEFMjHbFSwtfU8W0S7scUK53fjrG2ACyY7QDwGgFkvmMh6t9uuj8=
on main.tf line 145, in resource "aws_s3_bucket" "default":
145: resource "aws_s3_bucket" "default" {
Error: Error creating S3 bucket: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
status code: 409, request id: 59E964BDAA48DCDD, host id: aKpwR55Nh0aRFwAIv6Y8QQkMcnmZWSUFOLuvL5nmO4Bh+eOSAayCmXE1zrIHT66Faah1/VfglMA=
on .terraform/modules/terraform_state_backend/main.tf line 124, in resource "aws_s3_bucket" "default":
124: resource "aws_s3_bucket" "default" {
from terraform-aws-tfstate-backend.
Hi @organicnz This is normal behavior with S3 buckets, when buckets have deleted the names takes some time to be released so that it can be reused, this is not a bug on the module or terraform, this is how the AWS S3 api works
Yeah, looks like it is, still cleaning up S3 buckets in region us-west-2, but when it passed that step in us-west-1 or us-east-1 it drops another error with coalescelist
. Someone mentioned that it should rely on the conditional operator on a thread.
terraform apply -auto-approve
var.region
AWS Region the S3 bucket should reside in
Enter a value: us-west-1
provider.aws.region
The region where AWS operations will take place. Examples
are us-east-1, us-west-2, etc.
Enter a value: us-west-1
module.terraform_state_backend.data.aws_iam_policy_document.prevent_unencrypted_uploads[0]: Refreshing state...
data.aws_iam_policy_document.prevent_unencrypted_uploads[0]: Refreshing state...
aws_dynamodb_table.with_server_side_encryption[0]: Refreshing state... [id=terraform-state-lock]
module.terraform_state_backend.aws_dynamodb_table.with_server_side_encryption[0]: Refreshing state... [id=eg-test-terraform-state-lock]
Error: Error in function call
on main.tf line 255, in data "template_file" "terraform_backend_config":
255: coalescelist(
256:
257:
258:
|----------------
| aws_dynamodb_table.with_server_side_encryption is empty tuple
| aws_dynamodb_table.without_server_side_encryption is empty tuple
Call to function "coalescelist" failed: no non-null arguments.
Error: Error in function call
on .terraform/modules/terraform_state_backend/main.tf line 234, in data "template_file" "terraform_backend_config":
234: coalescelist(
235:
236:
237:
|----------------
| aws_dynamodb_table.with_server_side_encryption is empty tuple
| aws_dynamodb_table.without_server_side_encryption is empty tuple
Call to function "coalescelist" failed: no non-null arguments.
from terraform-aws-tfstate-backend.
are you cleaning the .terraform dir and such when switching to another region? this is to create the bucket for the state to be stored so it should not exist in the state until is created.
I will assume you switched to another region because you do not have a state so in that case, you need to reinitialize the project which can be done by
rm -rf .terraform
and thenterraform init
and then apply or plan
Thank you, I haven't cleaned it up before you mentioned and my deep apologies that it's not a bug as it was labelled initially.
That's so weird it shows empty S3 storage, but the issue doesn't disappear anywhere. Should this error be rather addressed to AWS?
#Error: Error creating S3 bucket: BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
status code: 409, request id: C83D6B33B66E5AD0, host id: nsXFCzCdd2+HJUyPrrHIQokq735AEYzTntQPdNUY7OOBF+GSd5WrljJKto7LyyThoCsBCIt3LIQ=
on .terraform/modules/terraform_state_backend/main.tf line 124, in resource "aws_s3_bucket" "default":
124: resource "aws_s3_bucket" "default" {
from terraform-aws-tfstate-backend.
Any conclusion ? I got same weird BucketAlreadyExists error
from terraform-aws-tfstate-backend.
Any conclusion ? I got same weird BucketAlreadyExists error
Hi mate, have you tried to create a new unique S3 bucket? I tried on a different AWS account and it helped to resolve this issue :)
from terraform-aws-tfstate-backend.
This doesn't seem like an issue with this module as this module cannot ensure that the bucket name is unique globally
from terraform-aws-tfstate-backend.
Error: creating S3 Bucket (swethabuckets7128834): operation error S3: CreateBucket, https response error StatusCode: 409, RequestID: 08J2B14W7G3ZB0D0, HostID: CegKwKnfuzghXHKd7N0RI7VlOVzYUVNErrFDzhtg/+hzWMs8KUF3Jeq1m9PEydPJMx6nuSzQZsFYEjICOjWsJw==, BucketAlreadyOwnedByYou:
Getting above error while changing tfstate file to remote.
from terraform-aws-tfstate-backend.
Related Issues (20)
- Dependency Dashboard
- darwin_arm64 still not supported HOT 5
- KMS encryption HOT 1
- Logging bucket generates a name with a duplicate HOT 4
- Using this module without without specifying an external context label module generates invalid resource names
- Upgrading from <0.33.1 to >=0.33.1 requires state move for bucket HOT 2
- terraform-provider-aws v4.0 incompatibility HOT 2
- Allow making changes to the s3 bucket policy
- terraform apply completes successfully with "Warning: Argument is deprecated" HOT 5
- Unable to be used with terraform workspaces HOT 2
- Reimplement with "cloudposse/terraform-aws-s3-bucket" to standardize parameters/features
- Add delete_protection to DynamoDB table HOT 3
- No compatibility with terraform v1.6 HOT 1
- Add lifecycle configuration to delete objects under a certain size to remove destroyed states
- Error releasing the state lock
- Feature Request - Allow a parameter for the name of DynamoDB table HOT 1
- Error creating S3 bucket ... the region 'us-east-1' is wrong; expecting 'eu-central-1' HOT 3
- Remove the `read_capacity` and `write_capacity` from lifecycle change ignore
- Add support for multiple terraform backend config files HOT 6
- DynamoDB label attributes inconsistent due to null label module HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-aws-tfstate-backend.