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

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

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

DescribeInstanceAssociationsStatus 搭配 CLI 使用

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

CLI
AWS CLI

描述執行個體關聯的狀態

此範例顯示執行個體關聯的詳細資訊。

命令:

aws ssm describe-instance-associations-status --instance-id "i-1234567890abcdef0"

輸出:

{ "InstanceAssociationStatusInfos": [ { "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "Name": "AWS-GatherSoftwareInventory", "DocumentVersion": "1", "AssociationVersion": "1", "InstanceId": "i-1234567890abcdef0", "ExecutionDate": 1550501886.0, "Status": "Success", "ExecutionSummary": "1 out of 1 plugin processed, 1 success, 0 failed, 0 timedout, 0 skipped. ", "AssociationName": "Inventory-Association" }, { "AssociationId": "5c5a31f6-6dae-46f9-944c-0123456789ab", "Name": "AWS-UpdateSSMAgent", "DocumentVersion": "1", "AssociationVersion": "1", "InstanceId": "i-1234567890abcdef0", "ExecutionDate": 1550505828.548, "Status": "Success", "DetailedStatus": "Success", "AssociationName": "UpdateSSMAgent" } ] }
PowerShell
for PowerShell 工具

範例 1:此範例顯示執行個體關聯的詳細資訊。

Get-SSMInstanceAssociationsStatus -InstanceId "i-0000293ffd8c57862"

輸出:

AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DetailedStatus : Pending DocumentVersion : 1 ErrorCode : ExecutionDate : 2/20/2015 8:31:11 AM ExecutionSummary : temp_status_change InstanceId : i-0000293ffd8c57862 Name : AWS-UpdateSSMAgent OutputUrl : Status : Pending

範例 2:此範例會檢查指定執行個體 ID 的執行個體關聯狀態,並進一步顯示這些關聯的執行狀態

Get-SSMInstanceAssociationsStatus -InstanceId i-012e3cb4df567e8aa | ForEach-Object {Get-SSMAssociationExecution -AssociationId .AssociationId}

輸出:

AssociationId : 512a34a5-c678-1234-1234-12345678db9e AssociationVersion : 2 CreatedTime : 3/2/2019 8:53:29 AM DetailedStatus : ExecutionId : 512a34a5-c678-1234-1234-12345678db9e LastExecutionDate : 1/1/0001 12:00:00 AM ResourceCountByStatus : {Success=9} Status : Success