From d214e26de6555aee55e2527ec7b45949bf3d3669 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:04:00 +0700 Subject: [PATCH 01/10] Create tflint.yml --- .github/workflows/tflint.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/tflint.yml diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml new file mode 100644 index 0000000..56611d9 --- /dev/null +++ b/.github/workflows/tflint.yml @@ -0,0 +1,36 @@ +name: Lint +on: + push: + branches: [ tflint-poc ] + pull_request: + +jobs: + tflint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + name: Checkout source code + + - uses: actions/cache@v3 + name: Cache plugin dir + with: + path: ~/.tflint.d/plugins + key: ubuntu-latest-tflint-${{ hashFiles('.tflint.hcl') }} + + - uses: terraform-linters/setup-tflint@v3 + name: Setup TFLint + with: + tflint_version: v0.44.1 + + - name: Show version + run: tflint --version + + - name: Init TFLint + run: tflint --init + env: + # https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting + GITHUB_TOKEN: ${{ github.token }} + + - name: Run TFLint + run: tflint -f compact + From 21a612d7eef640c74ef1c1a414028f9f315b87d9 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:05:57 +0700 Subject: [PATCH 02/10] test failure case in api-gateway.tf --- tutorial/serverless-basic-application/api-gateway.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial/serverless-basic-application/api-gateway.tf b/tutorial/serverless-basic-application/api-gateway.tf index e0e3514..247b1c9 100644 --- a/tutorial/serverless-basic-application/api-gateway.tf +++ b/tutorial/serverless-basic-application/api-gateway.tf @@ -6,14 +6,14 @@ resource "aws_api_gateway_rest_api" "lambda" { } # Resource -resource "aws_api_gateway_resource" "resource" { +resource1 "aws_api_gateway_resource" "resource" { path_part = "resource" parent_id = aws_api_gateway_rest_api.lambda.root_resource_id rest_api_id = aws_api_gateway_rest_api.lambda.id } # Method -resource "aws_api_gateway_method" "method" { +resource "aws_api_gateway_method1" "method" { rest_api_id = aws_api_gateway_rest_api.lambda.id resource_id = aws_api_gateway_resource.resource.id http_method = "POST" From 0e3f005d1fc3a751e4788d9dd6a547b85a1efded Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:11:56 +0700 Subject: [PATCH 03/10] Update tflint.yml --- .github/workflows/tflint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml index 56611d9..24e3d6f 100644 --- a/.github/workflows/tflint.yml +++ b/.github/workflows/tflint.yml @@ -32,5 +32,5 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Run TFLint - run: tflint -f compact + run: tflint --recursive From a3675107a1b123f19da5f799096d6991b8cf9181 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:13:13 +0700 Subject: [PATCH 04/10] Update tflint.yml to use compact --- .github/workflows/tflint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml index 24e3d6f..f641599 100644 --- a/.github/workflows/tflint.yml +++ b/.github/workflows/tflint.yml @@ -32,5 +32,5 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Run TFLint - run: tflint --recursive + run: tflint --recursive -f compact From 0d2ac3ffad6ce33048388aac2efb9f0f4038432a Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:21:54 +0700 Subject: [PATCH 05/10] Create .tflint.hcl --- .tflint.hcl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .tflint.hcl diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..94bdd12 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,26 @@ +config { + format = "compact" + plugin_dir = "~/.tflint.d/plugins" + + module = true + force = false + disabled_by_default = false + + ignore_module = { + "terraform-aws-modules/vpc/aws" = true + "terraform-aws-modules/security-group/aws" = true + } + + varfile = ["example1.tfvars", "example2.tfvars"] + variables = ["foo=bar", "bar=[\"baz\"]"] +} + +plugin "aws" { + enabled = true + version = "0.4.0" + source = "github.com/terraform-linters/tflint-ruleset-aws" +} + +rule "aws_instance_invalid_type" { + enabled = false +} From 28f5dbdcd17f2afb79443afa7f66985fad23ddbf Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:24:35 +0700 Subject: [PATCH 06/10] Update tflint.yml --- .github/workflows/tflint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml index f641599..5c3e5ce 100644 --- a/.github/workflows/tflint.yml +++ b/.github/workflows/tflint.yml @@ -32,5 +32,5 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Run TFLint - run: tflint --recursive -f compact + run: tflint --recursive -f compact --config "$(pwd)/.tflint.hcl" From be8e1d94884354881089ba2623de756566c48d4b Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:26:19 +0700 Subject: [PATCH 07/10] Update .tflint.hcl --- .tflint.hcl | 3 --- 1 file changed, 3 deletions(-) diff --git a/.tflint.hcl b/.tflint.hcl index 94bdd12..3168a82 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -10,9 +10,6 @@ config { "terraform-aws-modules/vpc/aws" = true "terraform-aws-modules/security-group/aws" = true } - - varfile = ["example1.tfvars", "example2.tfvars"] - variables = ["foo=bar", "bar=[\"baz\"]"] } plugin "aws" { From 90108ed9de8b9276508245b0cf0d40fc593ff4d9 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:27:40 +0700 Subject: [PATCH 08/10] Update tflint.yml --- .github/workflows/tflint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml index 5c3e5ce..9a53731 100644 --- a/.github/workflows/tflint.yml +++ b/.github/workflows/tflint.yml @@ -20,7 +20,7 @@ jobs: - uses: terraform-linters/setup-tflint@v3 name: Setup TFLint with: - tflint_version: v0.44.1 + tflint_version: v0.47.0 - name: Show version run: tflint --version From 67fe5b4391d5bf62afb75f6158db4584a09b5c73 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:29:41 +0700 Subject: [PATCH 09/10] Update .tflint.hcl --- .tflint.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tflint.hcl b/.tflint.hcl index 3168a82..b3a9ea4 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -14,7 +14,7 @@ config { plugin "aws" { enabled = true - version = "0.4.0" + version = "v0.24.1" source = "github.com/terraform-linters/tflint-ruleset-aws" } From 04b23b073ce0c1724f3f4bd414f5af26fa7f93c8 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:30:35 +0700 Subject: [PATCH 10/10] Update .tflint.hcl --- .tflint.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tflint.hcl b/.tflint.hcl index b3a9ea4..c3c9c14 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -14,7 +14,7 @@ config { plugin "aws" { enabled = true - version = "v0.24.1" + version = "0.24.1" source = "github.com/terraform-linters/tflint-ruleset-aws" }