From aea05be83f7a90e6ddb22173140c3de599b1396e Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 1 Mar 2021 20:30:07 -0500 Subject: [PATCH 1/3] fix: revert module Terraform 0.13.x version upgrade --- .github/workflows/pre-commit.yml | 72 ++++++++++++++----- .pre-commit-config.yaml | 2 +- README.md | 2 +- examples/github-complete/README.md | 2 +- examples/github-complete/versions.tf | 2 +- examples/github-repository-webhook/README.md | 2 +- .../github-repository-webhook/versions.tf | 2 +- examples/gitlab-repository-webhook/README.md | 2 +- .../gitlab-repository-webhook/versions.tf | 2 +- modules/github-repository-webhook/README.md | 2 +- modules/github-repository-webhook/versions.tf | 2 +- versions.tf | 2 +- 12 files changed, 67 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 73c2bee2..efa5a771 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,14 +7,65 @@ on: - master jobs: - getBaseVersion: - name: Get min/max versions - runs-on: ubuntu-latest +# Min Terraform version(s) + getDirectories: + name: Get root directories + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Python + uses: actions/setup-python@v2 + - name: Build matrix + id: matrix + run: | + DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))") + echo "::set-output name=directories::$DIRS" + outputs: + directories: ${{ steps.matrix.outputs.directories }} + preCommitMinVersions: + name: Min TF validate + needs: getDirectories + runs-on: ubuntu-latest + strategy: + matrix: + directory: ${{ fromJson(needs.getDirectories.outputs.directories) }} steps: - name: Checkout uses: actions/checkout@v2 + - name: Install Python + uses: actions/setup-python@v2 + - name: Terraform min/max versions + id: minMax + uses: clowdhaus/terraform-min-max@v1.0.1 + with: + directory: ${{ matrix.directory }} + - name: Install Terraform v${{ steps.minMax.outputs.minVersion }} + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: ${{ steps.minMax.outputs.minVersion }} + - name: Install pre-commit dependencies + run: pip install pre-commit + - name: Execute pre-commit + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory != '.' }} + run: + pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/* + - name: Execute pre-commit + # Run only validate pre-commit check on min version supported + if: ${{ matrix.directory == '.' }} + run: + pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf) + +# Max Terraform version + getBaseVersion: + name: Module max TF version + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 - name: Terraform min/max versions id: minMax uses: clowdhaus/terraform-min-max@v1.0.1 @@ -22,40 +73,29 @@ jobs: minVersion: ${{ steps.minMax.outputs.minVersion }} maxVersion: ${{ steps.minMax.outputs.maxVersion }} - preCommit: - name: Pre-commit check + preCommitMaxVersion: + name: Max TF pre-commit runs-on: ubuntu-latest needs: getBaseVersion strategy: fail-fast: false matrix: version: - - ${{ needs.getBaseVersion.outputs.minVersion }} - ${{ needs.getBaseVersion.outputs.maxVersion }} - steps: - name: Checkout uses: actions/checkout@v2 - - name: Install Python uses: actions/setup-python@v2 - - name: Install Terraform v${{ matrix.version }} uses: hashicorp/setup-terraform@v1 with: terraform_version: ${{ matrix.version }} - - name: Install pre-commit dependencies run: | pip install pre-commit curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/ curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/ - - - name: Execute pre-commit - # Run only validate pre-commit check on min version supported - if: ${{ matrix.version == needs.getBaseVersion.outputs.minVersion }} - run: pre-commit run --color=always --show-diff-on-failure --all-files terraform_validate - - name: Execute pre-commit # Run all pre-commit checks on max version supported if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4963e575..188d38ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.46.0 + rev: v1.47.0 hooks: - id: terraform_fmt - id: terraform_validate diff --git a/README.md b/README.md index dbd52257..ad1c849e 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ allow_github_webhooks = true | Name | Version | |------|---------| -| terraform | >= 0.13 | +| terraform | >= 0.12.26 | | aws | >= 2.68 | | random | >= 2.0 | diff --git a/examples/github-complete/README.md b/examples/github-complete/README.md index 6890b739..eb5c993d 100644 --- a/examples/github-complete/README.md +++ b/examples/github-complete/README.md @@ -29,7 +29,7 @@ Go to https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/settin | Name | Version | |------|---------| -| terraform | >= 0.13 | +| terraform | >= 0.12.26 | | aws | >= 2.68 | | github | >= 2.4.1 | diff --git a/examples/github-complete/versions.tf b/examples/github-complete/versions.tf index 35c927cf..f663cb12 100644 --- a/examples/github-complete/versions.tf +++ b/examples/github-complete/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 0.12.26" required_providers { aws = { diff --git a/examples/github-repository-webhook/README.md b/examples/github-repository-webhook/README.md index 60f9450e..f205dede 100644 --- a/examples/github-repository-webhook/README.md +++ b/examples/github-repository-webhook/README.md @@ -21,7 +21,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| terraform | >= 0.13 | +| terraform | >= 0.12.26 | | aws | >= 2.68 | | github | >= 2.4.1 | diff --git a/examples/github-repository-webhook/versions.tf b/examples/github-repository-webhook/versions.tf index 35c927cf..f663cb12 100644 --- a/examples/github-repository-webhook/versions.tf +++ b/examples/github-repository-webhook/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 0.12.26" required_providers { aws = { diff --git a/examples/gitlab-repository-webhook/README.md b/examples/gitlab-repository-webhook/README.md index f203c397..6e0d6faa 100644 --- a/examples/gitlab-repository-webhook/README.md +++ b/examples/gitlab-repository-webhook/README.md @@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| terraform | >= 0.13 | +| terraform | >= 0.12.26 | | aws | >= 2.68 | | gitlab | >= 3.0 | diff --git a/examples/gitlab-repository-webhook/versions.tf b/examples/gitlab-repository-webhook/versions.tf index 4d87f2e7..3184f46e 100644 --- a/examples/gitlab-repository-webhook/versions.tf +++ b/examples/gitlab-repository-webhook/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 0.12.26" required_providers { aws = { diff --git a/modules/github-repository-webhook/README.md b/modules/github-repository-webhook/README.md index 098827dc..5408e25c 100644 --- a/modules/github-repository-webhook/README.md +++ b/modules/github-repository-webhook/README.md @@ -5,7 +5,7 @@ | Name | Version | |------|---------| -| terraform | >= 0.13 | +| terraform | >= 0.12.26 | | github | >= 2.4.1 | ## Providers diff --git a/modules/github-repository-webhook/versions.tf b/modules/github-repository-webhook/versions.tf index 897fabf3..5954d3b4 100644 --- a/modules/github-repository-webhook/versions.tf +++ b/modules/github-repository-webhook/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 0.12.26" required_providers { github = { diff --git a/versions.tf b/versions.tf index d44f5c5a..9d556021 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.13" + required_version = ">= 0.12.26" required_providers { aws = { From 037352ca6c27c0f36bfdd7b9523f3ecb47ac186f Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 1 Mar 2021 20:33:46 -0500 Subject: [PATCH 2/3] chore: gitlab requires 0.13.x --- examples/gitlab-repository-webhook/README.md | 2 +- examples/gitlab-repository-webhook/versions.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gitlab-repository-webhook/README.md b/examples/gitlab-repository-webhook/README.md index 6e0d6faa..f203c397 100644 --- a/examples/gitlab-repository-webhook/README.md +++ b/examples/gitlab-repository-webhook/README.md @@ -19,7 +19,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| terraform | >= 0.12.26 | +| terraform | >= 0.13 | | aws | >= 2.68 | | gitlab | >= 3.0 | diff --git a/examples/gitlab-repository-webhook/versions.tf b/examples/gitlab-repository-webhook/versions.tf index 3184f46e..4d87f2e7 100644 --- a/examples/gitlab-repository-webhook/versions.tf +++ b/examples/gitlab-repository-webhook/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.26" + required_version = ">= 0.13" required_providers { aws = { From 40152969e88e36bbabd1a383a23354bd1f838ae5 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 1 Mar 2021 20:36:43 -0500 Subject: [PATCH 3/3] chore: update README --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index ad1c849e..6a76dbe8 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,6 @@ Depending on which SCM system you use, Github repositories or Gitlab projects ha See `README.md` in `examples` for Github or Gitlab for complete details. -## Terraform versions - -Terraform 0.12 or newer. Pin module version to `~> v2.0`. Submit pull-requests to `master` branch. - -Terraform 0.11. Pin module version to `~> v1.0`. - ### Before using Atlantis and the code in this repository please make sure that you have read and understood the security implications described in [the official Atlantis documentation](https://www.runatlantis.io/docs/security.html). ## How to use this?