From 8f87c5c223e2a3e06c327350f84a9ab858a73f76 Mon Sep 17 00:00:00 2001 From: Ken Cochrane Date: Sat, 13 Aug 2016 13:05:19 +0000 Subject: [PATCH] Added changes to support nightly builds for AWS --- alpine/cloud/aws/bake-ami.sh | 12 +++++++----- alpine/cloud/aws/common.sh | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/alpine/cloud/aws/bake-ami.sh b/alpine/cloud/aws/bake-ami.sh index 92d53e415..9f1505e6f 100755 --- a/alpine/cloud/aws/bake-ami.sh +++ b/alpine/cloud/aws/bake-ami.sh @@ -16,6 +16,8 @@ export AWS_DEFAULT_REGION=$(current_instance_region) # TODO(nathanleclaire): This device could be calculated dynamically to avoid conflicts. EBS_DEVICE=/dev/xvdb +CHANNEL=${CHANNEL:-editions} +DAY=$(date +"%m_%d_%Y") bake_image() { @@ -26,7 +28,7 @@ bake_image() --size 20 \ --availability-zone $(current_instance_az) | jq -r .VolumeId) - tag ${VOLUME_ID} + tag ${VOLUME_ID} ${DAY} ${CHANNEL} aws ec2 wait volume-available --volume-ids ${VOLUME_ID} @@ -48,7 +50,7 @@ bake_image() --volume-id ${VOLUME_ID} \ --description "Snapshot of Moby device for AMI baking" | jq -r .SnapshotId) - tag ${SNAPSHOT_ID} + tag ${SNAPSHOT_ID} ${DAY} ${CHANNEL} arrowecho "Waiting for snapshot completion" @@ -70,7 +72,7 @@ bake_image() } ]" | jq -r .ImageId) - tag ${IMAGE_ID} + tag ${IMAGE_ID} ${DAY} ${CHANNEL} # Boom, now you (should) have a Moby AMI. arrowecho "Created AMI: ${IMAGE_ID}" @@ -137,9 +139,9 @@ case "$1" in bake_image ;; clean) - arrowecho "Cleaning resources from previous build tag if applicable..." + arrowecho "Cleaning resources from previous build tag (${TAG_KEY_PREV}) if applicable..." clean_tagged_resources "${TAG_KEY_PREV}" - arrowecho "Cleaning resources from current build tag if applicable..." + arrowecho "Cleaning resources from current build tag (${TAG_KEY}) if applicable..." clean_tagged_resources "${TAG_KEY}" ;; clean-mount) diff --git a/alpine/cloud/aws/common.sh b/alpine/cloud/aws/common.sh index a2123e951..75dedb2f3 100644 --- a/alpine/cloud/aws/common.sh +++ b/alpine/cloud/aws/common.sh @@ -29,6 +29,8 @@ current_instance_id() # cleaned up later. tag() { - arrowecho "Tagging $1" + arrowecho "Tagging $1 with ${TAG_KEY}, $2, and $3" aws ec2 create-tags --resources "$1" --tags "Key=${TAG_KEY},Value=" >/dev/null + aws ec2 create-tags --resources "$1" --tags "Key=date,Value=$2" >/dev/null + aws ec2 create-tags --resources "$1" --tags "Key=channel,Value=$3" >/dev/null }