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

Fix for Warning: Reference to undefined provider #27

Closed
wants to merge 1 commit into from
Closed

Fix for Warning: Reference to undefined provider #27

wants to merge 1 commit into from

Conversation

dylan-shipwell
Copy link

Description

When specifying a provider configuration to wrappers, terraform emits this warnings.

╷
│ Warning: Reference to undefined provider
│
│   on terraform.tf line 41, in module
"main":
│   41:     aws = aws.primary
│
│ There is no explicit declaration for local provider name "aws" in
module.aws-kms, so
│ Terraform is assuming you mean to pass a configuration for
"hashicorp/aws".
│
│ If you also control the child module, add a required_providers entry
named "aws" with the source address "hashicorp/aws".
│
│ (and one more similar warning elsewhere)
╵

Motivation and Context

This change reduces the reporting of warnings in terraform. Terraform is extremely fragile and warnings are often a symptom of breakage-to-come, so reducing warnings to an absolutely minimum is a useful goal state.

Breaking Changes

No known.

How Has This Been Tested?

  • [n/a ] I have updated at least one of the examples/* to demonstrate and validate my change(s)

    n/a because this is a module-call-site side warning, exhaustively testing all module-call-site's warning would require a stack of infinite size, but we could insist on having a stack of at least two module depth for every module to ensure the "middle depth" example modules produce no warnings.

    • [n/a ] I have tested and validated these changes using one or more of the provided examples/* projects
  • Please describe how you tested your changes

    I have installed this commit to check the terraform warning is no longer emitted

       module "main" {
      -  source = "terraform-aws-modules/kms/aws//wrappers"
      +  #source = "terraform-aws-modules/kms/aws//wrappers"
      +  source = "git::https://github.com/dylan-shipwell/terraform-aws-kms//wrappers?ref=5e322b3c8979c2a3b687dabca3d39f0080edf691"
      +
         providers = {
           aws = aws.primary
         }
    
      (terraform (1.1.5) apply no longer emits this warning)
    

When specifying a provider configuration to wrappers, terraform emits
this warnings.

╷
│ Warning: Reference to undefined provider
│
│   on terraform.tf line 41, in module
"main":
│   41:     aws = aws.primary
│
│ There is no explicit declaration for local provider name "aws" in
module.aws-kms, so
│ Terraform is assuming you mean to pass a configuration for
"hashicorp/aws".
│
│ If you also control the child module, add a required_providers entry
named "aws" with the source address "hashicorp/aws".
│
│ (and one more similar warning elsewhere)
╵
@dylan-shipwell dylan-shipwell changed the title Warning: Reference to undefined provider Fix for Warning: Reference to undefined provider Feb 15, 2024
@antonbabenko
Copy link
Member

If you are using Terraform, you can use the for_each native feature and not wrappers, which are designed to be used with Terragrunt.

Copy link

I'm going to lock this pull request 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 related to this change, 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 Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants