-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
63 lines (57 loc) · 1.7 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
stages:
- test build
- validate
- deploy
cache:
paths:
- .terraform
test:
image: alpine:latest
stage: test build
script:
- "apk update"
- "apk add yarn zip"
- "yarn"
- "yarn test"
build:
image: alpine:latest
stage: test build
script:
- "apk update"
- "apk add yarn zip"
- "yarn --prod"
- "zip -r key_rotator.zip ./*"
artifacts:
paths:
- key_rotator.zip
validate:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
stage: validate
script:
- "export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
- "export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY"
- "export AWS_DEFAULT_REGION=us-east-1"
- "terraform init -reconfigure -input=false"
- "terraform workspace select dev || terraform workspace new dev"
- "terraform validate -input=false -var gitlab_group_id=$GROUP_ID -var api_key=$API_KEY -var aws_user=$AWS_USER"
deploy:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
stage: deploy
only:
- master
script:
- "export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
- "export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY"
- "export AWS_DEFAULT_REGION=us-east-1"
- "terraform init -reconfigure -input=false"
- "terraform workspace select dev || terraform workspace new dev"
- "terraform validate -input=false -var gitlab_group_id=$GROUP_ID -var api_key=$API_KEY -var aws_user=$AWS_USER"
- "terraform apply -input=false -auto-approve -var gitlab_group_id=$GROUP_ID -var api_key=$API_KEY -var aws_user=$AWS_USER"