Search code examples
amazon-web-servicesterraformterraform-provider-aws

AWS - Terraform Workspace failing to run in different region


I'm working with Terraform workspace to build in multiple regions; however, I've encountered an issue trying to run the same code in a second region. I have no issues running the code in us-east-1, my primary region, but when I run it in a different region, I get the following error:

│ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
│ 
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│ 
│ Error: InvalidClientTokenId: The security token included in the request is invalid.
│       status code: 403, request id: xxx
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 4, in provider "aws":
│    4: provider "aws" {

My provider section in main.tf looks like this:

provider "aws" {
  region = "${var.region}"
  profile = var.profile
}

I'm using config and credentials in the .aws folder for authentication. In my config file, I'm assuming a role, and referencing a source profile in the credentials file. Though using the same profile, which i'm referencing from a variable file, I have no issues running against one region, but do on the second region. However, if I was to use an account specific for the account I'm assuming the role for, I have no issues running the code.

What am I missing, that it runs successfully for one region but the second is failing with same profile?


Solution

  • Issue has been resolved. As I was using an assumed role for another account, I discovered that the region was not enabled on the main account. Once I had enabled the region in AWS, I was able to successfully run terraform on the region.