Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . ssm ]

register-target-with-maintenance-window

Description

Registers a target with a maintenance window.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  register-target-with-maintenance-window
--window-id <value>
--resource-type <value>
--targets <value>
[--owner-information <value>]
[--name <value>]
[--description <value>]
[--client-token <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--window-id (string)

The ID of the maintenance window the target should be registered with.

--resource-type (string)

The type of target being registered with the maintenance window.

Possible values:

  • INSTANCE
  • RESOURCE_GROUP

--targets (list)

The targets to register with the maintenance window. In other words, the instances to run commands on when the maintenance window runs.

You can specify targets using instance IDs, resource group names, or tags that have been applied to instances.

Example 1 : Specify instance IDs

``Key=InstanceIds,Values=*instance-id-1* ,*instance-id-2* ,*instance-id-3* ``

Example 2 : Use tag key-pairs applied to instances

``Key=tag:my-tag-key ,Values=*my-tag-value-1* ,*my-tag-value-2* ``

Example 3 : Use tag-keys applied to instances

``Key=tag-key,Values=*my-tag-key-1* ,*my-tag-key-2* ``

Example 4 : Use resource group names

``Key=resource-groups:Name,Values=*resource-group-name* ``

Example 5 : Use filters for resource group types

``Key=resource-groups:ResourceTypeFilters,Values=*resource-type-1* ,*resource-type-2* ``

Note

For Key=resource-groups:ResourceTypeFilters , specify resource types in the following format

``Key=resource-groups:ResourceTypeFilters,Values=*AWS::EC2::INSTANCE* ,*AWS::EC2::VPC* ``

For more information about these examples formats, including the best use case for each one, see Examples: Register Targets with a Maintenance Window in the AWS Systems Manager User Guide .

Shorthand Syntax:

Key=string,Values=string,string ...

JSON Syntax:

[
  {
    "Key": "string",
    "Values": ["string", ...]
  }
  ...
]

--owner-information (string)

User-provided value that will be included in any CloudWatch events raised while running tasks for these targets in this maintenance window.

--name (string)

An optional name for the target.

--description (string)

An optional description for the target.

--client-token (string)

User-provided idempotency token.

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Examples

To register a single target with a Maintenance Window

This example registers an instance with a Maintenance Window.

Command:

aws ssm register-target-with-maintenance-window --window-id "mw-ab12cd34ef56gh78" --target "Key=InstanceIds,Values=i-0000293ffd8c57862" --owner-information "Single instance" --resource-type "INSTANCE"

Output:

{
      "WindowTargetId":"1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d-1a2"
}

To register multiple targets with a Maintenance Window

This example registers two instances with a Maintenance Window.

Command:

aws ssm register-target-with-maintenance-window --window-id "mw-ab12cd34ef56gh78" --target "Key=InstanceIds,Values=i-0000293ffd8c57862,i-0cb2b964d3e14fd9f" --owner-information "Two instances in a list" --resource-type "INSTANCE"

To register a target with a Maintenance Window using EC2 tags

This example registers an instance with a Maintenance Window using EC2 tags.

Command:

aws ssm register-target-with-maintenance-window --window-id "mw-06cf17cbefcb4bf4f" --targets "Key=tag:Environment,Values=Prod" "Key=Role,Values=Web" --owner-information "Production Web Servers" --resource-type "INSTANCE"

Output

WindowTargetId -> (string)

The ID of the target definition in this maintenance window.