Closed glindstedt closed 2 years ago
Hi @glindstedt, thanks for submitting this.
Values directly configured in the Terraform source files have the highest precedence when resolving configuration. The order is:
provider "aws" { ... }
While we refer to Terraform files as a "configuration", it's best to think of them as source files, and not configuration files. Directly configuring the profile
value in the provider block is equivalent to passing --profile
when using the AWS CLI.
There are several solutions you could use:
AWS_PROFILE
profile
parameter a Terraform variable, so that it can be configured from the command line or a variable fileI'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
Provider and backend configuration.
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
Expected Behavior
That
AWS_PROFILE
is able to override the profile set in the terraform file. In general I expect programs to treat environment variables (and command line arguments) as overrides to options which might otherwise be defined in configuration files.Actual Behavior
Terraform still tries to use the profile that's set in the terraform file. If I comment out that line it correctly picks up on the
AWS_PROFILE
environment variable and uses that profile.Steps to Reproduce
backend
andprovider
withprofile
set to a profile that doesn't exist in your configAWS_PROFILE
environment variable to a profile that does existterraform plan
, terraform will insist on trying to use the profile defined in the terraform file instead of accepting the override