-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
56 lines (50 loc) · 934 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
47
48
49
50
51
52
53
54
55
56
image:
name: hashicorp/terraform:1.9.1
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
variables:
TF_ROOT: $CI_PROJECT_DIR
cache:
key: $TF_ROOT
paths:
- $TF_ROOT/.terraform/
- $TF_ROOT/.terraform.lock.hcl
stages:
- test
- predeploy
- deploy
test:
stage: test
before_script:
- cd $TF_ROOT
- terraform init
script:
- terraform fmt -recursive -check
- terraform validate
plan:
only:
refs:
- master
stage: predeploy
before_script:
- cd $TF_ROOT
script:
- terraform plan -var-file=$TFVARSFILE -out tfplan
artifacts:
name: tfplan
expire_in: 1 week
paths:
- $TF_ROOT/tfplan
apply:
when: manual
only:
refs:
- master
stage: deploy
environment:
name: production
before_script:
- cd $TF_ROOT
script:
- terraform apply -auto-approve -var-file=$TFVARSFILE