aws ssm create-association
A State Manager association defines the state that you want to maintain on your managed nodes. AWS CLI reference
3 examples 22 options Its page in the AWS CLI reference
Examples
Example 1: To associate a document using instance IDs
The following create-association example associates a configuration document with an instance, using instance IDs.
aws ssm create-association --instance-id "i-0cb2b964d3e14fd9f" --name "AWS-UpdateSSMAgent"Identify--instance-idThe managed node ID.--nameThe name of the SSM Command document or Automation runbook that contains the configuration information for the managed node.Its output
{
"AssociationDescription": {
"Status": {
"Date": 1487875500.33,
"Message": "Associated with AWS-UpdateSSMAgent",
"Name": "Associated"
},
"Name": "AWS-UpdateSSMAgent",
"InstanceId": "i-0cb2b964d3e14fd9f",
"Overview": {
"Status": "Pending",
"DetailedStatus": "Creating"
},
"AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"DocumentVersion": "$DEFAULT",
"LastUpdateAssociationDate": 1487875500.33,
"Date": 1487875500.33,
"Targets": [
{
"Values": [
"i-0cb2b964d3e14fd9f"
],
"Key": "InstanceIds"
}
]
}
}For more information, see Creating associations in the AWS Systems Manager User Guide.
Example 2: To associate a document using targets
The following create-association example associates a configuration document with an instance, using targets.
aws ssm create-association --name "AWS-UpdateSSMAgent" --targets "Key=instanceids,Values=i-0cb2b964d3e14fd9f"Identify--nameThe name of the SSM Command document or Automation runbook that contains the configuration information for the managed node.--targetsThe targets for the association.Its output
{
"AssociationDescription": {
"Status": {
"Date": 1487875500.33,
"Message": "Associated with AWS-UpdateSSMAgent",
"Name": "Associated"
},
"Name": "AWS-UpdateSSMAgent",
"InstanceId": "i-0cb2b964d3e14fd9f",
"Overview": {
"Status": "Pending",
"DetailedStatus": "Creating"
},
"AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"DocumentVersion": "$DEFAULT",
"LastUpdateAssociationDate": 1487875500.33,
"Date": 1487875500.33,
"Targets": [
{
"Values": [
"i-0cb2b964d3e14fd9f"
],
"Key": "InstanceIds"
}
]
}
}For more information, see Creating associations in the AWS Systems Manager User Guide.
Example 3: To create an association that runs only once
The following create-association example creates a new association that only runs once on the specified date and time. Associations created with a date in the past or present (by the time it is processed the date is in the past) run immediately.
aws ssm create-association --name "AWS-UpdateSSMAgent" --targets "Key=instanceids,Values=i-0cb2b964d3e14fd9f" --schedule-expression "at(2020-05-14T15:55:00)" --apply-only-at-cron-intervalIdentify--nameThe name of the SSM Command document or Automation runbook that contains the configuration information for the managed node.--targetsThe targets for the association.--schedule-expressionA cron expression when the association will be applied to the targets.--apply-only-at-cron-intervalBy default, when you create a new association, the system runs it immediately after it is created and then according to the schedule you specified and when target changes are detected.Its output
{
"AssociationDescription": {
"Status": {
"Date": 1487875500.33,
"Message": "Associated with AWS-UpdateSSMAgent",
"Name": "Associated"
},
"Name": "AWS-UpdateSSMAgent",
"InstanceId": "i-0cb2b964d3e14fd9f",
"Overview": {
"Status": "Pending",
"DetailedStatus": "Creating"
},
"AssociationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"DocumentVersion": "$DEFAULT",
"LastUpdateAssociationDate": 1487875500.33,
"Date": 1487875500.33,
"Targets": [
{
"Values": [
"i-0cb2b964d3e14fd9f"
],
"Key": "InstanceIds"
}
]
}
}For more information, see Creating associations and Reference: Cron and rate expressions for Systems Manager in the AWS Systems Manager User Guide.
Options
--alarm-configurationThe details for the CloudWatch alarm you want to apply to an automation or command.--apply-only-at-cron-intervalBy default, when you create a new association, the system runs it immediately after it is created and then according to the schedule you specified and when target changes are detected.--association-dispatch-assume-roleA role used by association to take actions on your behalf.--association-nameSpecify a descriptive name for the association.--automation-target-parameter-nameChoose the parameter that will define how your automation will branch out.--calendar-namesThe names of Amazon Resource Names (ARNs) of the Change Calendar type documents you want to gate your associations under.--compliance-severityThe severity level to assign to the association.--document-versionThe document version you want to associate with the targets.--durationThe number of hours the association can run before it is canceled.--instance-idThe managed node ID.--max-concurrencyThe maximum number of targets allowed to run the association at the same time.--max-errorsThe number of errors that are allowed before the system stops sending requests to run the association on additional targets.--nameThe name of the SSM Command document or Automation runbook that contains the configuration information for the managed node.--output-locationAn Amazon Simple Storage Service (Amazon S3) bucket where you want to store the output details of the request.--parametersThe parameters for the runtime configuration of the document.--schedule-expressionA cron expression when the association will be applied to the targets.--schedule-offsetNumber of days to wait after the scheduled day to run an association.--sync-complianceThe mode for generating association compliance.--tagsAdds or overwrites one or more tags for a State Manager association.--target-locationsA location is a combination of Amazon Web Services Regions and Amazon Web Services accounts where you want to run the association.--target-mapsA key-value mapping of document parameters to target resources.--targetsThe targets for the association.