There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListAssociations with a CLI
The following code examples show how to use ListAssociations.
- CLI
- 
            - AWS CLI
- 
             
                    Example 1: To list your associations for a specific instance The following list-associations example lists all associations with the AssociationName, UpdateSSMAgent. aws ssm list-associations/--association-filter-list"key=AssociationName,value=UpdateSSMAgent"Output: { "Associations": [ { "Name": "AWS-UpdateSSMAgent", "InstanceId": "i-1234567890abcdef0", "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "AssociationVersion": "1", "Targets": [ { "Key": "InstanceIds", "Values": [ "i-016648b75dd622dab" ] } ], "Overview": { "Status": "Pending", "DetailedStatus": "Associated", "AssociationStatusAggregatedCount": { "Pending": 1 } }, "ScheduleExpression": "cron(0 00 12 ? * SUN *)", "AssociationName": "UpdateSSMAgent" } ] }For more information, see Working with associations in Systems Manager in the Systems Manager User Guide. Example 2: To list your associations for a specific document The following list-associations example lists all associations for the specified document. aws ssm list-associations/--association-filter-list"key=Name,value=AWS-UpdateSSMAgent"Output: { "Associations": [ { "Name": "AWS-UpdateSSMAgent", "InstanceId": "i-1234567890abcdef0", "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "AssociationVersion": "1", "Targets": [ { "Key": "InstanceIds", "Values": [ "i-1234567890abcdef0" ] } ], "LastExecutionDate": 1550505828.548, "Overview": { "Status": "Success", "DetailedStatus": "Success", "AssociationStatusAggregatedCount": { "Success": 1 } }, "ScheduleExpression": "cron(0 00 12 ? * SUN *)", "AssociationName": "UpdateSSMAgent" }, { "Name": "AWS-UpdateSSMAgent", "InstanceId": "i-9876543210abcdef0", "AssociationId": "fbc07ef7-b985-4684-b82b-0123456789ab", "AssociationVersion": "1", "Targets": [ { "Key": "InstanceIds", "Values": [ "i-9876543210abcdef0" ] } ], "LastExecutionDate": 1550507531.0, "Overview": { "Status": "Success", "AssociationStatusAggregatedCount": { "Success": 1 } } } ] }For more information, see Working with associations in Systems Manager in the Systems Manager User Guide. - 
                    For API details, see ListAssociations in AWS CLI Command Reference. 
 
- 
                    
 
- PowerShell
- 
            - Tools for PowerShell V4
- 
             
                    Example 1: This example lists all the associations for an instance. The syntax used by this example requires PowerShell version 3 or later. $filter1 = @{Key="InstanceId";Value=@("i-0000293ffd8c57862")} Get-SSMAssociationList -AssociationFilterList $filter1Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}Example 2: This example lists all associations for a configuration document. The syntax used by this example requires PowerShell version 3 or later. $filter2 = @{Key="Name";Value=@("AWS-UpdateSSMAgent")} Get-SSMAssociationList -AssociationFilterList $filter2Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}Example 3: With PowerShell version 2, you must use New-Object to create each filter. $filter1 = New-Object Amazon.SimpleSystemsManagement.Model.AssociationFilter $filter1.Key = "InstanceId" $filter1.Value = "i-0000293ffd8c57862" Get-SSMAssociationList -AssociationFilterList $filter1Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}- 
                    For API details, see ListAssociations in AWS Tools for PowerShell Cmdlet Reference (V4). 
 
- 
                    
- Tools for PowerShell V5
- 
             
                    Example 1: This example lists all the associations for an instance. The syntax used by this example requires PowerShell version 3 or later. $filter1 = @{Key="InstanceId";Value=@("i-0000293ffd8c57862")} Get-SSMAssociationList -AssociationFilterList $filter1Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}Example 2: This example lists all associations for a configuration document. The syntax used by this example requires PowerShell version 3 or later. $filter2 = @{Key="Name";Value=@("AWS-UpdateSSMAgent")} Get-SSMAssociationList -AssociationFilterList $filter2Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}Example 3: With PowerShell version 2, you must use New-Object to create each filter. $filter1 = New-Object Amazon.SimpleSystemsManagement.Model.AssociationFilter $filter1.Key = "InstanceId" $filter1.Value = "i-0000293ffd8c57862" Get-SSMAssociationList -AssociationFilterList $filter1Output: AssociationId : d8617c07-2079-4c18-9847-1655fc2698b0 DocumentVersion : InstanceId : i-0000293ffd8c57862 LastExecutionDate : 2/20/2015 8:31:11 AM Name : AWS-UpdateSSMAgent Overview : Amazon.SimpleSystemsManagement.Model.AssociationOverview ScheduleExpression : Targets : {InstanceIds}- 
                    For API details, see ListAssociations in AWS Tools for PowerShell Cmdlet Reference (V5). 
 
-