Skip to content

Commit 6e232e8

Browse files
cdaniluksblack4
andauthored
Cross account support (#2)
* Update linting/checks * not needed * added crossaccount support * fix badge Co-authored-by: Steven B <[email protected]> Co-authored-by: Steven B <[email protected]>
1 parent ebab384 commit 6e232e8

22 files changed

+591
-44
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @rhythmictech/engineering

.github/workflows/check.yml

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

.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.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: pre-commit-check
3+
on:
4+
push:
5+
branches: -- main
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/[email protected]
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
31+
- uses: stefanzweifel/git-auto-commit-action@v4
32+
if: ${{ failure() }}
33+
with:
34+
commit_message: Apply automatic changes
35+
commit_options: "--no-verify"
36+
# Optional commit user and author settings
37+
commit_user_name: Linter Bot
38+
commit_user_email: [email protected]
39+
commit_author: Linter Bot <[email protected]>

.github/workflows/pullRequest.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
name: pull request
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Python
12+
uses: actions/setup-python@v2
13+
- name: Install prerequisites
14+
run: ./bin/install-ubuntu.sh
15+
- name: initialize Terraform
16+
run: terraform init --backend=false
17+
- name: pre-commit
18+
uses: pre-commit/[email protected]
19+
env:
20+
AWS_DEFAULT_REGION: us-east-1
21+
# many of these are covered by better reviewdog linters below
22+
SKIP: >-
23+
terraform_tflint_deep,
24+
no-commit-to-branch,
25+
terraform_tflint_nocreds,
26+
terraform_tfsec
27+
- uses: stefanzweifel/git-auto-commit-action@v4
28+
if: ${{ failure() }}
29+
with:
30+
commit_message: Apply automatic changes
31+
commit_options: "--no-verify"
32+
# Optional commit user and author settings
33+
commit_user_name: Linter Bot
34+
commit_user_email: [email protected]
35+
commit_author: Linter Bot <[email protected]>
36+
tflint:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
- name: setup Terraform
41+
uses: hashicorp/setup-terraform@v1
42+
with:
43+
terraform_version: 0.12.26
44+
- name: Terraform init
45+
run: terraform init --backend=false
46+
- name: tflint
47+
uses: reviewdog/action-tflint@master
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
reporter: github-pr-check
51+
filter_mode: added
52+
flags: --module
53+
level: error
54+
tfsec:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: setup Terraform
59+
uses: hashicorp/setup-terraform@v1
60+
with:
61+
terraform_version: 0.12.26
62+
- name: Terraform init
63+
run: terraform init --backend=false
64+
- name: tfsec
65+
uses: reviewdog/action-tfsec@master
66+
with:
67+
github_token: ${{ secrets.GITHUB_TOKEN }}
68+
reporter: github-pr-check
69+
filter_mode: added
70+
level: warning
71+
misspell:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: misspell
76+
uses: reviewdog/action-misspell@v1
77+
with:
78+
github_token: ${{ secrets.GITHUB_TOKEN }}
79+
locale: "US"
80+
reporter: github-pr-check
81+
filter_mode: added
82+
level: error
83+
yamllint:
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v2
87+
- name: yamllint
88+
uses: reviewdog/action-yamllint@v1
89+
with:
90+
github_token: ${{ secrets.GITHUB_TOKEN }}
91+
reporter: github-pr-check
92+
filter_mode: added
93+
level: error

.github/workflows/tflint.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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: setup Terraform
17+
uses: hashicorp/setup-terraform@v1
18+
with:
19+
terraform_version: 0.12.26
20+
- name: Terraform init
21+
run: terraform init --backend=false
22+
- name: tflint
23+
uses: reviewdog/action-tflint@master
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
reporter: github-check
27+
filter_mode: nofilter
28+
flags: --module
29+
level: error

.github/workflows/tfsec.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: setup Terraform
17+
uses: hashicorp/setup-terraform@v1
18+
with:
19+
terraform_version: 0.12.26
20+
- name: Terraform init
21+
run: terraform init --backend=false
22+
- name: tfsec
23+
uses: reviewdog/action-tfsec@master
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
reporter: github-check
27+
filter_mode: nofilter
28+
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# .tfvars files
9+
*.tfvars

.pre-commit-config.yaml

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,71 @@
1-
---
21
repos:
3-
- repo: git://github.com/antonbabenko/pre-commit-terraform
4-
rev: v1.24.0
5-
hooks:
6-
- id: terraform_fmt
7-
- id: terraform_docs
8-
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v2.4.0
10-
hooks:
11-
- id: end-of-file-fixer
12-
- id: trailing-whitespace
13-
- id: no-commit-to-branch
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.31.0
4+
hooks:
5+
- id: terraform_docs
6+
always_run: true
7+
args:
8+
- --args=--sort-by-required
9+
- id: terraform_fmt
10+
- id: terraform_tflint
11+
alias: terraform_tflint_deep
12+
name: terraform_tflint_deep
13+
args:
14+
- --args=--deep
15+
- id: terraform_tflint
16+
alias: terraform_tflint_nocreds
17+
name: terraform_tflint_nocreds
18+
- id: terraform_tfsec
19+
- repo: local
20+
hooks:
21+
- id: terraform_validate
22+
name: terraform_validate
23+
entry: |
24+
bash -c '
25+
AWS_DEFAULT_REGION=us-east-1
26+
declare -a DIRS
27+
for FILE in "$@"
28+
do
29+
DIRS+=($(dirname "$FILE"))
30+
done
31+
for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
32+
do
33+
cd $(dirname "$FILE")
34+
terraform init --backend=false
35+
terraform validate .
36+
done
37+
'
38+
language: system
39+
verbose: true
40+
files: \.tf(vars)?$
41+
exclude: examples
42+
- repo: https://github.com/pre-commit/pre-commit-hooks
43+
rev: v3.0.0
44+
hooks:
45+
- id: check-case-conflict
46+
- id: check-json
47+
- id: check-merge-conflict
48+
- id: check-symlinks
49+
- id: check-yaml
50+
args:
51+
- --unsafe
52+
- id: end-of-file-fixer
53+
- id: mixed-line-ending
54+
args:
55+
- --fix=lf
56+
- id: no-commit-to-branch
57+
args:
58+
- --branch
59+
- main
60+
- --branch
61+
- master
62+
- --branch
63+
- prod
64+
- id: pretty-format-json
65+
args:
66+
- --autofix
67+
- --top-keys=name,Name
68+
- id: trailing-whitespace
69+
args:
70+
- --markdown-linebreak-ext=md
71+
exclude: README.md

0 commit comments

Comments
 (0)