-
Notifications
You must be signed in to change notification settings - Fork 110
95 lines (89 loc) · 2.74 KB
/
terraform-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
name: "Terraform-ci"
on: [push, pull_request]
defaults:
run:
shell: sh
jobs:
# Terraform validate configuration
terraform-validate:
name: "Terraform-validate"
runs-on: ubuntu-latest
container:
image: maddevsio/terraform-utils:latest
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Init l1
working-directory: ./terraform/layer1-aws
run: terraform init -backend=false
- name: Terraform Init l2
working-directory: ./terraform/layer2-k8s
run: terraform init -backend=false
- name: Terraform Validate l1
working-directory: ./terraform/layer1-aws
run: terraform validate -no-color .
- name: Terraform Validate l2
working-directory: ./terraform/layer2-k8s
run: terraform validate -no-color .
- name: Upload files for l1
uses: actions/upload-artifact@v2
with:
name: l1
path: ./terraform/layer1-aws/.terraform
retention-days: 1
# Checks that all Terraform configuration files format
terraform-format:
name: "Terraform-format"
runs-on: ubuntu-latest
container:
image: maddevsio/terraform-utils:latest
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Format
run: terraform fmt -recursive -write=false -check .
working-directory: ./terraform
# Checks that all Terraform configuration files tflint
terraform-tflint:
name: "Terraform-tflint"
runs-on: ubuntu-latest
container:
image: maddevsio/terraform-utils:latest
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform tflint l1
working-directory: ./terraform/layer1-aws
run: tflint --no-color
- name: Terraform tflint l2
working-directory: ./terraform/layer2-k8s
run: tflint --no-color
terraform-tfsec-l1:
name: "Terraform-tfsec-l1"
needs: terraform-validate
runs-on: ubuntu-latest
container:
image: aquasec/tfsec
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download init for l1
uses: actions/download-artifact@v4
with:
name: l1
path: ./terraform/layer1-aws/.terraform
- name: tfsec l1
working-directory: ./terraform
run: tfsec layer1-aws
- uses: geekyeggo/delete-artifact@v5
with:
name: l1
failOnError: false
if: ${{ always() }}