Skip to content

Commit 3eea6b2

Browse files
committed
Add ssm functions
- ssm-automation-execution-failures: lists the failed steps - ssm-automation-step-executions: lists steps
1 parent 615fca1 commit 3eea6b2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lib/ssm-functions

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,46 @@ ssm-automation-executions() {
206206
| columnise
207207
}
208208

209+
ssm-automation-execution-failures() {
210+
local search="${@:-}"
211+
ssm-automation-executions Failed | grep 'i-' | grep "${search}" | xargs -I{} sh -c ' echo "{}" | cut -f 1,2,3,4 | tr "\n" "\t" | tee /dev/tty | bma ssm-automation-step-executions | rg --word-regexp Failed | cut -f 2,3,4,6,8'
212+
}
213+
214+
ssm-automation-step-executions() {
215+
216+
# Show step-by-step details for an SSM Automation Execution
217+
#
218+
# USAGE: automation-execution-steps execution_id [execution_id]
219+
#
220+
# $ ssm-automation-executions | ssm-automation-steps-executions
221+
# [Outputs detailed step information for each provided execution ID]
222+
223+
local automation_executions="$(skim-stdin "$@")"
224+
225+
local automation_execution
226+
for automation_execution in $automation_executions; do
227+
# echo "Details for Automation Execution ID: $automation_execution"
228+
aws ssm describe-automation-step-executions \
229+
--automation-execution-id "$automation_execution" \
230+
--output text \
231+
--query "
232+
StepExecutions[].[
233+
'$automation_execution',
234+
StepName,
235+
StepStatus,
236+
Action,
237+
StepExecutionId,
238+
ExecutionStartTime,
239+
ExecutionEndTime,
240+
FailureMessage
241+
]"
242+
echo "" # Adds a line break for readability
243+
done \
244+
| LC_ALL=C sort -k 5 -t $'\t' \
245+
| columnise
246+
}
247+
248+
209249
ssm-automation-execution() {
210250

211251
# Show details for an SSM Automation Execution

0 commit comments

Comments
 (0)