将 CreateAssociationBatch
与 Amazon SDK 或 CLI 配合使用
以下代码示例演示如何使用 CreateAssociationBatch
。
- CLI
-
- Amazon CLI
-
创建多个关联
此示例将一个配置文档与多个实例相关联。如果适用,输出将返回成功和失败操作的列表。
命令:
aws ssm create-association-batch --entries "Name=AWS-UpdateSSMAgent,InstanceId=i-1234567890abcdef0" "Name=AWS-UpdateSSMAgent,InstanceId=i-9876543210abcdef0"
输出:
{ "Successful": [ { "Name": "AWS-UpdateSSMAgent", "InstanceId": "i-1234567890abcdef0", "AssociationVersion": "1", "Date": 1550504725.007, "LastUpdateAssociationDate": 1550504725.007, "Status": { "Date": 1550504725.007, "Name": "Associated", "Message": "Associated with AWS-UpdateSSMAgent" }, "Overview": { "Status": "Pending", "DetailedStatus": "Creating" }, "DocumentVersion": "$DEFAULT", "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "Targets": [ { "Key": "InstanceIds", "Values": [ "i-1234567890abcdef0" ] } ] }, { "Name": "AWS-UpdateSSMAgent", "InstanceId": "i-9876543210abcdef0", "AssociationVersion": "1", "Date": 1550504725.057, "LastUpdateAssociationDate": 1550504725.057, "Status": { "Date": 1550504725.057, "Name": "Associated", "Message": "Associated with AWS-UpdateSSMAgent" }, "Overview": { "Status": "Pending", "DetailedStatus": "Creating" }, "DocumentVersion": "$DEFAULT", "AssociationId": "9c9f7f20-5154-4fed-a83e-0123456789ab", "Targets": [ { "Key": "InstanceIds", "Values": [ "i-9876543210abcdef0" ] } ] } ], "Failed": [] }
-
有关 API 详细信息,请参阅《Amazon CLI Command Reference》中的 CreateAssociationBatch
。
-
- PowerShell
-
- 适用于 PowerShell 的工具
-
示例 1:此示例将一个配置文档与多个实例相关联。如果适用,输出将返回成功和失败操作的列表。
$option1 = @{InstanceId="i-0cb2b964d3e14fd9f";Name=@("AWS-UpdateSSMAgent")} $option2 = @{InstanceId="i-0000293ffd8c57862";Name=@("AWS-UpdateSSMAgent")} New-SSMAssociationFromBatch -Entry $option1,$option2
输出:
Failed Successful ------ ---------- {} {Amazon.SimpleSystemsManagement.Model.FailedCreateAssociation, Amazon.SimpleSystemsManagement.Model.FailedCreateAsso...
示例 2:此示例将显示成功操作的完整详细信息。
$option1 = @{InstanceId="i-0cb2b964d3e14fd9f";Name=@("AWS-UpdateSSMAgent")} $option2 = @{InstanceId="i-0000293ffd8c57862";Name=@("AWS-UpdateSSMAgent")} (New-SSMAssociationFromBatch -Entry $option1,$option2).Successful
-
有关 API 详细信息,请参阅《Amazon Tools for PowerShell Cmdlet Reference》中的 CreateAssociationBatch。
-
有关 Amazon SDK 开发人员指南和代码示例的完整列表,请参阅 将 Systems Manager 与 Amazon SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
CreateAssociation
CreateDocument