@@ -187,7 +187,7 @@ autoscaling_group_name() {
187187 local autoscaling_name=$( $AWS_CLI autoscaling describe-auto-scaling-instances \
188188 --instance-ids $instance_id \
189189 --output text \
190- --query AutoScalingInstances[0].AutoScalingGroupName)
190+ --query AutoScalingInstances[0].AutoScalingGroupName | tr -d ' \n\r ' )
191191
192192 if [ $? != 0 ]; then
193193 return 1
@@ -211,8 +211,7 @@ autoscaling_enter_standby() {
211211 local asg_name=${2}
212212
213213 msg " Checking if this instance has already been moved in the Standby state"
214- local instance_state_temp=$( get_instance_state_asg $instance_id )
215- local instance_state=${instance_state_temp::- 1}
214+ local instance_state=$( get_instance_state_asg $instance_id )
216215 if [ $? != 0 ]; then
217216 msg " Unable to get this instance's lifecycle state."
218217 return 1
@@ -295,11 +294,10 @@ autoscaling_enter_standby() {
295294# successful.
296295autoscaling_exit_standby () {
297296 local instance_id=$1
298- local asg_name=${2}
297+ local asg_name=${2}
299298
300299 msg " Checking if this instance has already been moved out of Standby state"
301- local instance_state_temp=$( get_instance_state_asg $instance_id )
302- local instance_state=${instance_state_temp::- 1}
300+ local instance_state=$( get_instance_state_asg $instance_id )
303301 if [ $? != 0 ]; then
304302 msg " Unable to get this instance's lifecycle state."
305303 return 1
@@ -316,9 +314,7 @@ autoscaling_exit_standby() {
316314 fi
317315
318316 msg " Moving instance $instance_id out of Standby"
319- $AWS_CLI autoscaling exit-standby \
320- --instance-ids $instance_id \
321- --auto-scaling-group-name " ${asg_name} "
317+ $AWS_CLI autoscaling exit-standby --instance-ids $instance_id --auto-scaling-group-name ${asg_name}
322318 if [ $? != 0 ]; then
323319 msg " Failed to put instance $instance_id back into InService for ASG ${asg_name} ."
324320 return 1
@@ -455,7 +451,7 @@ wait_for_state() {
455451
456452 msg " Checking $WAITER_ATTEMPTS times, every $WAITER_INTERVAL seconds, for instance $instance_id to be in state $state_name "
457453
458- local instance_state=$( $instance_state_cmd )
454+ local instance_state=$( $instance_state_cmd | tr -d ' \n\r ' )
459455 local count=1
460456
461457 msg " Instance is currently in state: $instance_state "
@@ -468,9 +464,8 @@ wait_for_state() {
468464
469465 sleep $WAITER_INTERVAL
470466
471- instance_state_temp=$( $instance_state_cmd )
472- instance_state=${instance_state_temp::- 1}
473- count=$(( $count + 1 ))
467+ instance_state=$( $instance_state_cmd | tr -d ' \n\r' )
468+ count=$(( $count + 1 ))
474469 msg " Instance is currently in state: $instance_state "
475470 done
476471
0 commit comments