'How to suppress/ignore tflint warnings

I am using tflint for the first time to scan my terraform code. For that I have created shell script to execute tflint command however, I am getting some [WARN] messages when tflint job is executed. I am not sure how they are generated. Is there a way to suppress it?

tflint command is getting executed successfully and also showing possible issues/notice in my terraform code.

I am using below Github workflow action;

      - name: Setup TFLint
        uses: terraform-linters/setup-tflint@v1
        with:
          tflint_version: v0.26.0

      - name: Lint Terraform Code
        run: scripts/tflint.sh
        shell: bash
        continue-on-error: false

".tflint.hcl" file ->

plugin "aws" {
  enabled = true
  version = "0.12.0"
  source  = "github.com/terraform-linters/tflint-ruleset-aws"
}

rule "terraform_naming_convention" {
  enabled = true
}

rule "terraform_unused_declarations" {
  enabled = true
}

rule "terraform_deprecated_index" {
  enabled = true
}

rule "terraform_documented_outputs" {
  enabled = true
}

rule "terraform_documented_variables" {
  enabled = true
}

rule "terraform_typed_variables" {
  enabled = true
}

tflint.sh ->

#!/usr/bin/env bash
echo "Scanning all files(*.tf) with tflint"
find * -name '*.tf' | grep -E -v ".terraform|.terragrunt-cache" | while read -r line; do
    tflint "$line" -f compact
done

Github workflow output showing [WARN] messages-->

enter image description here



Solution 1:[1]

By the way, I have managed to suppress the warning messages by making use of null device /dev/null and redirected STDERR logs generated by script to 2> /dev/null.

Final Code:

- name: Lint Terraform Code
  run: scripts/tflint.sh 2> /dev/null
  shell: bash
  continue-on-error: false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sagar Jadhav