View a markdown version of this page

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

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

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

搭配使用 ListAssociationVersions 與 CLI

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

CLI
AWS CLI

列出特定關聯 ID 之關聯的所有版本

下列 list-association-versions 範例列出了指定關聯的所有版本。

aws ssm list-association-versions \ --association-id "8dfe3659-4309-493a-8755-0123456789ab"

輸出:

{ "AssociationVersions": [ { "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "AssociationVersion": "1", "CreatedDate": 1550505536.726, "Name": "AWS-UpdateSSMAgent", "Parameters": { "allowDowngrade": [ "false" ], "version": [ "" ] }, "Targets": [ { "Key": "InstanceIds", "Values": [ "i-1234567890abcdef0" ] } ], "ScheduleExpression": "cron(0 00 12 ? * SUN *)", "AssociationName": "UpdateSSMAgent" } ] }

如需詳細資訊,請參閱《AWS Systems Manager 使用者指南》中的 Working with associations in Systems Manager

PowerShell
Tools for PowerShell V4

範例 1:此範例示範擷取所提供之關聯的所有版本。

Get-SSMAssociationVersionList -AssociationId 123a45a0-c678-9012-3456-78901234db5e

輸出:

AssociationId : 123a45a0-c678-9012-3456-78901234db5e AssociationName : AssociationVersion : 2 ComplianceSeverity : CreatedDate : 3/12/2019 9:21:01 AM DocumentVersion : MaxConcurrency : MaxErrors : Name : AWS-GatherSoftwareInventory OutputLocation : Parameters : {} ScheduleExpression : Targets : {InstanceIds} AssociationId : 123a45a0-c678-9012-3456-78901234db5e AssociationName : test-case-1234567890 AssociationVersion : 1 ComplianceSeverity : CreatedDate : 3/2/2019 8:53:29 AM DocumentVersion : MaxConcurrency : MaxErrors : Name : AWS-GatherSoftwareInventory OutputLocation : Parameters : {} ScheduleExpression : rate(30minutes) Targets : {InstanceIds}
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》中的 ListAssociationVersions

Tools for PowerShell V5

範例 1:此範例示範擷取所提供之關聯的所有版本。

Get-SSMAssociationVersionList -AssociationId 123a45a0-c678-9012-3456-78901234db5e

輸出:

AssociationId : 123a45a0-c678-9012-3456-78901234db5e AssociationName : AssociationVersion : 2 ComplianceSeverity : CreatedDate : 3/12/2019 9:21:01 AM DocumentVersion : MaxConcurrency : MaxErrors : Name : AWS-GatherSoftwareInventory OutputLocation : Parameters : {} ScheduleExpression : Targets : {InstanceIds} AssociationId : 123a45a0-c678-9012-3456-78901234db5e AssociationName : test-case-1234567890 AssociationVersion : 1 ComplianceSeverity : CreatedDate : 3/2/2019 8:53:29 AM DocumentVersion : MaxConcurrency : MaxErrors : Name : AWS-GatherSoftwareInventory OutputLocation : Parameters : {} ScheduleExpression : rate(30minutes) Targets : {InstanceIds}
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》中的 ListAssociationVersions