Reputation: 31662
Im trying to do this:
terraform {
backend "s3" {
bucket = "resources"
region = "us-east-1"
key = "resources"
}
}
// the default region
provider "aws" {
region = "us-west-2"
}
//for creating buckets in other regions- region param broken stupid issue with aws_s3_bucket resource...
provider "aws" {
alias = "east1"
region = "us-east-1"
}
resource "aws_s3_bucket" "zzzzz" {
provider = "aws.east1"
bucket = "zzzzz"
acl = "private"
force_destroy = true
}
And getting error
Error creating S3 bucket: AuthorizationHeaderMalformed: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-west-2'
Upvotes: 2
Views: 3859
Reputation: 437
This error is related to your S3 bucket name. Following my example, I had this name: my_bucket
When I changed to a more detailed name (my-project-s3-state-bucket
) the error disappeared.
So, in conclusion, your s3 bucket should be globally unique. PS: Yeah, I agree that the terraform/aws provider error isn't friendly to understand.
Upvotes: 0
Reputation: 2267
This may also happen if your bucket name is not globally unique (not within your account only). Trying a different (usually longer) name would help
Upvotes: 3
Reputation: 31662
I just needed to wait 1hour + because I recreated bucket in different region
Upvotes: 4