From e70cb06e4b70942625c4fb9975dbba817e20a429 Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Tue, 27 Aug 2024 17:11:12 +0100 Subject: [PATCH] Add simple format check for Terragrunt files (#176) --- .github/workflows/terragrunt_test.yml | 21 +++++++++++++++++++ deployment/live/gcp/cloudbuild/terragrunt.hcl | 8 +++---- .../live/gcp/example-gcp/ci/terragrunt.hcl | 2 +- .../live/gcp/example-gcp/terragrunt.hcl | 10 ++++----- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/terragrunt_test.yml diff --git a/.github/workflows/terragrunt_test.yml b/.github/workflows/terragrunt_test.yml new file mode 100644 index 00000000..43389e2a --- /dev/null +++ b/.github/workflows/terragrunt_test.yml @@ -0,0 +1,21 @@ +name: 'Terragrunt format check' +on: + - pull_request + +env: + tf_version: '1.5.7' + tg_version: '0.55.1' + +jobs: + checks: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Check terragrunt HCL + uses: gruntwork-io/terragrunt-action@cf355638dbd066b6a70eb01f31ad9293870a0e34 # v2 + with: + tf_version: ${{ env.tf_version }} + tg_version: ${{ env.tg_version }} + tg_command: 'hclfmt --terragrunt-check --terragrunt-diff' diff --git a/deployment/live/gcp/cloudbuild/terragrunt.hcl b/deployment/live/gcp/cloudbuild/terragrunt.hcl index 8d1075a7..d1bb698b 100644 --- a/deployment/live/gcp/cloudbuild/terragrunt.hcl +++ b/deployment/live/gcp/cloudbuild/terragrunt.hcl @@ -3,9 +3,9 @@ terraform { } locals { - project_id = "trillian-tessera" - region = "us-central1" - env = path_relative_to_include() + project_id = "trillian-tessera" + region = "us-central1" + env = path_relative_to_include() } remote_state { @@ -18,7 +18,7 @@ remote_state { prefix = "${path_relative_to_include()}-terraform.tfstate" gcs_bucket_labels = { - name = "terraform_state_storage" + name = "terraform_state_storage" } } } diff --git a/deployment/live/gcp/example-gcp/ci/terragrunt.hcl b/deployment/live/gcp/example-gcp/ci/terragrunt.hcl index 6cb46865..efe11340 100644 --- a/deployment/live/gcp/example-gcp/ci/terragrunt.hcl +++ b/deployment/live/gcp/example-gcp/ci/terragrunt.hcl @@ -11,6 +11,6 @@ inputs = merge( include.root.locals, { example_gcp_docker_image = "us-central1-docker.pkg.dev/trillian-tessera/docker-prod/example-gcp:latest" - log_origin = "example-gcp" + log_origin = "example-gcp" } ) diff --git a/deployment/live/gcp/example-gcp/terragrunt.hcl b/deployment/live/gcp/example-gcp/terragrunt.hcl index 4643e228..0f8bbc76 100644 --- a/deployment/live/gcp/example-gcp/terragrunt.hcl +++ b/deployment/live/gcp/example-gcp/terragrunt.hcl @@ -3,10 +3,10 @@ terraform { } locals { - env = path_relative_to_include() - project_id = get_env("GOOGLE_PROJECT", "trillian-tessera") - location = get_env("GOOGLE_REGION", "us-central1") - base_name = get_env("TESSERA_BASE_NAME", "${local.env}-example-gcp") + env = path_relative_to_include() + project_id = get_env("GOOGLE_PROJECT", "trillian-tessera") + location = get_env("GOOGLE_REGION", "us-central1") + base_name = get_env("TESSERA_BASE_NAME", "${local.env}-example-gcp") } remote_state { @@ -19,7 +19,7 @@ remote_state { prefix = "${local.env}/terraform.tfstate" gcs_bucket_labels = { - name = "terraform_state_storage" + name = "terraform_state_storage" } } }