DescribeAutomationExecutions 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeAutomationExecutions 搭配 CLI 使用

下列程式碼範例示範如何使用 DescribeAutomationExecutions

CLI
AWS CLI

描述自動化執行

下列describe-automation-executions範例顯示自動化執行的詳細資訊。

aws ssm describe-automation-executions \ --filters Key=ExecutionId,Values=73c8eef8-f4ee-4a05-820c-e354fEXAMPLE

輸出:

{ "AutomationExecutionMetadataList": [ { "AutomationExecutionId": "73c8eef8-f4ee-4a05-820c-e354fEXAMPLE", "DocumentName": "AWS-StartEC2Instance", "DocumentVersion": "1", "AutomationExecutionStatus": "Success", "ExecutionStartTime": 1583737233.748, "ExecutionEndTime": 1583737234.719, "ExecutedBy": "arn:aws:sts::29884EXAMPLE:assumed-role/mw_service_role/OrchestrationService", "LogFile": "", "Outputs": {}, "Mode": "Auto", "Targets": [], "ResolvedTargets": { "ParameterValues": [], "Truncated": false }, "AutomationType": "Local" } ] }

如需詳細資訊,請參閱 AWS Systems Manager 使用者指南中的執行簡單自動化工作流程

PowerShell
for PowerShell 工具

範例 1:此範例說明與您的帳戶相關聯的所有作用中和已終止的 Automation Execution。

Get-SSMAutomationExecutionList

輸出:

AutomationExecutionId : 4105a4fc-f944-11e6-9d32-8fb2db27a909 AutomationExecutionStatus : Failed DocumentName : AWS-UpdateLinuxAmi DocumentVersion : 1 ExecutedBy : admin ExecutionEndTime : 2/22/2017 9:17:08 PM ExecutionStartTime : 2/22/2017 9:17:02 PM LogFile : Outputs : {[createImage.ImageId, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]}

範例 2:此範例顯示執行 AutomationExecutionStatus 以外的執行的 ExecutionID、文件、執行開始/結束時間戳記 '成功'

Get-SSMAutomationExecutionList | Where-Object AutomationExecutionStatus -ne "Success" | Select-Object AutomationExecutionId, DocumentName, AutomationExecutionStatus, ExecutionStartTime, ExecutionEndTime | Format-Table -AutoSize

輸出:

AutomationExecutionId DocumentName AutomationExecutionStatus ExecutionStartTime ExecutionEndTime --------------------- ------------ ------------------------- ------------------ ---------------- e1d2bad3-4567-8901-ae23-456c7c8901be AWS-UpdateWindowsAmi Cancelled 4/16/2019 5:37:04 AM 4/16/2019 5:47:29 AM 61234567-a7f8-90e1-2b34-567b8bf9012c Fixed-UpdateAmi Cancelled 4/16/2019 5:33:04 AM 4/16/2019 5:40:15 AM 91234d56-7e89-0ac1-2aee-34ea5d6a7c89 AWS-UpdateWindowsAmi Failed 4/16/2019 5:22:46 AM 4/16/2019 5:27:29 AM