-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
85 lines (66 loc) · 2.09 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
image: <docker_image_has_all_required_package>
stages:
- plan
- apply
- destroy
.common: &common
before_script:
- export AWS_ACCOUNT_ID=`jq -r .${ENVIRONMENT}.account_id info.json`
- terraform --version
- terraform init --backend-config "bucket=tf-state-${AWS_ACCOUNT_ID}" --backend-config "key=${STATE_FILE}" --backend-config "region=${AWS_REGION}"
- terraform get
- terraform plan --var-file ${ENVIRONMENT}.tfvars
when: manual
tags:
- <runner_tag>
.plan_common: &plan_common
<<: *common
stage: plan
script:
- echo "plan"
.apply_common: &apply_common
<<: *common
script:
- terraform apply --var-file ${ENVIRONMENT}.tfvars
stage: apply
.destroy_common: &destroy_common
<<: *common
script:
- terraform destroy --force --var-file ${ENVIRONMENT}.tfvars
stage: destroy
dev_team7-plan:
<<: *plan_common
variables:
TF_VAR_aws_access_key: $DEV_ACCESS_KEY
TF_VAR_aws_secret_key: $DEV_SECRET_KEY
TF_VAR_emq_admin_password: $emq_admin_password
TF_VAR_emqtt_password: $emqtt_password
TF_VAR_emqtt_cookies: $emqtt_cookies
AWS_ACCESS_KEY_ID: $DEV_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $DEV_SECRET_KEY
AWS_REGION: eu-central-1
ENVIRONMENT: dev_team7
dev_team7-apply:
<<: *apply_common
variables:
TF_VAR_aws_access_key: $DEV_ACCESS_KEY
TF_VAR_aws_secret_key: $DEV_SECRET_KEY
TF_VAR_emq_admin_password: $emq_admin_password
TF_VAR_emqtt_password: $emqtt_password
TF_VAR_emqtt_cookies: $emqtt_cookies
AWS_ACCESS_KEY_ID: $DEV_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $DEV_SECRET_KEY
AWS_REGION: eu-central-1
ENVIRONMENT: dev_team7
dev_team7-destroy:
<<: *destroy_common
variables:
TF_VAR_aws_access_key: $DEV_ACCESS_KEY
TF_VAR_aws_secret_key: $DEV_SECRET_KEY
TF_VAR_emq_admin_password: $emq_admin_password
TF_VAR_emqtt_password: $emqtt_password
TF_VAR_emqtt_cookies: $emqtt_cookies
AWS_ACCESS_KEY_ID: $DEV_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $DEV_SECRET_KEY
AWS_REGION: eu-central-1
ENVIRONMENT: dev_team7