Default provider for module

Is there a way to say use the default provider for a module that defines an aliased provider.

For example I have a module that can create Route53 entires, in our setup DNS lives in a separate account so I have to over-ride the provider for that specific resource

resource "route53_record" "this" {
  provider = aws.route53

And therefor within the module I define

provider “aws” {
alias = “route53”

When calling this module the user has to call it as such:

module “route53” {
providers = {
aws.route53 = aws.some-alias

However there are certain use cases where the aws.route53 provider should just be set to the default aws provider (or based on the inputs to the module the DNS entries won’t be created and therefore the secondary provider won’t actually be used). In those situations it would be beneficial for the user to not have to supply the provider when calling the module and just have the module default to the default provider.

Hi @cyrus-mc!

I’m not sure I fully followed what situation you are describing here, but the providers argument does allow both passing default providers into aliased proxy provider slots and passing aliased providers into default provider slots in the child module.

To pass the default provider from the caller module into an aliased provider configuration in the child module:

  providers = {
    aws.route53 = aws

To pass an aliased provider from the root module as the default provider configuration for the child module:

  providers = {
    aws = aws.some-alias

The second of these is particularly useful if you are using a third-party module that doesn’t define any alias configurations but your root module defines multiple configurations for the same provider. You can potentially instantiate different modules with different provider configurations without modifying the modules themselves at all, or instantiate the same module multiple times with different provider configurations e.g. to represent deploying the same regional infrastructure across multiple regions.


Thanks for the response. I am aware that you can set the aliases provider to the default. My question was more can you set that default in the module itself so that only in cases where the user needs to over-ride it with a different provider configuration they can.

Hi @cyrus-mc,

For shared modules that don’t need multiple configurations for the same provider, the usual approach is to not write any provider blocks at all for the provider, and expect the configuration to be provided by the caller.

If no providers argument is present in a module block then the default provider configurations for each provider will inherit automatically without any explicit configuration. If the root module’s default provider configuration isn’t the one you want the child module to inherit then you’d override that default behavior with an explicit providers map like my second example above.