-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 2.79 KB
/
tf-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
on: push
name: Terraform CI
env:
AWS_REGION: us-east-1
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ env.TERRAFORM_VERSION }}
- name: Run Terraform fmt
shell: bash --noprofile --norc -exo pipefail {0}
run: terraform fmt -check
tflint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Import CI .env file
uses: cardinalby/export-env-action@v1
with:
envFile: ".github/ci-versions.env"
expand: "true"
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ env.TERRAFORM_VERSION }}
- name: Setup tflint
run: |
wget https://github.com/terraform-linters/tflint/releases/download/${{ env.TFLINT_VERSION }}/tflint_linux_amd64.zip
unzip tflint_linux_amd64.zip
chmod +x tflint
sudo mv tflint /usr/local/bin/tflint
- name: Run tflint
run: tflint --recursive
tfsec:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Import CI .env file
uses: cardinalby/export-env-action@v1
with:
envFile: ".github/ci-versions.env"
expand: "true"
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ env.TERRAFORM_VERSION }}
- name: Run Trivy vulnerability scanner in IaC mode
uses: aquasecurity/trivy-action@master
with:
scan-type: "config"
hide-progress: false
format: "sarif"
output: "trivy-results.sarif"
exit-code: "1"
ignore-unfixed: true
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Import CI .env file
uses: cardinalby/export-env-action@v1
with:
envFile: ".github/ci-versions.env"
expand: "true"
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ env.TERRAFORM_VERSION }}
- name: Validate Terraform code
shell: bash --noprofile --norc -exo pipefail {0}
run: terraform init && terraform validate