Skip to content

Call EnsureNoError after evaluating aws_route expression so unevaluable expressions are skipped #320

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

Merged

Conversation

jandersen-plaid
Copy link
Contributor

runner.EvaluateExpr can return errors that are skippable (for example, ErrUnevaluable which occurs when an expression cannot be evaluated) and entirely normal.

For example, the snippet

data "aws_transit_gateway" "tgw" {
  tags = {
    Name = "Transit Gateway"
  }
}

resource "aws_route" "tgw_route" {
  route_table_id     = "rtb-1234abcd"
  transit_gateway_id = data.aws_transit_gateway_id.tgw.id
}

Will produce the error:

Failed to check ruleset; Failed to check `aws_route_not_specified_target` rule: unevaluable expression found in example.tf:9

when the terraform is perfectly valid (and obeys the rule).

This PR just wraps the IsNull increment in a runner.EnsureNoError call so that skippable errors are skippable.

@jandersen-plaid
Copy link
Contributor Author

Let me know if there is a preferred procedure for submitting these pulls as well (that is: creating an issue first is required, and then a PR, or something else)! I just noticed this while working through some upgrades and thought I would fix it.

@wata727 wata727 merged commit 82fc2e0 into terraform-linters:master Mar 28, 2022
@wata727
Copy link
Member

wata727 commented Mar 28, 2022

Thanks!

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.

2 participants