From 99fa327ea77d08c913812b80fa15d488b4d98f11 Mon Sep 17 00:00:00 2001 From: Jan Sebastian Siwy Date: Thu, 9 Jun 2022 11:56:25 +0000 Subject: [PATCH] Run validation with multiple Terraform versions It's always the currently latest patch version for a minor version. --- .github/workflows/validate.yml | 31 +++++++++++++++++++++++++------ .gitignore | 4 ++-- _test/main.tf | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 _test/main.tf diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 615cae1..de17e26 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -2,16 +2,35 @@ name: Validate on: push -env: - AWS_REGION: local - jobs: - validate: + validate_terraform_versions: runs-on: ubuntu-20.04 + + strategy: + matrix: + terraform_version: + - "0.15.5" + - "1.0.11" + - "1.1.9" + - "1.2.2" + + defaults: + run: + working-directory: _test + steps: - uses: actions/checkout@v3 - - uses: hashicorp/setup-terraform@v2.0.0 + - uses: hashicorp/setup-terraform@v2 with: - terraform_version: 0.15.5 + terraform_version: ${{ matrix.terraform_version }} - run: terraform init - run: terraform validate + + validate: # this is a workaround, see https://github.community/t/status-check-for-a-matrix-jobs/127354/6 + if: ${{ always() }} + needs: [validate_terraform_versions] + runs-on: ubuntu-20.04 + steps: + - name: Check build status of all needed jobs + if: ${{ needs.validate_terraform_versions.result != 'success' }} + run: exit 1 diff --git a/.gitignore b/.gitignore index 05a74e5..576c848 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/.terraform -/.terraform.lock.hcl +/_test/.terraform +/_test/.terraform.lock.hcl diff --git a/_test/main.tf b/_test/main.tf new file mode 100644 index 0000000..31415e7 --- /dev/null +++ b/_test/main.tf @@ -0,0 +1,27 @@ +provider "aws" { + region = "local" +} + +module "lambda" { + source = "./.." + + function_name = "example" + description = "This is an example" + + runtime = "nodejs12.x" + handler = "index.handler" + memory_size = 128 + timeout = 3 + reserved_concurrent_executions = 1 + + environment_variables = { + NODE_ENV = "production" + } + + source_dir = "lambda/src" + + tags = { + app = "example" + env = "production" + } +}