IBM Support

Terraform AWS Provider Errors: "Invalid provider configuration" when using an aliased provider

Troubleshooting


Problem

When using an aliased AWS provider in a Terraform configuration, you may encounter an Error: Invalid provider configuration, even when a provider block for the alias is correctly defined.

Terraform returns the following error message:

│ 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.
│
╵

This error can occur despite having a valid aliased provider configuration, such as:

provider "aws" {
  alias  = "secondary"
  region = "us-east-2"
}

Cause

This error occurs when one or more resources in your configuration do not include the provider argument and are therefore attempting to use a default (non-aliased) aws provider. If you have not defined a default provider "aws" block, Terraform cannot find a valid configuration for these resources and returns the error.

Terraform requires a default provider configuration for any resource that does not explicitly specify an aliased provider instance.

Solution

To resolve this issue, you must define a default provider block in your root module alongside any aliased provider configurations. This ensures that resources without an explicit provider argument have a valid configuration to use.

Example

Consider the following problematic configuration, which defines an aliased provider but omits the default provider.

## This configuration will fail because the default provider is missing.

/*
provider "aws" {
  region = "us-east-1"
}
*/

provider "aws" {
  alias  = "secondary"
  region = "us-east-2"
}

resource "aws_vpc" "main" {
  ## This resource implicitly requires the default "aws" provider.
  cidr_block = "10.0.0.0/16"
}

resource "aws_vpc" "main2" {
  provider   = aws.secondary
  cidr_block = "10.0.0.0/16"
}

The aws_vpc.main resource does not specify a provider, so it falls back to the default aws provider. Since the default provider block is commented out, Terraform produces the Invalid provider configuration error.

To correct this, uncomment or add the default provider "aws" block.

## This configuration will succeed.

provider "aws" {
  region = "us-east-1"
}

provider "aws" {
  alias  = "secondary"
  region = "us-east-2"
}

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_vpc" "main2" {
  provider   = aws.secondary
  cidr_block = "10.0.0.0/16"
}

With both the default and aliased providers defined, Terraform can successfully configure both resources.

Additional Information

  • For more details on provider configuration, please refer to the official Terraform documentation on Provider Configuration.
  • To learn more about using multiple instances of the same provider, see the documentation for Aliased Providers.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB77","label":"Automation Platform"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGH5YK","label":"IBM Terraform Self-Managed"},"ARM Category":[{"code":"","label":""}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Historical Number

43194127870099

Document Information

Modified date:
16 March 2026

UID

ibm17265644