@@ -116,7 +116,7 @@ while getopts "a:d:c:f:g:w:n:t:r:p:o:x:shvl" OPTION; do
116
116
;;
117
117
g)
118
118
github_token_location=$OPTARG
119
- ;;
119
+ ;;
120
120
c)
121
121
cloudwatch_group=$OPTARG
122
122
;;
@@ -281,7 +281,7 @@ elif [ "${action}" == "document" ]; then
281
281
cloudwatch_group=" aws-connect"
282
282
fi
283
283
284
- echo " Running ${document_name} on instance ${instance_id} "
284
+ echo " Running ${document_name} on instance ${instance_id} "
285
285
286
286
# create the send-command as a string so that parameters can be appended on if needed
287
287
aws_command=" aws ssm send-command \
@@ -305,11 +305,11 @@ elif [ "${action}" == "document" ]; then
305
305
306
306
if [ " $? " != " 0" ]; then
307
307
echo " Unable to execute command!"
308
- exit 0
308
+ exit 1
309
309
fi
310
310
311
311
echo " Command ID: $sh_command_id "
312
-
312
+
313
313
# get the status of the command
314
314
status=$( aws ssm list-command-invocations \
315
315
--command-id " ${sh_command_id} " \
@@ -336,21 +336,13 @@ elif [ "${action}" == "document" ]; then
336
336
337
337
echo " Command still running..."
338
338
sleep 5
339
-
339
+
340
340
status=$( aws ssm list-command-invocations \
341
341
--command-id " ${sh_command_id} " \
342
342
--details \
343
343
--output text \
344
344
--no-paginate \
345
- --query " CommandInvocations[0].Status" )
346
-
347
- # check if the command has failed
348
- for (( i = 0 ; i < "${# ssm_failed_statuses[@]} "; i++ )) ; do
349
- if [ " ${ssm_failed_statuses[$i]} " == " ${status} " ]; then
350
- echo " Failure Status: ${ssm_failed_statuses[$i]} !"
351
- endLoop=" true"
352
- fi
353
- done
345
+ --query " CommandInvocations[0].Status" )
354
346
355
347
# check if the command has succeeded. If so then get the command output
356
348
if [ " Success" == " ${status} " ]; then
@@ -370,6 +362,15 @@ elif [ "${action}" == "document" ]; then
370
362
endLoop=" true"
371
363
fi
372
364
365
+ # check if the command has failed
366
+ for (( i = 0 ; i < "${# ssm_failed_statuses[@]} "; i++ )) ; do
367
+ if [ " ${ssm_failed_statuses[$i]} " == " ${status} " ]; then
368
+ echo " Failure Status: ${ssm_failed_statuses[$i]} !"
369
+ endLoop=" true"
370
+ exit 1
371
+ fi
372
+ done
373
+
373
374
done
374
375
375
376
else
0 commit comments