Ask questions"Error: Provider configuration not present" when aliased provider is used

Terraform Version

Terraform v0.12.0

With terraform version 0.11.10, the files below work as expected.

Terraform Configuration Files

initially the providers section in the config below was absent, but it was added to try and troubleshoot the issue. The same results happen if it is absent or present.

provider "aws" {
  region = "us-west-2"
  alias  = "env"

provider "aws" {
  region = "us-west-2"

provider "google" {
  credentials = "${file("gcp.json")}"
  region      = "us-central1"
  project     = "orv5-236500"

module "network" {
  source = "../../../../terraform-modules/gcp/network"

  cluster = "testpad8"
  region  = "us-central1"
  domain  = ""

  providers = {
    aws.env = "aws.env"
    google  = "google"
    aws     = "aws"

The network module is the first part we're porting and testing with TF12. The locals/inputs are in different files in the module.

# DNS Setup

# Parent Zone in Route53 to create subdomains in
data "aws_route53_zone" "main" {
  provider = "aws.env"
  name     = "${var.domain}"

# DNS Zone in GCP for the cluster
resource "google_dns_managed_zone" "cluster" {
  name        = "${local.cluster_domain}"
  dns_name    = "${local.cluster_domain}"
  description = "Domain for CLUSTER: ${var.cluster}"
  visibility  = "public"

  labels = "${merge(var.extra_labels,
    map("Name", "${local.cluster_domain}"),
  map("launchpad_cluster", "${var.cluster}"))}"

# DNS delegation records in the main environment domain
resource "aws_route53_record" "environment-ns" {
  provider = "aws.env"
  zone_id  = "${data.aws_route53_zone.main.zone_id}"
  name     = "${local.cluster_domain}"
  type     = "NS"
  ttl      = "30"

  records = [

# Create a zone for mongo product to publish records to
resource "google_dns_managed_zone" "mongo" {
  name        = "m.${local.cluster_domain}"
  dns_name    = "m.${local.cluster_domain}"
  description = "Domain for mongo records in CLUSTER: ${var.cluster}"
  visibility  = "public"

  labels = "${merge(var.extra_labels,
    map("Name", "${local.cluster_domain}"),
  map("launchpad_cluster", "${var.cluster}"))}"

# Create a delegation for the m.$var.cluster.$environment domain
resource "google_dns_record_set" "environment-mongo-ns" {
  managed_zone = "${}"
  name         = "m.${google_dns_managed_zone.cluster.dns_name}"
  type         = "NS"
  ttl          = "30"

  rrdatas = [

# Create the wildcard in the mongo domain
resource "google_dns_record_set" "mongo-wildcard" {
  managed_zone = "${}"
  name         = "*"
  type         = "CNAME"
  ttl          = "30"

  rrdatas = ["${format("ingress.%s", local.cluster_domain)}"]

Debug Output

Crash Output

N/A error message is:

Error: Provider configuration not present

To work with its original
provider configuration at is required, but it
has been removed. This occurs when a provider configuration is removed while
objects created by that provider still exist in the state. Re-add the provider
configuration to destroy,
after which you can remove the provider configuration again.

Expected Behavior

Plan should have executed, adding a zone in GCP, and NS records in AWS with delegations to the subdomain created in GCP.

Actual Behavior

Error message indicates a state that does not exist, no prior state existed.

Steps to Reproduce

This happens when running

terraform init 
terraform plan

Additional Context

We do run terraform via a wrapper, however in this case the wrapper is not used, and it's just a test to call the module to ensure the module works as expected. The test is run manually.


I found similar issues but it looked like in each of those cases the provider configuration was being done inside of the module. In our case the provider configuration is done in the main terraform and passed into the module.


Answer questions dimisjim


variable "region" {
  default = "eu-west-1"

provider "aws" {
  region  = var.region
  version = "~> 2.19.0"

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

inside a module that needs to use a provider in a different region:

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

In 0.11, there was no need for specifying the alias provider twice. Apparently, the above was the only way I could get it to work in 0.12.


Related questions

failed to save provider manifest: open .terraform/plugins/linux_amd64/lock.json: permission denied hot 4
The argument "host" is required, but no definition was found. hot 3
Unable to run 0.12upgrade hot 3
for_each attribute for creating multiple resources based on a map hot 3
Module cannot find alias AWS provider in 0.12.0 hot 3
Error: Invalid template interpolation value hot 2
Terraform v0.11.1 : Error downloading modules: Error loading modules: open .terraform/modules/3f10921295c292995128e9e36eb: no such file or directory hot 2
MalformedPolicyDocument: Policy document should not specify a principal. hot 2
remote-exec provisioner fails with 'bash: Permission denied' hot 2
Detect incorrect directive syntax {% and provide appropriate error message hot 2
Error in Terraform 0.12.0: This object has no argument, nested block, or exported attribute hot 2
Feature Request - Allow list/array in 'query' in 'external' data source hot 2
Terraform provider downloads fail with TLS handshake timeout hot 2
'terraform init' failed with 'Registry service unreachable.' error hot 2
"Warning: Value for undeclared variable" hot 2
Github User Rank List