-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathterraform.yml
65 lines (61 loc) · 1.04 KB
/
terraform.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
.terraform:
image:
name: hashicorp/terraform:0.12.24
entrypoint: [""]
cache:
key: ${CI_PIPELINE_ID}
paths:
- "${TF_FOLDER_PATH}/.terraform"
validate:
extends: .terraform
stage: test
script:
- &check |
if [ -n "${TF_FOLDER_PATH}" ]; then
cd "${TF_FOLDER_PATH}"
fi
terraform --version
- terraform init -backend=false
- terraform validate
only:
- /^v.+$/i
- master
- merge_requests
variables:
GIT_DEPTH: 1
plan:
extends: .terraform
stage: build
script:
- *check
- &init |
terraform init
- terraform plan -out=plan.tfplan
artifacts:
name: plan
paths:
- "${TF_FOLDER_PATH}/plan.tfplan"
only:
- /^v.+$/i
except:
- branches
variables:
GIT_DEPTH: 1
apply:
extends: .terraform
stage: deploy
script:
- *check
- *init
- terraform apply -input=false plan.tfplan
dependencies:
- plan
when: manual
only:
- /^v.+$/i
except:
- branches
environment:
name: production
variables:
GIT_DEPTH: 1