Terraform v0.8.8
provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "res_s3_bucket" {
bucket = "tf-bucket-region-issue"
region = "us-east-1"
}
https://gist.github.com/mzraly/6c4cbdd2f8016c0526bd3b18b7a43a01
None
Documentation at https://www.terraform.io/docs/providers/aws/r/s3_bucket.html suggests that by specifying the region in an aws_s3_bucket resource that bucket will be created in that region. In the example above, we expected the bucket to be created in us-east-1.
The bucket is created in the region specified by the provider, us-west-2.
terraform applyNone
None I am aware of.
Hi @mzraly
us-east-1 is - historically - a special region.
To create a bucket in the us-east-1 region, you need to specify the provider explicitly omitting the region, as in:
provider "aws" {
region = "us-west-2"
}
provider "aws" {
alias = "useast"
region = "us-east-1"
}
resource "aws_s3_bucket" "bucket" {
provider = "aws.useast" # Set this and remove the region argument
bucket = "my-bucket"
}
The issue is that you can't set the region when the target is us-east-1, since it is an exception on the AWS side (Error returned is: InvalidLocationConstraint: The specified location-constraint is not valid).
Does it help?
Hi @Ninir,
Thanks for explaining the reason behind the failure. Up to you guys how much you want to expose or mask underlying provider inconsistencies, but if you don't mask them then please document them.
@mzraly Note: for importing buckets from different regions you may also need to pass provider in the import argument to match the bucket provider (Ex: -provider=aws.useast).
See: https://github.com/hashicorp/terraform/issues/13750#issuecomment-295281815
Want to note that is your apply a second time, the output says it will be change to us-east-1, but is does not actually (w/o the custom provider for us-east-1).
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.