We recently didn’t set a default provider (i.e., every provider had an alias).
provider "aws" {
alias = "primary"
region = var.region
assume_role {
role_arn = var.aws_account_name_arn_map[var.aws_account_name]
}
}
provider "aws" {
alias = "secondary"
region = "us-east-1"
assume_role {
role_arn = var.aws_account_name_arn_map[var.aws_account_name]
}
}
provider "aws" {
alias = "ops"
region = var.region
assume_role {
role_arn = var.aws_account_name_arn_map["ops"]
}
}
We couldn’t figure out why the ops
alias was used as the provider for a specific child module.
We came across this description in the official documentation. Can someone please decipher the second paragraph as it isn’t clear which provider’s chosen if all providers have an alias:
If every explicit configuration of a provider has an alias, Terraform uses the implied empty configuration as that provider’s default configuration. (If the provider has any required configuration arguments, Terraform will raise an error when resources default to the empty configuration.)