Submitted by mig5 on
This may be obvious to others, but it wasn't to me.
I was setting up Terraform remote state storage (to an s3 bucket) like so:
-backend-config="bucket=mig5-terraform-state" \
-backend-config="key=terraform.tfstate"
I kept getting the error on the above:
This worked, of course:
-backend-config="bucket=mig5-terraform-state" \
-backend-config="key=terraform.tfstate"
.. but it's annoying. I don't want to have to specify the region here, because it's already set as 'region' in ~/.aws/config in the [default] section. I put it in ~/.aws/credentials too, to no avail. Probably a bug.
To make matters worse, even after the above worked, commands that compare state like 'terraform plan' would still error out with the same message.
It turns out you need to specify the region as a -backend-config parameter to the 'terraform remote config' command. Like this:
-backend-config="bucket=mig5-terraform-state" \
-backend-config="key=terraform.tfstate" \
-backend-config="region=us-west-2"
After that, terraform commands run fine.
Naturally, only after writing this article did I notice that the Terraform doc has finally been updated to include the 'region' parameter. I am sure it wasn't there a month or so ago. Grr!