As you can see below, I'm trying to pass a specific provider to a module, which then passes it as the main provider (aws = aws.some_profile)
to a second, nested module.
on terraform plan
I get the following error:
Error: missing provider module.module_a.provider["registry.terraform.io/hashicorp/aws"].some_profile
I must be doing somethig basic wrong or assuming the language works in a way that it doesn't. Ideas?
File structure:
├── main.tf
├── module_a
│ ├── main.tf
│ └── module_b
│ └── main.tf
└── providers.tf
main.tf (top level):
module "module_a" {
source = "./module_a"
providers = {
aws.some_profile = aws.some_profile
}
}
main.tf (inside module_a):
module "module_b" {
source = "./module_b"
providers = {
aws = aws.some_profile
}
}
main.tf (inside module b):
resource "null_resource" "null" {}
providers.tf:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.22.0"
}
}
}
provider "aws" {
profile = "default"
region = "us-west-2"
}
provider "aws" {
alias = "some_profile"
profile = "some_profile"
region = "us-west-2"
}
terraform providers
is your friend. It will show you providers that you passing to submodules – Bruno Criado