Skip to content

Commit 2a6f07a

Browse files
authored
fix: Updated code and version requirements to work with Terraform 0.15 (#1165)
1 parent a26c9fd commit 2a6f07a

File tree

33 files changed

+530
-443
lines changed

33 files changed

+530
-443
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Pre-Commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
# Min Terraform version(s)
11+
getDirectories:
12+
name: Get root directories
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Install Python
18+
uses: actions/setup-python@v2
19+
- name: Build matrix
20+
id: matrix
21+
run: |
22+
DIRS=$(python -c "import json; import glob; print(json.dumps([x.replace('/versions.tf', '') for x in glob.glob('./**/versions.tf', recursive=True)]))")
23+
echo "::set-output name=directories::$DIRS"
24+
outputs:
25+
directories: ${{ steps.matrix.outputs.directories }}
26+
27+
preCommitMinVersions:
28+
name: Min TF validate
29+
needs: getDirectories
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
directory: ${{ fromJson(needs.getDirectories.outputs.directories) }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
- name: Install Python
38+
uses: actions/setup-python@v2
39+
- name: Terraform min/max versions
40+
id: minMax
41+
uses: clowdhaus/[email protected]
42+
with:
43+
directory: ${{ matrix.directory }}
44+
- name: Install Terraform v${{ steps.minMax.outputs.minVersion }}
45+
uses: hashicorp/setup-terraform@v1
46+
with:
47+
terraform_version: ${{ steps.minMax.outputs.minVersion }}
48+
- name: Install pre-commit dependencies
49+
run: pip install pre-commit
50+
- name: Execute pre-commit
51+
# Run only validate pre-commit check on min version supported
52+
if: ${{ matrix.directory != '.' }}
53+
run:
54+
pre-commit run terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*
55+
- name: Execute pre-commit
56+
# Run only validate pre-commit check on min version supported
57+
if: ${{ matrix.directory == '.' }}
58+
run:
59+
pre-commit run terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)
60+
61+
62+
# Max Terraform version
63+
getBaseVersion:
64+
name: Module max TF version
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
- name: Terraform min/max versions
70+
id: minMax
71+
uses: clowdhaus/[email protected]
72+
outputs:
73+
minVersion: ${{ steps.minMax.outputs.minVersion }}
74+
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
75+
76+
preCommitMaxVersion:
77+
name: Max TF pre-commit
78+
runs-on: ubuntu-latest
79+
needs: getBaseVersion
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
version:
84+
- ${{ needs.getBaseVersion.outputs.maxVersion }}
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v2
88+
- name: Install Python
89+
uses: actions/setup-python@v2
90+
- name: Install Terraform v${{ matrix.version }}
91+
uses: hashicorp/setup-terraform@v1
92+
with:
93+
terraform_version: ${{ matrix.version }}
94+
- name: Install pre-commit dependencies
95+
run: |
96+
pip install pre-commit
97+
curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-v0.12\..+?-linux-amd64" | head -n1)" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
98+
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/
99+
- name: Execute pre-commit
100+
# Run all pre-commit checks on max version supported
101+
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}
102+
run: pre-commit run --color=always --show-diff-on-failure --all-files

.gitignore

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
1-
*.tfvars
2-
*.tfstate*
3-
.terraform/
4-
**/inspec.lock
5-
*.gem
6-
Gemfile.lock
7-
terraform.tfstate.d/
81
eks-admin-cluster-role-binding.yaml
92
eks-admin-service-account.yaml
10-
.idea/
11-
*.iml
123
config-map-aws-auth*.yaml
134
kubeconfig_*
14-
*.swp
5+
6+
#################################################################
7+
# Default .gitignore content for all terraform-aws-modules below
8+
#################################################################
9+
10+
.DS_Store
11+
12+
# Local .terraform directories
13+
**/.terraform/*
14+
15+
# Terraform lockfile
16+
.terraform.lock.hcl
17+
18+
# .tfstate files
19+
*.tfstate
20+
*.tfstate.*
21+
*.tfplan
22+
23+
# Crash log files
24+
crash.log
25+
26+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
27+
# password, private keys, and other secrets. These should not be part of version
28+
# control as they are data points which are potentially sensitive and subject
29+
# to change depending on the environment.
30+
*.tfvars
31+
32+
# Ignore override files as they are usually used to override resources locally and so
33+
# are not checked in
34+
override.tf
35+
override.tf.json
36+
*_override.tf
37+
*_override.tf.json
38+
39+
# Ignore CLI configuration files
40+
.terraformrc
41+
terraform.rc

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.43.0
3+
rev: v1.48.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs

0 commit comments

Comments
 (0)