'How to maintain different aws profiles in terraform provider configuration
I have two AWS env each has one profile Dev for QA env and prod for prod env.
here I would like to maintain single provider configuration block in terraform with multiple profiles as per the env, lets say an if kind of condition to select the profile based on env key.
provider "aws" {
region = "us-east-1"
profile = "dev". (this profile should be taken as per the env type)
default_tags {
terraform = true
}
}
Is this possible?
Solution 1:[1]
Just set the provider without aws Profile that way TF will apply it on the relevant profile.
provider "aws" {
region = "us-east-1"
//profile = "dev". (this profile should be taken as per the env type)
default_tags {
terraform = true
}
}
than change your active profile and default aws profile
AWS_DEFAULT_PROFILE=dev
AWS_PROFILE=dev
and run the TF
terrafotm apply
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Barak Haryati |