-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
46 lines (40 loc) · 852 Bytes
/
.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
---
variables:
TF_ROOT: ${CI_PROJECT_DIR}
cache:
key: tf
paths:
- ${TF_ROOT}/.terraform/
before_script:
- terraform --version
- echo $BASE64_GCP_CREDS | base64 -d > ${TF_ROOT}/sa.json
- export GOOGLE_APPLICATION_CREDENTIALS="${TF_ROOT}/sa.json"
- cd ${TF_ROOT}
default:
image:
name: hashicorp/terraform:1.0.8
entrypoint: ["/bin/sh", "-c"]
stages:
- init
- plan
- apply
terraform init:
stage: init
script:
- ls -lah ${TF_ROOT}
- terraform init
terraform plan:
stage: plan
script:
- ls -lah ${TF_ROOT}
- terraform init -input=false -reconfigure
- terraform plan -out="plan.cache"
artifacts:
paths:
- ${TF_ROOT}/plan.cache
terraform apply:
stage: apply
script:
- terraform init -input=false -reconfigure
- terraform apply -input=false "plan.cache"
when: manual