Skip to content
Latchkey

Terraform "reference to undefined provider" Alias in CI

A resource or module references an aliased provider (e.g. aws.west) that is never defined, or a module declares a configuration_aliases provider the root does not pass in.

What this error means

validate/plan fails with "reference to undefined provider", naming an alias like aws.west. It surfaces after adding a multi-region resource or a module that expects aliased providers it was not given.

terraform output
Error: reference to undefined provider

  on main.tf line 22, in resource "aws_s3_bucket" "replica":
  22:   provider = aws.west

There is no explicit declaration for local provider name "aws.west" in
module.root, so it is not possible to associate this resource with a provider.

Common causes

Aliased provider block never declared

A resource sets provider = aws.west but no provider "aws" { alias = "west" } block exists, so the alias is undefined.

Module configuration_aliases not satisfied

A module declares configuration_aliases = [aws.west] in its required_providers, but the root never passes that provider via the providers = {} argument.

How to fix it

Declare and pass the aliased provider

Define the aliased provider in the root and pass it into modules that require it.

main.tf
provider "aws" {
  alias  = "west"
  region = "us-west-2"
}

module "replica" {
  source    = "./modules/replica"
  providers = { aws.west = aws.west }
}

Match module provider requirements

  1. Read the module’s configuration_aliases to see which aliased providers it expects.
  2. Declare each alias in the root.
  3. Pass them with providers = { aws.west = aws.west } on the module call.

How to prevent it

  • Declare every provider alias a resource or module references.
  • Pass aliased providers explicitly via providers = {}.
  • Run terraform validate to catch undefined aliases before apply.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →