In my main.tf
file I have:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
region = "us-west-2"
}
When I run terraform plan
, I am getting the error below:
Error: configuring Terraform AWS Provider: failed to get shared config profile, terragrunt
with provider["registry.terraform.io/hashicorp/aws"],
on provider.tf line 2, in provider "aws":
2: provider "aws" {
In my case, I’m not using terragrunt
in the project at all, purely terraform
and the error message isn’t helpful.
2
Answers
Solution:
My
AWS_PROFILE
env variable was set toterragrunt
. And because my~/.aws/credentials
file didn't have a profile for terragrunt, I was getting the error. I had to set it to an existing profile and my problem was fixed.Context:
The
shared config profile
terraform is talking about has to do with theprovider.profile
variable inmain.tf
,AWS_PROFILE
environment variable, and the~/.aws/credentials
file. In that order of prescedence.If your
~/.aws/credentials
doesn't have a default profile, then you must point to it explicitly. For example, if it looks like below:Then you have to either
export AWS_PROFILE=https://sso.jumpcloud.com/saml2/aws
or
profile
in yourmain.tf
This worked for me on Windows: