Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupupaulsv/f8ef077dfb24ad1103704b3ff089d777 to your computer and use it in GitHub Desktop.
Save lupupaulsv/f8ef077dfb24ad1103704b3ff089d777 to your computer and use it in GitHub Desktop.
for i in ${ids[@]}
do
echo "Waiting for build ID $i running on account: $ACCOUNT_ID"
echo "Debug information at https://us-west-2.console.aws.amazon.com/systems-manager/automation/execution/$i?region=$AWS_DEFAULT_REGION"
while true;
do
status=$(aws ssm get-automation-execution --output text --automation-execution-id "$i" )
if [[ $(echo "$status" | grep -i "status" | grep -i "failed") ]]; then
### something has gone wrong, stop the execution
echo "Build failed!"
exit 1
fi
if [[ $(echo "$status" | grep -i "imagestate" | grep -i "available") ]]; then
### store the new AMI since we'll need them in terraform
new_amis[$k]=$( echo "$status" |grep CREATEIMAGE.IMAGEID | grep -oP ami-[a-z0-9]+)
let k++
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment