-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildspec.yml
20 lines (19 loc) · 886 Bytes
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: 0.2
phases:
pre_build:
commands:
- cd $CODEBUILD_SRC_DIR/ami_build_packer/
- echo "Installing Packer"
- curl -o packer.zip https://releases.hashicorp.com/packer/1.6.5/packer_1.6.5_linux_amd64.zip && unzip packer.zip
- echo "installed Packer."
build:
commands:
- ./packer build -color=false -var "base_ami=$BASE_AMI" images/web_ami_image.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
- cat ami_id.txt
- aws ssm put-parameter --name $AMIID_SSMPS --type "String" --value $(cat ami_id.txt) --overwrite
- aws sns publish --topic-arn $SNS_ARN --message "Hi There... New AMI is available now. AMI ID- $(cat ami_id.txt)"