Skip to content

Commit 2856022

Browse files
authored
Merge pull request #13 from rhythmictech/redo
redo module to cater to managing tfstate in remote accounts
2 parents 9e68e2e + 5baab5d commit 2856022

30 files changed

+726
-364
lines changed

.github/workflows/misspell.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: misspell
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- prod
9+
- develop
10+
11+
jobs:
12+
misspell:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: misspell
17+
uses: reviewdog/action-misspell@v1
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
locale: "US"
21+
reporter: github-check
22+
filter_mode: nofilter
23+
level: error

.github/workflows/pre-commit-check.yaml

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

.github/workflows/pre-commit.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: pre-commit-check
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- prod
8+
- develop
9+
10+
jobs:
11+
pre-commit-check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
- name: Install prerequisites
18+
run: ./bin/install-ubuntu.sh
19+
- name: initialize Terraform
20+
run: terraform init --backend=false
21+
- name: pre-commit
22+
uses: pre-commit/action@v2.0.3
23+
env:
24+
AWS_DEFAULT_REGION: us-east-1
25+
# many of these are covered by better reviewdog linters below
26+
SKIP: >-
27+
terraform_tflint_deep,
28+
no-commit-to-branch,
29+
terraform_tflint_nocreds,
30+
terraform_tfsec

.github/workflows/pullRequest.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: pull request
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
# TODO: #22 add job using https://github.com/reviewdog/action-alex
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
- name: Install prerequisites
15+
run: ./bin/install-ubuntu.sh
16+
- name: initialize Terraform
17+
run: terraform init --backend=false
18+
- name: pre-commit
19+
uses: pre-commit/action@v2.0.3
20+
env:
21+
AWS_DEFAULT_REGION: us-east-1
22+
# many of these are covered by better reviewdog linters below
23+
SKIP: >-
24+
terraform_tflint_deep,
25+
no-commit-to-branch,
26+
terraform_tflint_nocreds,
27+
terraform_tfsec
28+
tflint:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Install prerequisites
33+
run: ./bin/install-ubuntu.sh
34+
- name: Terraform init
35+
run: terraform init --backend=false
36+
- name: tflint
37+
uses: reviewdog/action-tflint@master
38+
with:
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
reporter: github-pr-check
41+
filter_mode: added
42+
flags: --module
43+
level: error
44+
tfsec:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: Install prerequisites
49+
run: ./bin/install-ubuntu.sh
50+
- name: Terraform init
51+
run: terraform init --backend=false
52+
- name: tfsec
53+
uses: reviewdog/action-tfsec@master
54+
with:
55+
github_token: ${{ secrets.GITHUB_TOKEN }}
56+
reporter: github-pr-check
57+
filter_mode: added
58+
level: warning
59+
misspell:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: misspell
64+
uses: reviewdog/action-misspell@v1
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
locale: "US"
68+
reporter: github-pr-check
69+
filter_mode: added
70+
level: error
71+
yamllint:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: yamllint
76+
uses: reviewdog/action-yamllint@v1
77+
with:
78+
github_token: ${{ secrets.GITHUB_TOKEN }}
79+
reporter: github-pr-check
80+
filter_mode: added
81+
level: error

.github/workflows/tflint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: tflint
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- prod
9+
- develop
10+
11+
jobs:
12+
tflint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Install prerequisites
17+
run: ./bin/install-ubuntu.sh
18+
- name: Terraform init
19+
run: terraform init --backend=false
20+
- name: tflint
21+
uses: reviewdog/action-tflint@master
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
reporter: github-check
25+
filter_mode: nofilter
26+
flags: --module
27+
level: error

.github/workflows/tfsec.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: tfsec
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- prod
9+
- develop
10+
11+
jobs:
12+
tfsec:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Install prerequisites
17+
run: ./bin/install-ubuntu.sh
18+
- name: Terraform init
19+
run: terraform init --backend=false
20+
- name: tfsec
21+
uses: reviewdog/action-tfsec@master
22+
with:
23+
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
reporter: github-check
25+
filter_mode: nofilter
26+
level: error

.github/workflows/yamllint.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: yamllint
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- prod
9+
- develop
10+
11+
jobs:
12+
yamllint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: yamllint
17+
uses: reviewdog/action-yamllint@v1
18+
with:
19+
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
reporter: github-check
21+
filter_mode: nofilter
22+
level: error

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
8+
assumerole
9+
assumerole/*

.pre-commit-config.yaml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1+
exclude: ".terraform"
12
repos:
23
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.50.0
4+
rev: v1.74.1
45
hooks:
56
- id: terraform_docs
67
always_run: true
7-
args:
8-
- --args=--sort-by-required
98
- id: terraform_fmt
10-
- id: terraform_tflint
11-
alias: terraform_tflint_deep
12-
name: terraform_tflint_deep
13-
args:
14-
- --args=--deep
159
- id: terraform_tflint
1610
alias: terraform_tflint_nocreds
1711
name: terraform_tflint_nocreds
@@ -33,14 +27,36 @@ repos:
3327
cd $(dirname "$FILE")
3428
terraform init --backend=false
3529
terraform validate .
30+
cd ..
31+
done
32+
'
33+
language: system
34+
verbose: true
35+
files: \.tf(vars)?$
36+
exclude: examples
37+
- id: tflock
38+
name: provider_locks
39+
entry: |
40+
bash -c '
41+
AWS_DEFAULT_REGION=us-east-1
42+
declare -a DIRS
43+
for FILE in "$@"
44+
do
45+
DIRS+=($(dirname "$FILE"))
46+
done
47+
for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
48+
do
49+
cd $(dirname "$FILE")
50+
terraform providers lock -platform=linux_amd64
51+
cd ..
3652
done
3753
'
3854
language: system
3955
verbose: true
4056
files: \.tf(vars)?$
4157
exclude: examples
4258
- repo: https://github.com/pre-commit/pre-commit-hooks
43-
rev: v3.4.0
59+
rev: v4.2.0
4460
hooks:
4561
- id: check-case-conflict
4662
- id: check-json
@@ -50,11 +66,17 @@ repos:
5066
args:
5167
- --unsafe
5268
- id: end-of-file-fixer
53-
- id: trailing-whitespace
5469
- id: mixed-line-ending
5570
args:
5671
- --fix=lf
5772
- id: no-commit-to-branch
73+
args:
74+
- --branch
75+
- main
76+
- --branch
77+
- master
78+
- --branch
79+
- prod
5880
- id: pretty-format-json
5981
args:
6082
- --autofix
@@ -63,3 +85,5 @@ repos:
6385
args:
6486
- --markdown-linebreak-ext=md
6587
exclude: README.md
88+
ci:
89+
skip: [terraform_docs, terraform_fmt, terraform_tflint, terraform_tfsec, tflock]

.terraform-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.5
1+
latest:^1.1

0 commit comments

Comments
 (0)