Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue running terraform validate against a module using required_providers.[provider].configuration_aliases #28567

Closed
rockholla opened this issue Apr 30, 2021 · 2 comments
Labels
bug new new issue not yet triaged

Comments

@rockholla
Copy link

Terraform Version

0.15.1

Terraform Configuration Files

terraform {
  required_version = "~> 0.15.1"
  required_providers {
    google = {
      source                = "hashicorp/google"
      version               = "~> 3.52"
      configuration_aliases = [google.group_management]
    }
    random = {
      source  = "hashicorp/random"
      version = "~> 3.1"
    }
  }
}

# provider "google" {
#   alias = "group_management"
# }
...
resource "random_id" "project_id_suffix" {
  byte_length = 6
}

resource "google_folder" "zone" {
  display_name = var.name
  parent       = var.parent
}
...
resource "google_cloud_identity_group" "zone" {
  provider     = google.group_management
  display_name = local.cloud_identity_group_name
  parent       = "customers/${var.google_customer_id}"
  group_key {
    id = "${local.cloud_identity_group_name}@${var.identity_domain}"
  }
  labels = {
    "cloudidentity.googleapis.com/groups.discussion_forum" = ""
  }
}
...

This is a new module in development. Just showing some of the resources for context, but most important would be the root terraform block, required_providers and resource google_cloud_identity_group using the aliased provider.

Debug Output

https://gist.github.com/rockholla/c45b4eceebe894f91b66f34f6b30b2b1

Crash Output

N/A

Expected Behavior

Expecting to be able to run terraform validate without explicit provider block defined for the alias. And even if I need that workaround not receiving warnings about a bare provider block defined when using the module.

Actual Behavior

Full terraform validate output available via the gist. Seems as though validate is getting confused about state management or something for these aliased provider resources in the module.

If I provide an explicit, bare provider block (commented out in config shared) for the alias in the module itself, validate succeeds . When I uncomment that provider block so it prevents the validate error, using the module elsewhere gives this:

│ Warning: Empty provider configuration blocks are not required
│
│   on .terraform/modules/delivery/google/paas-zone/versions.tf line 19:
│   19: provider "google" {
│
│ Remove the google.group_management provider block from module.delivery.
│
│ (and 2 more similar warnings elsewhere)

Steps to Reproduce

I think building a simple module like below using the same pattern with aliasing and using the expected aliased provider in at least one resource should produce, e.g.

terraform {
  required_version = "~> 0.15.1"
  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = "~> 3.0"
      configuration_aliases = [aws.alt]
    }
  }
}
resource "aws_vpc" "example_01" {
  cidr_block = "10.0.0.0/16"
}
resource "aws_vpc" "example_02" {
  provider   = aws.alt
  cidr_block = "10.0.0.0/16"
}

Then in the module:

$ terraform init
$ terraform validate

Additional Context

N/A

References

@jbardin
Copy link
Member

jbardin commented Apr 30, 2021

Duplicate of #28490

@jbardin jbardin marked this as a duplicate of #28490 Apr 30, 2021
@jbardin jbardin closed this as completed Apr 30, 2021
@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants