Examples: Register targets with a maintenance window
You can register a single instance as a target using its instance ID, as demonstrated in Step 2: Register a target instance with the maintenance window (AWS CLI). You can also register one or more instances as targets using the command formats on this page.
In general, there are two methods for identifying the instances you want to use as maintenance window targets: specifying individual instances, and using resource tags. The resource tags method provides more options, as shown in examples 2-3.
You can also specify one or more resource groups as the target of a maintenance window. A resource group can include instances and many other types of supported AWS resources. Examples 4 and 5, next, demonstrate how to add resource groups to your maintenance window targets.
If a single maintenance window task is registered with multiple targets, its task invocations occur sequentially and not in parallel. If your task must run on multiple targets at the same time, register a task for each target individually and assign each task the same priority level.
For more information about creating and managing resource groups, see
What is AWS Resource Groups? in the
AWS Resource Groups User Guide and Resource Groups
and Tagging for AWS
For information about limits for the Maintenance Windows capability, in addition to those specified in the following examples, see Systems Manager service quotas in the Amazon Web Services General Reference.
Example 1: Register multiple targets using instance IDs
Run the following command on your local machine format to register multiple instances as targets using their instance IDs:
Recommended use: Most useful when registering a unique group of instances with any maintenance window for the first time and they do not share a common instance tag.
Quotas: You can specify up to 50 instances total for each maintenance window target.
Example 2: Register targets using resource tags applied to instances
Run the following command on your local machine to register instances that are all already tagged with a key-value pair you have assigned:
Recommended use: Most useful when registering a unique group of instances with any maintenance window for the first time and they do share a common instance tag.
Quotas: You can specify up to five key-value pairs total for each target. If you specify more than one key-value pair, an instance must be tagged with all the tag keys and values you specify to be included in the target group.
You can tag a group of instances with the tag-key Patch Group and assign the instances a
common key value, such as my-patch-group
. Patch Manager
evaluates the Patch Group key on
instances to help determine which patch baseline applies to them. If
your task will run the AWS-RunPatchBaseline
SSM
document (or the legacy AWS-ApplyPatchBaseline
SSM document), you can specify the same Patch
Group key-value pair when you register targets with a
maintenance window. For example: --target "Key=tag:Patch
Group,Values=
.
Doing so enables you to easily use a maintenance window to update
patches on a group of instances that are already associated with the
same patch baseline. For more information, see About patch groups.
my-patch-group
Example 3: Register targets using a group of tag keys (without tag values)
Run the following command on your local machine to register instances that all have one or more tag keys assigned to them, regardless of their key values.
Recommended use: Useful when you want to target instances by specifying multiple tag keys (without their values) rather than just one tag-key or a tag key-value pair.
Quotas: You can specify up to five tag-keys total for each target. If you specify more than one tag key, an instance must be tagged with all the tag keys you specify to be included in the target group.
Example 4: Register targets using a resource group name
Run the following command on your local machine to register a specified resource group, regardless of the type of resources it contains. If the tasks you assign to the maintenance window do not act on a type of resource included in this resource group, the system might report an error. Tasks for which a supported resource type is found continue to run despite these errors.
Recommended use: Useful when you want to quickly specify a resource group as a target without evaluating whether all of its resource types will be targeted by a maintenance window, or when you know that the resource group contains only the resource types that your tasks perform actions on.
Quotas: You can specify only one resource group as a target.
Example 5: Register targets by filtering resource types in a resource group
Run the following command on your local machine to register only certain resource types that belong to a resource group that you specify. With this option, even if you add a task for a resource type that belongs to the resource group, the task won’t run if you haven’t explicitly added the resource type to the filter.
Recommended use: Useful when you want to maintain strict control over the types of AWS resources your maintenance window can run actions on, or when your resource group contains a large number of resource types and you want to avoid unnecessary error reports in your maintenance window logs.
Quotas: You can specify only one resource group as a target.