Reputation: 493
I use Terraform v0.13.5 to provision resources for multiple projects using multiple profiles.
I have the following declared in provider.tf
:
shared_credentials_file = "~/.aws/credentials"
profile = "profile_name"
But I get the error:
Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
It works if I use shell environment variables:
export AWS_SHARED_CREDENTIALS_FILE=/Users/$USER/.aws/credentials
export AWS_PROFILE=profile_name
It seems that both the environment variables and the info in the provider file are required. If there's a mismatch between the two, Terraform errors out.
I can add the environment variables to .bashrc
but it's a pain since I have multiple profile names for different projects.
How can I use multiple profiles and specify them only in the terraform.tf
file?
Upvotes: 0
Views: 706
Reputation: 493
Martin's comment is correct.
I needed to also add my profile name to the terraform.tf file as well as the provider.tf file.
I did following and it worked.
terraform {
backend "s3" {
bucket = "my_bucketname"
key = "my_keyname"
region = "us-west-1"
profile = "my_profile_name"
}
}
Upvotes: 1