Step 2: Register a target node with the maintenance window (Amazon CLI) - Amazon Systems Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Step 2: Register a target node with the maintenance window (Amazon CLI)

In this step, you register a target with your new maintenance window. In this case, you specify which node to update when the maintenance window runs.

For an example of registering more than one node at a time using node IDs, examples of using tags to identify multiple nodes, and examples of specifying resource groups as targets, see Examples: Register targets with a maintenance window.

Note

You should already have created an Amazon Elastic Compute Cloud (Amazon EC2) instance to use in this step, as described in the Maintenance Windows tutorial prerequisites.

To register a target node with a maintenance window (Amazon CLI)

  1. Run the following command on your local machine. Replace each example resource placeholder with your own information.

    Linux & macOS
    aws ssm register-target-with-maintenance-window \ --window-id "mw-0c50858d01EXAMPLE" \ --resource-type "INSTANCE" \ --target "Key=InstanceIds,Values=i-02573cafcfEXAMPLE"
    Windows
    aws ssm register-target-with-maintenance-window ^ --window-id "mw-0c50858d01EXAMPLE" ^ --resource-type "INSTANCE" ^ --target "Key=InstanceIds,Values=i-02573cafcfEXAMPLE"

    The system returns information like the following.

    {
       "WindowTargetId":"e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE"
    }
  2. Now run the following command on your local machine to view details about your maintenance window target.

    Linux & macOS
    aws ssm describe-maintenance-window-targets \ --window-id "mw-0c50858d01EXAMPLE"
    Windows
    aws ssm describe-maintenance-window-targets ^ --window-id "mw-0c50858d01EXAMPLE"

    The system returns information like the following.

    {
        "Targets": [
            {
                "WindowId": "mw-0c50858d01EXAMPLE",
                "WindowTargetId": "e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE",
                "ResourceType": "INSTANCE",
                "Targets": [
                    {
                        "Key": "InstanceIds",
                        "Values": [
                            "i-02573cafcfEXAMPLE"
                        ]
                    }
                ]
            }
        ]
    }

Continue to Step 3: Register a task with the maintenance window (Amazon CLI).