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_empty_list_equality rule does not cover non-trivial expressions #1424

Closed
sergei-ivanov opened this issue Jun 24, 2022 · 2 comments
Closed

Comments

@sergei-ivanov
Copy link

Introduction

Thanks for adding this rule, but unfortunately it only picks up the most trivial cases.

For example, it picks up this:

resource "aws_security_group_rule" "outbound_proxy" {
  count =var.proxy_subnets != [] ? 1 : 0

but not this:

resource "aws_security_group_rule" "outbound_proxy" {
  count = var.enabled && var.proxy_subnets != [] ? 1 : 0

nor this:

templatefile("${path.module}/jenkins.yaml.tmpl", {
    JENKINS_INGRESS_ENABLED = var.jenkins_controller_alb_allow_list != []
})

I guess it needs to implement more complex recursion for parsing into expressions.

It may also need to check for comparison with empty maps, e.g. var.peering_connections != {}.

Expected Behavior

All cases of comparison to empty list (or map) are highlighted by the rule.

@bendrucker
Copy link
Member

The first example would be worth attempting. Short term, the primary goal should be to support expressions commonly passed to attributes like count.

Recursive evaluation of complex attribute values is a deeper issue than this rule, e.g. see #1257. Providing a helper function that visits each value expression within collection types is its own exercise with potential for use in many rules.

@wata727
Copy link
Member

wata727 commented Aug 12, 2022

Fixed by #1426

@wata727 wata727 closed this as completed Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants