Skip to content

Instantly share code, notes, and snippets.

@anorsich
Created September 8, 2014 09:33
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 anorsich/70324a09890bde8fac62 to your computer and use it in GitHub Desktop.
Save anorsich/70324a09890bde8fac62 to your computer and use it in GitHub Desktop.
Wait for amazon elastic beanstalk environment become green.
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop | cut -d":" -f2| sed -e 's/^ *//g' -e 's/ *$//g' `
echo ${temp##*|}
}
echo "Waiting 20 seconds before start checking"
sleep 20s
echo "Press [CTRL+C] to stop.."
VERSION=$1
while true
do
json=$(aws elasticbeanstalk describe-environments --version-label "${VERSION}")
echo "$json"
prop='Health'
Health=`jsonval`
if [ "$Health" == "Green" ]
then
echo "Application is propagated, health is Green"
break
else
echo "Health is:" ${Health}". Will check again in 10 seconds"
fi
sleep 10s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment