@@ -4,33 +4,33 @@ set -eu
44instance_id=" $1 "
55
66REGION_SEPARATOR=' --'
7- if [[ " ${ instance_id} " == * " ${REGION_SEPARATOR} " * ]]
7+ if echo " $instance_id " | grep -q -e " ${REGION_SEPARATOR} "
88then
9- export AWS_DEFAULT_REGION=" ${instance_id##* ${ REGION_SEPARATOR} } "
10- instance_id=" ${instance_id%% ${ REGION_SEPARATOR} * } "
9+ export AWS_DEFAULT_REGION=" ${instance_id##* " $ REGION_SEPARATOR" } "
10+ instance_id=" ${instance_id%% " $ REGION_SEPARATOR" * } "
1111fi
1212
1313START_INSTANCE_TIMEOUT=300
1414START_INSTANCE_CHECK_INTERVAL=5
15- STATUS=` aws ssm describe-instance-information --filters Key=InstanceIds,Values=${ instance_id} --output text --query ' InstanceInformationList[0].PingStatus' `
16- if [ $STATUS != ' Online' ]
15+ STATUS=$( aws ssm describe-instance-information --filters Key=InstanceIds,Values=" $ instance_id" --output text --query ' InstanceInformationList[0].PingStatus' )
16+ if [ " $STATUS " != ' Online' ]
1717then
1818 aws ec2 start-instances --instance-ids " ${instance_id} " --profile " ${AWS_PROFILE} " --region " ${AWS_REGION} "
1919 > /dev/stderr echo " Waiting for EC2 Instance ${instance_id} ..."
2020 START_INSTANCE_START=" $( date +%s) "
21- while [ $(( $(date +% s) - $START_INSTANCE_START )) -le ${START_INSTANCE_TIMEOUT} ]
21+ while [ $(( $(date +% s) - " $START_INSTANCE_START " )) -le ${START_INSTANCE_TIMEOUT} ]
2222 do
23- > /dev/stderr echo -n " ."
23+ > /dev/stderr printf " ."
2424 sleep ${START_INSTANCE_CHECK_INTERVAL}
25- STATUS=` aws ssm describe-instance-information --filters Key=InstanceIds,Values=${ instance_id} --output text --query ' InstanceInformationList[0].PingStatus' `
26- if [ ${ STATUS} = = ' Online' ]
25+ STATUS=$( aws ssm describe-instance-information --filters Key=InstanceIds,Values=" $ instance_id" --output text --query ' InstanceInformationList[0].PingStatus' )
26+ if [ " $ STATUS" = ' Online' ]
2727 then
2828 break
2929 fi
3030 done
3131 > /dev/stderr echo
3232
33- if [ $STATUS != ' Online' ]
33+ if [ " $STATUS " != ' Online' ]
3434 then
3535 > /dev/stderr echo " Timeout."
3636 exit 1
0 commit comments