-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
66 lines (62 loc) · 1.74 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
stages:
- terraform-validate
- terraform-build
- packer
before_script:
- mkdir ~/.aws/
- echo -e "[default]" > ~/.aws/credentials
- echo -e "aws_access_key_id=$AWS_ACCESS_KEY">> ~/.aws/credentials
- echo -e "aws_secret_access_key=$AWS_SECRET_KEY">> ~/.aws/credentials
- echo -e "[default]" > ~/.aws/config
- echo -e "region = us-east-1" >> ~/.aws/config
- echo -e "output = json" >> ~/.aws/config
- echo -e "[profile home]" >> ~/.aws/config
- echo -e "role_arn=arn:aws:iam::$ACCOUNT_ID:role/$AWS_ROLE" >> ~/.aws/config
- echo -e "source_profile = default" >> ~/.aws/config
- echo -e "region = us-east-1" >> ~/.aws/config
- echo -e "output = json" >> ~/.aws/config
- export TF_IN_AUTOMATION=true
- export TF_VAR_role_arn="arn:aws:iam::${ACCOUNT_ID}:role/$AWS_ROLE"
validate_json:
stage: terraform-build
tags: [gitlab-org]
image: registry.gitlab.com/cardenas88karl/automate-ami-demo:latest
except:
refs:
- master
script:
- chmod 755 ./aws-cli.sh
- terraform init && terraform apply -auto-approve
- packer validate ami.json
artifacts:
paths:
- ami.json
allow_failure: false
build_json:
stage: terraform-build
tags: [gitlab-org]
image: registry.gitlab.com/cardenas88karl/automate-ami-demo:latest
only:
refs:
- master
script:
- chmod 755 ./aws-cli.sh
- terraform init && terraform apply -auto-approve
- packer validate ami.json
artifacts:
paths:
- ami.json
allow_failure: false
execute_packer:
stage: packer
tags: [gitlab-org]
image: registry.gitlab.com/cardenas88karl/automate-ami-demo:latest
only:
refs:
- master
script:
- chmod 755 ./amazon.sh
- packer build ami.json
dependencies:
- build_json
allow_failure: false