forked from awslabs/ami-builder-packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
25 lines (24 loc) · 880 Bytes
/
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
version: 0.2
phases:
pre_build:
commands:
- echo "Installing Packer"
- curl -o packer.zip https://releases.hashicorp.com/packer/1.0.3/packer_1.0.3_linux_amd64.zip && unzip packer.zip
- echo "Validating Packer template"
- ./packer validate packer_cis.json
build:
commands:
- ./packer build -color=false packer_cis.json | tee build.log
post_build:
commands:
- egrep "${AWS_REGION}\:\sami\-" build.log | cut -d' ' -f2 > ami_id.txt
# Packer doesn't return non-zero status; we must do that if Packer build failed
- test -s ami_id.txt || exit 1
- sed -i.bak "s/<<AMI-ID>>/$(cat ami_id.txt)/g" ami_builder_event.json
- aws events put-events --entries file://ami_builder_event.json
- echo "build completed on `date`"
artifacts:
files:
- ami_builder_event.json
- build.log
discard-paths: yes