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

tflint: Skip evaluation of module arguments if the module call is not evaluated #1415

Merged

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Jun 19, 2022

Fixes #1395

In Terraform, if count = 0 or for_each = [], the module is not evaluated and the module arguments are also not evaluated. So, the following configuration is valid:

variable "foo" {
  type = object({ attr = string })
  default = null
}

module "bar" {
  source = "./baz"
  count = 0

  argument = var.foo.attr
}

However, TFLint ignores the module's meta-arguments, so in this case var.foo.attr was evaluated and an error occurred.

Failed to prepare rule checking; failed to eval an expression in module.tf:10; Attempt to get attribute from null value: This value is null, so it does not have any attributes.

This PR makes the evaluation of modules aware of the meta-arguments. In the above example, var.foo.attr is not evaluated.

@wata727 wata727 changed the title Skip evaluation of module arguments if the module call is not evaluated tflint: Skip evaluation of module arguments if the module call is not evaluated Jun 19, 2022
@wata727 wata727 merged commit f9008f4 into master Jun 20, 2022
@wata727 wata727 deleted the eval_module_call_arguments_when_only_the_module_is_created branch June 20, 2022 13:56
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.

"This value is null, so it does not have any attributes." error from upstream module
1 participant