【发布时间】:2022-10-18 04:03:39
【问题描述】:
我第一次使用 tflint 来扫描我的 terraform 代码。为此,我创建了 shell 脚本来执行 tflint 命令,但是,当执行 tflint 作业时,我收到了一些 [WARN] 消息。我不确定它们是如何生成的。有没有办法压制它?
tflint 命令正在成功执行,并且还在我的 terraform 代码中显示可能的问题/通知。
我正在使用以下 Github 工作流操作;
- 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”文件->
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 工作流输出显示 [WARN] 消息-->
【问题讨论】:
-
v0.26.0 有点旧(2021 年 4 月 4 日)。您能否先尝试升级到最新的 v0.34.1 以排除开发人员已经修复的任何旧问题?
-
是的,我确实尝试过使用版本
0.34.1,但没有运气。实际上,我觉得这是由于我的脚本造成的吗? -
你也可以添加你的 Terraform 代码吗?你使用自定义的 GitHub 运行器吗?我在具有相同 tflint 版本、相同脚本和相同 .tflint.hcl 文件的私人仓库上对其进行了测试,没有任何问题。
-
那很奇怪。好吧,不确定是否与进一步引用此Github issue 的 terraform 代码有关。
-
你使用天蓝色插入?如果是,它的哪个版本?由于它不是您在此处发布的 .tflint.hcl 的一部分,因此我最初没有对其进行测试,但是使用此插件时,我会收到相同的错误消息。
标签: terraform github-actions lint