-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
27 lines (25 loc) · 1.01 KB
/
buildspec.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
---
version: 0.2
env:
variables:
USER: root
phases:
pre_build:
commands:
- echo 'pre_build.'
- echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk add jq aws-cli --update
- packer validate template.json
build:
commands:
- echo 'build'
- curl -sqL -o aws_credentials.json http://169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
- aws configure set region ap-northeast-1
- aws configure set aws_access_key_id `jq -r '.AccessKeyId' aws_credentials.json`
- aws configure set aws_secret_access_key `jq -r '.SecretAccessKey' aws_credentials.json`
- aws configure set aws_session_token `jq -r '.Token' aws_credentials.json`
- packer build template.json
post_build:
commands:
- echo 'post_build'
- aws ec2 modify-image-attribute --image-id `aws ec2 describe-images --owners self | jq -r '.Images | sort_by(.CreationDate) | reverse | .[0].ImageId'` --launch-permission "{\"Add\":[{\"Group\":\"all\"}]}"