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

feat: Skip legacy modules (with provider block) in terraform_wrapper_module_for_each hook #560

Merged
merged 1 commit into from Aug 25, 2023

Conversation

ajax-ryzhyi-r
Copy link
Contributor

Put an x into the box if that apply:

  • This PR introduces breaking change.
  • This PR fixes a bug.
  • This PR adds new functionality.
  • This PR enhances existing functionality.

Description of your changes

Modules that have provider blocks do not support for_each, count, or depends_on meta arguments. Therefore, there is no need to generate wrappers for these modules because they cannot be called.

This PR adds a skip for modules that contain a provider block.

How can we test changes

Run the terraform_wrapper_module_for_each against the module with the provider block - wrapper should not be created.

@antonbabenko
Copy link
Owner

Thank you for your contribution. Could you please provide a small code snippet of the module with a provider block which should not be generated by the hook? And/or link to the related issue in Terraform?

@ajax-ryzhyi-r
Copy link
Contributor Author

Thank you for your contribution. Could you please provide a small code snippet of the module with a provider block which should not be generated by the hook? And/or link to the related issue in Terraform?

This is not actually an issue; it is expected behavior. Modules with local provider definitions are considered legacy modules by HashiCorp and do not support the for_each meta argument. However, in rare cases, there may be a need to add some provider configurations in the module. In such cases, successfully generated wrappers could be confusing because they cannot be used.

Terraform docs: https://developer.hashicorp.com/terraform/language/modules/develop/providers#legacy-shared-modules-with-provider-configurations

@antonbabenko antonbabenko changed the title fix: Skip legacy modules in terraform_wrapper_module_for_each hook feat: Skip legacy modules (with provider block) in terraform_wrapper_module_for_each hook Aug 25, 2023
@antonbabenko antonbabenko merged commit 456cc76 into antonbabenko:master Aug 25, 2023
6 checks passed
@antonbabenko
Copy link
Owner

Thank you for the explanation! Merging...

antonbabenko pushed a commit that referenced this pull request Aug 25, 2023
# [1.83.0](v1.82.0...v1.83.0) (2023-08-25)

### Features

* Skip legacy modules (with provider block) in terraform_wrapper_module_for_each hook ([#560](#560)) ([456cc76](456cc76))
@antonbabenko
Copy link
Owner

This PR is included in version 1.83.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants