-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathconfig.yml
107 lines (97 loc) · 2.62 KB
/
config.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
105
106
107
version: 2.1
orbs:
tfsec: mycodeself/[email protected]
jobs:
plan:
docker:
- image: hashicorp/terraform:1.1.5
steps:
- checkout
- run:
name: Set up Terraform
# https://discuss.circleci.com/t/create-separate-steps-jobs-for-pr-forks-versus-branches/13419/2
command: |
cd terraform
if [[ $(echo "$CIRCLE_BRANCH" | grep -c "pull") -gt 0 ]]; then
echo "This is from a fork."
terraform init -backend=false -input=false
else
terraform init -backend-config=backend.tfvars -input=false
fi
- run:
name: Validate Terraform config
command: |
cd terraform
if [[ $(echo "$CIRCLE_BRANCH" | grep -c "pull") -gt 0 ]]; then
echo "This is from a fork."
terraform validate
else
terraform plan -input=false
fi
- persist_to_workspace:
root: .
paths:
- ./terraform/*
tfsec:
executor: tfsec/default
steps:
- checkout
- tfsec/scan:
directory: .
#exclude-checks: ''
checkov:
docker:
- image: circleci/python:latest
steps:
- checkout
- run:
name: Install checkov
command: pip install checkov
- run:
name: Run checkov
command: checkov -d ./terraform/ --skip-check CKV2_AWS_61,CKV_AWS_273,CKV_AWS_289,CKV_AWS_40,CKV_AWS_355,CKV_AWS_290,CKV2_AWS_6,CKV_AWS_33,CKV2_AWS_23,CKV2_AWS_39,CKV2_AWS_38,CKV2_AWS_62,CKV_AWS_18,CKV_AWS_144,CKV_AWS_145,
# TODO resolve /docs/checkov.md errors to remove skipped checks or skip checks inline where appropriate
apply:
docker:
- image: hashicorp/terraform:1.1.5
steps:
- attach_workspace:
at: .
- run:
name: Deploy the full environment
command: cd terraform && terraform apply -input=false -auto-approve
validate:
docker:
- image: python:3.9-alpine
steps:
- checkout
- run:
name: Install dependencies
command: pip install -r requirements.txt
- run:
name: Run validations
command: pytest tests
workflows:
version: 2
validate_and_deploy:
jobs:
- plan
- tfsec
- checkov
- apply:
filters:
branches:
only: main
requires:
- plan
- validate:
filters:
branches:
only: main
requires:
- apply
experimental:
notify:
branches:
only:
- main