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

terraform_rules: Add workaround for skipping child modules inspection #884

Merged

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Aug 22, 2020

Fixes #878

This PR adds a workaround to fix false positives in terraform rules.

Module inspection emits an issue in a module argument if an expression contains the module argument. However, this works as expected for rules such as aws_instance_invalid_type, but not for rules such as terraform_deprecated_interpolation, which has no cause in module arguments.

In order to avoid such false positives, first, in the rules of terraform, analysis other than the root module is explicitly skipped. This is not a good idea, but the goal is first to avoid false positives.

Copy link
Member

@bendrucker bendrucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change "This rule does not work for child modules" to "This rule does not evaluate child modules." Since they themselves do work, they're just electing not to enforce themselves on certain modules.

This definitely works in the near term to take care of the regression. terraform_workspace_remote raises an interesting counter-case. Including terraform.workspace in a child module has the same unexpected consequences in Terraform Cloud as using it in the root module would. Ideally that rule should be able to emit errors from child modules and those errors should not be associated with a module variable.

#769 might have the same need. Addressing it is probably a pretty far-ranging change—this is good for now.

@wata727 wata727 force-pushed the add_workaround_for_skipping_child_modules_inspection branch from 8384022 to d5e3010 Compare August 23, 2020 06:30
@wata727 wata727 merged commit 7e4c50c into master Aug 23, 2020
@wata727 wata727 deleted the add_workaround_for_skipping_child_modules_inspection branch August 23, 2020 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

terraform_deprecated_interpolation reports wrong range for child module
2 participants