list_associations
(**kwargs)¶Returns all State Manager associations in the current Amazon Web Services account and Amazon Web Services Region. You can limit the results to a specific State Manager association document or managed node by specifying a filter. State Manager is a capability of Amazon Web Services Systems Manager.
See also: AWS API Documentation
Request Syntax
response = client.list_associations(
AssociationFilterList=[
{
'key': 'InstanceId'|'Name'|'AssociationId'|'AssociationStatusName'|'LastExecutedBefore'|'LastExecutedAfter'|'AssociationName'|'ResourceGroupName',
'value': 'string'
},
],
MaxResults=123,
NextToken='string'
)
One or more filters. Use a filter to return a more specific list of results.
Note
Filtering associations using the InstanceID
attribute only returns legacy associations created using the InstanceID
attribute. Associations targeting the managed node that are part of the Target Attributes ResourceGroup
or Tags
aren't returned.
Describes a filter.
The name of the filter.
Note
InstanceId
has been deprecated.
The filter value.
dict
Response Syntax
{
'Associations': [
{
'Name': 'string',
'InstanceId': 'string',
'AssociationId': 'string',
'AssociationVersion': 'string',
'DocumentVersion': 'string',
'Targets': [
{
'Key': 'string',
'Values': [
'string',
]
},
],
'LastExecutionDate': datetime(2015, 1, 1),
'Overview': {
'Status': 'string',
'DetailedStatus': 'string',
'AssociationStatusAggregatedCount': {
'string': 123
}
},
'ScheduleExpression': 'string',
'AssociationName': 'string',
'ScheduleOffset': 123,
'TargetMaps': [
{
'string': [
'string',
]
},
]
},
],
'NextToken': 'string'
}
Response Structure
(dict) --
Associations (list) --
The associations.
(dict) --
Describes an association of a Amazon Web Services Systems Manager document (SSM document) and a managed node.
Name (string) --
The name of the SSM document.
InstanceId (string) --
The managed node ID.
AssociationId (string) --
The ID created by the system when you create an association. An association is a binding between a document and a set of targets with a schedule.
AssociationVersion (string) --
The association version.
DocumentVersion (string) --
The version of the document used in the association. If you change a document version for a State Manager association, Systems Manager immediately runs the association unless you previously specifed the apply-only-at-cron-interval
parameter.
Warning
State Manager doesn't support running associations that use a new version of a document if that document is shared from another account. State Manager always runs the default
version of a document if shared from another account, even though the Systems Manager console shows that a new version was processed. If you want to run an association using a new version of a document shared form another account, you must set the document version to default
.
Targets (list) --
The managed nodes targeted by the request to create an association. You can target all managed nodes in an Amazon Web Services account by specifying the InstanceIds
key with a value of *
.
(dict) --
An array of search criteria that targets managed nodes using a key-value pair that you specify.
Note
One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task, targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User Guide .
Supported formats include the following.
Key=InstanceIds,Values=<instance-id-1>,<instance-id-2>,<instance-id-3>
Key=tag:<my-tag-key>,Values=<my-tag-value-1>,<my-tag-value-2>
Key=tag-key,Values=<my-tag-key-1>,<my-tag-key-2>
Key=resource-groups:Name,Values=<resource-group-name>
Key=resource-groups:ResourceTypeFilters,Values=<resource-type-1>,<resource-type-2>
Key=ResourceGroup;Values=<resource-group-name>
For example:
Key=InstanceIds,Values=i-02573cafcfEXAMPLE,i-0471e04240EXAMPLE,i-07782c72faEXAMPLE
Key=tag:CostCenter,Values=CostCenter1,CostCenter2,CostCenter3
Key=tag-key,Values=Name,Instance-Type,CostCenter
Key=resource-groups:Name,Values=ProductionResourceGroup
This example demonstrates how to target all resources in the resource group ProductionResourceGroup in your maintenance window.Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC
This example demonstrates how to target only Amazon Elastic Compute Cloud (Amazon EC2) instances and VPCs in your maintenance window.Key=ResourceGroup,Values=MyResourceGroup
Key=InstanceIds,Values=*
This example demonstrates how to target all managed instances in the Amazon Web Services Region where the association was created.For more information about how to send commands that target managed nodes using Key,Value
parameters, see Targeting multiple instances in the Amazon Web Services Systems Manager User Guide .
Key (string) --
User-defined criteria for sending commands that target managed nodes that meet the criteria.
Values (list) --
User-defined criteria that maps to Key
. For example, if you specified tag:ServerRole
, you could specify value:WebServer
to run a command on instances that include EC2 tags of ServerRole,WebServer
.
Depending on the type of target, the maximum number of values for a key might be lower than the global maximum of 50.
LastExecutionDate (datetime) --
The date on which the association was last run.
Overview (dict) --
Information about the association.
Status (string) --
The status of the association. Status can be: Pending, Success, or Failed.
DetailedStatus (string) --
A detailed status of the association.
AssociationStatusAggregatedCount (dict) --
Returns the number of targets for the association status. For example, if you created an association with two managed nodes, and one of them was successful, this would return the count of managed nodes by status.
ScheduleExpression (string) --
A cron expression that specifies a schedule when the association runs. The schedule runs in Coordinated Universal Time (UTC).
AssociationName (string) --
The association name.
ScheduleOffset (integer) --
Number of days to wait after the scheduled day to run an association.
TargetMaps (list) --
A key-value mapping of document parameters to target resources. Both Targets and TargetMaps can't be specified together.
NextToken (string) --
The token to use when requesting the next set of items. If there are no additional items to return, the string is empty.
Exceptions
SSM.Client.exceptions.InternalServerError
SSM.Client.exceptions.InvalidNextToken