Skip to content
Latchkey

Terraform "Invalid provider configuration" in CI

A provider block is missing a required argument, or a resource references a provider configuration (often an alias) that is not defined or passed into the module.

What this error means

plan/apply fails with "Invalid provider configuration" - a required argument like region is unset, or a resource references a provider = aws.west alias that the module never received.

terraform output
Error: Invalid provider configuration

Provider "registry.terraform.io/hashicorp/aws" requires explicit configuration.
Add a provider block to the root module and configure the provider's required
arguments as described in the provider documentation.

Common causes

Missing required provider argument

A provider needs a required argument (for example AWS region, or an explicit endpoint) that is unset, so it cannot be configured.

Undefined or unpassed provider alias

A resource references provider = aws.west but no aliased provider block defines it, or a module expects a provider that the root never passed via providers = {}.

How to fix it

Configure required provider arguments

Set the required arguments on the provider block (use a variable so CI can supply it).

providers.tf
provider "aws" {
  region = var.aws_region
}

Define and pass aliased providers to modules

Declare the aliased provider and pass it explicitly into modules that need it.

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

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

How to prevent it

  • Set required provider arguments from variables so CI can supply them.
  • Declare every provider alias a resource or module references.
  • Pass aliased providers explicitly to modules with providers = {}.

Related guides

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