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

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

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

ListAssociationVersions配 AWS SDK或使用 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" } ] }

如需詳細資訊,請參閱《Systems Manager 理員使用指南》中的〈AWS Systems Manager〉中的使用關聯

PowerShell
適用的工具 PowerShell

範例 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}