I'm trying to use a (private) remote terraform module, and trying to pass a different provider to it. For the remote module, there are no providers defined and to my understanding, it will use a the local provider instead.
I can't seem to be able to get it to use a provider alias - there are a few files at play here:
# main.tf
provider "aws" {
region = var.aws_region
}
provider "aws" {
alias = "replica_region"
region = var.replica_region
}
terraform {
backend "s3" {
}
}
# s3.tf
module "some-remote-module" {
source = 'git::ssh.......'
providers = {
aws = aws.replica_region
}
}
Whenever I plan (with terragrunt), The region is that of the primary aws provider config. I get the following warning, too:
│ Warning: Reference to undefined provider
│
│ on s3.tf line 12, in module "some-remote-module":
│ 12: aws = aws.replica_region
│
│ There is no explicit declaration for local provider name "aws" in
│ module.some-remote-module, so Terraform is assuming you
│ mean to pass a configuration for "hashicorp/aws".
│
│ If you also control the child module, add a required_providers entry named
│ "aws" with the source address "hashicorp/aws".
╵
Am I passing the providers in incorrectly? Is this even something that terraform is capable of? I'm using terraform 1.3. The remote module doesn't have any provider config.