将 GetAutomationExecution 与 CLI 配合使用 - AWS Systems Manager

GetAutomationExecution 与 CLI 配合使用

以下代码示例演示如何使用 GetAutomationExecution

CLI
AWS CLI

显示有关自动化执行的详细信息

以下 get-automation-execution 示例显示有关自动化执行的详细信息。

aws ssm get-automation-execution \ --automation-execution-id 73c8eef8-f4ee-4a05-820c-e354fEXAMPLE

输出:

{ "AutomationExecution": { "AutomationExecutionId": "73c8eef8-f4ee-4a05-820c-e354fEXAMPLE", "DocumentName": "AWS-StartEC2Instance", "DocumentVersion": "1", "ExecutionStartTime": 1583737233.748, "ExecutionEndTime": 1583737234.719, "AutomationExecutionStatus": "Success", "StepExecutions": [ { "StepName": "startInstances", "Action": "aws:changeInstanceState", "ExecutionStartTime": 1583737234.134, "ExecutionEndTime": 1583737234.672, "StepStatus": "Success", "Inputs": { "DesiredState": "\"running\"", "InstanceIds": "[\"i-0cb99161f6EXAMPLE\"]" }, "Outputs": { "InstanceStates": [ "running" ] }, "StepExecutionId": "95e70479-cf20-4d80-8018-7e4e2EXAMPLE", "OverriddenParameters": {} } ], "StepExecutionsTruncated": false, "Parameters": { "AutomationAssumeRole": [ "" ], "InstanceId": [ "i-0cb99161f6EXAMPLE" ] }, "Outputs": {}, "Mode": "Auto", "ExecutedBy": "arn:aws:sts::29884EXAMPLE:assumed-role/mw_service_role/OrchestrationService", "Targets": [], "ResolvedTargets": { "ParameterValues": [], "Truncated": false } } }

有关更多信息,请参阅《AWS Systems Manager 用户指南》中的演练:修补 Linux AMI(AWS CLI)

PowerShell
适用于 PowerShell 的工具

示例 1:此示例显示自动化执行的详细信息。

Get-SSMAutomationExecution -AutomationExecutionId "4105a4fc-f944-11e6-9d32-8fb2db27a909"

输出:

AutomationExecutionId : 4105a4fc-f944-11e6-9d32-8fb2db27a909 AutomationExecutionStatus : Failed DocumentName : AWS-UpdateLinuxAmi DocumentVersion : 1 ExecutionEndTime : 2/22/2017 9:17:08 PM ExecutionStartTime : 2/22/2017 9:17:02 PM FailureMessage : Step launchInstance failed maximum allowed times. You are not authorized to perform this operation. Encoded authorization failure message: B_V2QyyN7NhSZQYpmVzpEc4oSnj2GLTNYnXUHsTbqJkNMoDgubmbtthLmZyaiUYekORIrA42-fv1x-04q5Fjff6glh Yb6TI5b0GQeeNrpwNvpDzmO-PSR1swlAbg9fdM9BcNjyrznspUkWpuKu9EC1Ou6v3OXU1KC9nZ7mPlWMFZNkSioQqpwWEvMw-GZktsQzm67qOhUhBNOLWYhbS pkfiqzY-5nw3S0obx30fhd3EJa5O_-GjV_a0nFXQJa70ik40bFOrEh3MtCSbrQT6--DvFy_FQ8TKvkIXadyVskeJI84XOF5WmA60f1pi5GI08i-nRfZS6oDeU gELBjjoFKD8s3L2aI0B6umWVxnQOjqhQRxwJ53b54sZJ2PW3v_mtg9-q0CK0ezS3xfh_y0ilaUGOAZG-xjQFuvU_JZedWpla3xi-MZsmblAifBI (Service: AmazonEC2; Status Code: 403; Error Code: UnauthorizedOperation; Request ID: 6a002f94-ba37-43fd-99e6-39517715fce5) Outputs : {[createImage.ImageId, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]} Parameters : {[AutomationAssumeRole, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]], [InstanceIamRole, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]], [SourceAmiId, Amazon.Runtime.Internal.Util.AlwaysSendList`1[System.String]]} StepExecutions : {launchInstance, updateOSSoftware, stopInstance, createImage...}

示例 2:此示例列出给定自动化执行 ID 的步骤详细信息

Get-SSMAutomationExecution -AutomationExecutionId e1d2bad3-4567-8901-ae23-456c7c8901be | Select-Object -ExpandProperty StepExecutions | Select-Object StepName, Action, StepStatus, ValidNextSteps

输出:

StepName Action StepStatus ValidNextSteps -------- ------ ---------- -------------- LaunchInstance aws:runInstances Success {OSCompatibilityCheck} OSCompatibilityCheck aws:runCommand Success {RunPreUpdateScript} RunPreUpdateScript aws:runCommand Success {UpdateEC2Config} UpdateEC2Config aws:runCommand Cancelled {} UpdateSSMAgent aws:runCommand Pending {} UpdateAWSPVDriver aws:runCommand Pending {} UpdateAWSEnaNetworkDriver aws:runCommand Pending {} UpdateAWSNVMe aws:runCommand Pending {} InstallWindowsUpdates aws:runCommand Pending {} RunPostUpdateScript aws:runCommand Pending {} RunSysprepGeneralize aws:runCommand Pending {} StopInstance aws:changeInstanceState Pending {} CreateImage aws:createImage Pending {} TerminateInstance aws:changeInstanceState Pending {}
  • 有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference》中的 GetAutomationExecution

有关 AWS SDK 开发人员指南和代码示例的完整列表,请参阅 将 Systems Manager 与 AWS SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。