-
Notifications
You must be signed in to change notification settings - Fork 16
/
_gitlab-ci.yml
127 lines (117 loc) · 2.37 KB
/
_gitlab-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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
image:
name: hashicorp/terraform:light
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
variables:
TF_LOG: $TF_LOG
stages:
- format
- validate
- plan
- apply
- destroy
format:
stage: format
script:
- terraform fmt -check -recursive
# validate_staging:
# variables:
# TF_ROOT: $CI_PROJECT_DIR/environments/staging
# stage: validate
# script:
# - cd $TF_ROOT
# - terraform init
# - terraform validate
# dependencies:
# - format
validate_dev:
variables:
TF_ROOT: $CI_PROJECT_DIR/environments/development
stage: validate
script:
- cd $TF_ROOT
- terraform init
- terraform validate
dependencies:
- format
# plan_staging:
# variables:
# TF_ROOT: $CI_PROJECT_DIR/environments/staging
# stage: plan
# script:
# - cd $TF_ROOT
# - terraform init
# - terraform plan -out plan_staging.json
# artifacts:
# name: plan_staging
# paths:
# - $TF_ROOT/plan_staging.json
# dependencies:
# - validate_staging
plan_dev:
variables:
TF_ROOT: $CI_PROJECT_DIR/environments/development
stage: plan
script:
- cd $TF_ROOT
- terraform init
- terraform plan -out plan_dev.json
artifacts:
name: plan_dev
paths:
- $TF_ROOT/plan_dev.json
dependencies:
- validate_dev
# apply_staging:
# variables:
# TF_ROOT: $CI_PROJECT_DIR/environments/staging
# stage: apply
# script:
# - cd $TF_ROOT
# - terraform init
# - terraform apply -auto-approve plan_staging.json
# dependencies:
# - plan_staging
# when: manual
# only:
# - main
apply_dev:
variables:
TF_ROOT: $CI_PROJECT_DIR/environments/development
stage: apply
script:
- cd $TF_ROOT
- terraform init
- terraform apply -auto-approve plan_dev.json
dependencies:
- plan_dev
when: manual
only:
- main
# destroy_staging:
# variables:
# TF_ROOT: $CI_PROJECT_DIR/environments/staging
# stage: apply
# script:
# - cd $TF_ROOT
# - terraform init
# - terraform destroy -auto-approve
# dependencies:
# - plan_staging
# when: manual
# only:
# - main
destroy_dev:
variables:
TF_ROOT: $CI_PROJECT_DIR/environments/development
stage: apply
script:
- cd $TF_ROOT
- terraform init
- terraform destroy -auto-approve
dependencies:
- plan_dev
when: manual
only:
- main