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

required_providers is not available in the project-factory Module? #623

Closed
2 tasks
shrink opened this issue Sep 30, 2021 · 3 comments · Fixed by #624
Closed
2 tasks

required_providers is not available in the project-factory Module? #623

shrink opened this issue Sep 30, 2021 · 3 comments · Fixed by #624
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work

Comments

@shrink
Copy link
Contributor

shrink commented Sep 30, 2021

Module module.project-factory does not declare a provider named google.
│ If you wish to specify a provider configuration for the module, add an entry for google in the required_providers block within the module.

I'd like to specify the provider to be used by the Module, but the root Module does not contain required_providers. I've searched around and noted that the lack of required_providers was surfaced in #462 and fixed in #513 for most modules but did not include the root Module. The removal of credentials_path in v11 means, as far as I know, the only way to control the provider configuration for this module is by changing the default provider configuration.

is there a reason for this -- a design decision? -- with a different (undocumented) approach that I should use, or is it a missing feature? I'm unsure if this is something I should be creating a Pull Request for, or if I'm misunderstanding how to use the Module.

  • I want to specify a set of Google credentials, in configuration, that the Module will use
  • I do not want to change the default Google provider configuration

Thanks,

@morgante
Copy link
Contributor

What version of Terraform are you using?

How are you using the module? It is not meant to be a "root module" that you run terraform apply in. Instead your Terraform configuration should reference the module like the examples do: https://github.com/terraform-google-modules/terraform-google-project-factory/blob/master/examples/simple_project/main.tf

@shrink
Copy link
Contributor Author

shrink commented Sep 30, 2021

Apologies for the unclear explanation! For example, if we take simple_project and do this:

provider "google" {
  alias = "example"
}

module "project-factory" {
  providers = {
    google = google.example
  }

  source                  = "../../"
  random_project_id       = true
  name                    = "simple-sample-project"
  org_id                  = var.organization_id
  billing_account         = var.billing_account
  default_service_account = "deprivilege"

  activate_api_identities = [{
    api = "healthcare.googleapis.com"
    roles = [
      "roles/healthcare.serviceAgent",
      "roles/bigquery.jobUser",
    ]
  }]
}

The result is...

│ Warning: Provider google is undefined
│
│   on test.tf line 7, in module "project-factory":
│    7:     google = google.example
│
│ Module module.project-factory does not declare a provider named google.
│ If you wish to specify a provider configuration for the module, add an entry for google in the required_providers block within the module.
╵

Same result with google-beta too.

dev:~$ terraform -v
Terraform v1.0.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v3.86.0
+ provider registry.terraform.io/hashicorp/google-beta v3.86.0
+ provider registry.terraform.io/hashicorp/null v2.1.2
+ provider registry.terraform.io/hashicorp/random v2.3.1
+ provider registry.terraform.io/integrations/github v4.15.1

edit: "root Module" might be the wrong language, apologies, been a while since I worked with terraform. I mean the module at the root of this repository, so what's declared in main.tf not what's declared in the modules/*.

@morgante
Copy link
Contributor

Got it, thanks for clarifying. We should indeed add this to the main, gsuite, and shared_vpc module.

I'd be happy to review a pull request.

@morgante morgante added bug Something isn't working P2 high priority issues triaged Scoped and ready for work labels Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 high priority issues triaged Scoped and ready for work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants