Added ability to make ami-clean-mount to clean up AMI volume mount

Signed-off-by: Ken Cochrane <KenCochrane@gmail.com>
This commit is contained in:
Ken Cochrane 2016-09-13 16:22:46 -04:00
parent 91507f1382
commit 3a5d68acbf
2 changed files with 20 additions and 9 deletions

View File

@ -55,6 +55,9 @@ ami: common
docker-compose run --rm -T ami clean
docker-compose run --rm -T ami bake
ami-clean-mount: common
docker-compose run --rm -T ami clean-mount
azure: common
docker-compose build azure
docker-compose run --rm -T azure makeraw

View File

@ -76,13 +76,8 @@ bake_image()
echo "${IMAGE_ID}" >"${MOBY_SRC_ROOT}/cloud/aws/ami_id.out"
}
clean_tagged_resources()
clean_volume_mount()
{
if [ -d "${MOBY_SRC_ROOT}/moby" ]
then
rm -rf "${MOBY_SRC_ROOT}/moby"
fi
VOLUME_ID=$(aws ec2 describe-volumes --filters "Name=tag-key,Values=$1" | jq -r .Volumes[0].VolumeId)
if [ ${VOLUME_ID} = "null" ]
then
@ -94,6 +89,16 @@ clean_tagged_resources()
arrowecho "Deleting volume"
aws ec2 delete-volume --volume-id ${VOLUME_ID} >/dev/null
fi
}
clean_tagged_resources()
{
if [ -d "${MOBY_SRC_ROOT}/moby" ]
then
rm -rf "${MOBY_SRC_ROOT}/moby"
fi
clean_volume_mount $1
IMAGE_ID=$(aws ec2 describe-images --filters "Name=tag-key,Values=$1" | jq -r .Images[0].ImageId)
if [ ${IMAGE_ID} = "null" ]
@ -129,6 +134,9 @@ case "$1" in
arrowecho "Cleaning resources from current build tag if applicable..."
clean_tagged_resources "${TAG_KEY}"
;;
clean-mount)
clean_volume_mount "${TAG_KEY}"
;;
*)
echo "Command $1 not found. Usage: ./bake-ami.sh [bake|clean]"
echo "Command $1 not found. Usage: ./bake-ami.sh [bake|clean|clean-mount]"
esac