From 20d3fa5ada53cb2f63496984d70c24ac559104d0 Mon Sep 17 00:00:00 2001 From: Roman Schwarz Date: Fri, 20 Sep 2024 10:29:30 +0200 Subject: [PATCH] Add dedicated TFLint config file for test modules Signed-off-by: Roman Schwarz --- .pre-commit-config.yaml | 11 ++++++++++- .tflint.examples.hcl | 8 ++++++++ .tflint.tests.hcl | 27 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .tflint.tests.hcl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d7deda..cfd83f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: hooks: - id: terraform_fmt - id: terraform_tflint - exclude: ^examples/ + exclude: ^(examples|tests)/ args: - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl - --hook-config=--delegate-chdir @@ -26,6 +26,15 @@ repos: args: - --args=--config=__GIT_WORKING_DIR__/.tflint.examples.hcl - --hook-config=--delegate-chdir + + - id: terraform_tflint + alias: terraform_tflint_tests + name: Terraform validate tests with tflint + files: ^tests/ + args: + - --args=--config=__GIT_WORKING_DIR__/.tflint.tests.hcl + - --hook-config=--delegate-chdir + - id: terraform_trivy exclude: ^(examples|tests)/ args: diff --git a/.tflint.examples.hcl b/.tflint.examples.hcl index 96e60b8..8f1009b 100644 --- a/.tflint.examples.hcl +++ b/.tflint.examples.hcl @@ -18,6 +18,14 @@ plugin "azurerm" { version = "0.27.0" } +rule "terraform_documented_variables" { + enabled = false +} + +rule "terraform_documented_outputs" { + enabled = false +} + rule "terraform_module_version" { enabled = false } diff --git a/.tflint.tests.hcl b/.tflint.tests.hcl new file mode 100644 index 0000000..0f73fca --- /dev/null +++ b/.tflint.tests.hcl @@ -0,0 +1,27 @@ +tflint { + required_version = "~> 0.50" +} + +plugin "terraform" { + enabled = true + + source = "github.com/terraform-linters/tflint-ruleset-terraform" + version = "0.9.1" + + preset = "all" +} + +plugin "azurerm" { + enabled = true + + source = "github.com/terraform-linters/tflint-ruleset-azurerm" + version = "0.27.0" +} + +rule "terraform_unused_required_providers" { + enabled = false +} + +rule "terraform_standard_module_structure" { + enabled = false +}