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: Rules across multiple resources are not supported #107

Open
nmoutschen opened this issue Nov 1, 2021 · 0 comments
Open

tflint: Rules across multiple resources are not supported #107

nmoutschen opened this issue Nov 1, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@nmoutschen
Copy link
Contributor

Some rules, such as aws_cloudwatch_log_group_lambda_retention need to evaluate the relationship between different resources defined in Terraform. Usually, this is done by passing references to other resources. For example, for the aforementioned rule:

resource "aws_cloudwatch_log_group" "this" {
  name              = "/aws/lambda/${aws_lambda_function.this.function_name}
  retention_in_days = 7
}

The name property above is not known ahead of time, which isn't supported by TFLint. See this issue for TFLint.

Expected Behavior

Linting terraform files should be able to run with rules that cross-reference resources.

Current Behavior

tflint fails with an Unevaluable expression found error.

Possible Solution

  1. Disable all rules that cross-reference resources.
  2. Build that feature for tflint.
  3. Find another linter for Terraform.
  4. Abandon linting for Terraform and implement an alternative solution, such as evaluating resources running on AWS.

I will first disable all rules that cross-reference resources for now, while exploring other solutions.

Steps to Reproduce (for bugs)

  1. Clone the repository and checkout the test/tflint branch
git clone https://github.com/awslabs/serverless-rules.git
cd serverless-rules
git checkout test/tflint
  1. Run tests for tflint
cd tflint-ruleset-aws-serverless
make test
  1. Get an error that the expression is unevaluable.
Error: Failed to check `aws_cloudwatch_log_group_lambda_retention` rule: Unevaluable expression found in XXX/serverless-rules/tflint-ruleset-aws-serverless/tests/aws_cloudwatch_log_group_lambda_retention.pass.tf:10

Environment

  • Infrastructure as code technology used:
  • (for cfn-lint) Python, cfn-lint, and cfn-lint-serverless versions:
  • (for tflint) Go, tflint versions:
  • Debugging logs
@nmoutschen nmoutschen added the bug Something isn't working label Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant