-
-
Notifications
You must be signed in to change notification settings - Fork 541
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: Fix the terraform_wrapper_module_for_each hook for modules without outputs or variables #552
Conversation
…do not have outputs or variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good. Thank you for opening this PR!
## [1.81.1](v1.81.0...v1.81.1) (2023-08-10) ### Bug Fixes * Fix the terraform_wrapper_module_for_each hook for modules without outputs or variables ([#552](#552)) ([f24b3fa](f24b3fa))
This PR is included in version 1.81.1 🎉 |
@@ -323,11 +323,11 @@ EOF | |||
|
|||
# Get names of module variables in all terraform files | |||
# shellcheck disable=SC2207 | |||
module_vars=($(echo "$all_tf_content" | hcledit block list | grep variable. | cut -d'.' -f 2)) | |||
module_vars=($(echo "$all_tf_content" | hcledit block list | { grep variable. || true; } | cut -d'.' -f 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put cut
to where it belongs in logically?
module_vars=($(echo "$all_tf_content" | hcledit block list | { grep variable. || true; } | cut -d'.' -f 2)) | |
module_vars=($(echo "$all_tf_content" | hcledit block list | { grep variable. | cut -d'.' -f 2 || true; })) |
|
||
# Get names of module outputs in all terraform files | ||
# shellcheck disable=SC2207 | ||
module_outputs=($(echo "$all_tf_content" | hcledit block list | grep output. | cut -d'.' -f 2)) | ||
module_outputs=($(echo "$all_tf_content" | hcledit block list | { grep output. || true; } | cut -d'.' -f 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put cut
to where it belongs in logically?
module_outputs=($(echo "$all_tf_content" | hcledit block list | { grep output. || true; } | cut -d'.' -f 2)) | |
module_outputs=($(echo "$all_tf_content" | hcledit block list | { grep output. | cut -d'.' -f 2 || true; })) |
@ajax-ryzhyi-r just discovered the error using this PR:
Could you please work on the fix? |
I'm not sure if this error is related to the changes made in this pull request. I've tried to reproduce it but with no success. 😞 The error you discovered appears to have originated from one of the |
@ajax-ryzhyi-r Try checkout this module locally - https://github.com/terraform-aws-modules/terraform-aws-appsync/ - and add I think the fix you have proposed is relevant and needed. |
@antonbabenko The issue also occurs with version |
This issue has been resolved in version 1.81.2 🎉 |
…do not have outputs or variables
Put an
x
into the box if that apply:Description of your changes
The
terraform_wrapper_module_for_each
hook always exits with1
code for modules that do not have outputs or variables defined. This is becausegrep
returns an exit code of1
when it does not find a match, andpipefail
is set for the hook script.This pull request resolves the issue by setting a
0
exit code for variables and outputsgrep
executions.How can we test changes
Run the
terraform_wrapper_module_for_each hook
against the module without outputs or variables. 🙃