Step 1: Create 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 (PDF).

Step 1: Create the maintenance window (Amazon CLI)

In this step, you create a maintenance window and specify its basic options, such as name, schedule, and duration. In later steps, you choose the instance it updates and the task it runs.

In our example, you create a maintenance window that runs every five minutes. Normally, you wouldn't run a maintenance window this frequently. However, with this rate you can see your tutorial results quickly. We will show you how to change to a less frequent rate after the task has run successfully.

Note

For an explanation of how the various schedule-related options for maintenance windows relate to one another, see Maintenance window scheduling and active period options.

For more information about working with the --schedule option, see Reference: Cron and rate expressions for Systems Manager.

To create a maintenance window (Amazon CLI)
  1. Open the Amazon Command Line Interface (Amazon CLI) and run the following command on your local machine to create a maintenance window that does the following:

    • Runs every five minutes for up to two hours (as needed).

    • Prevents new tasks from starting within one hour of the end of the maintenance window operation.

    • Allows unassociated targets (instances that you haven't registered with the maintenance window).

    • Indicates through the use of custom tags that its creator intends to use it in a tutorial.

    Linux & macOS
    aws ssm create-maintenance-window \ --name "My-First-Maintenance-Window" \ --schedule "rate(5 minutes)" \ --duration 2 \ --cutoff 1 \ --allow-unassociated-targets \ --tags "Key=Purpose,Value=Tutorial"
    Windows
    aws ssm create-maintenance-window ^ --name "My-First-Maintenance-Window" ^ --schedule "rate(5 minutes)" ^ --duration 2 ^ --cutoff 1 ^ --allow-unassociated-targets ^ --tags "Key"="Purpose","Value"="Tutorial"

    The system returns information like the following.

    {
       "WindowId":"mw-0c50858d01EXAMPLE"
    }
  2. Now run the following command to view details about this and any other maintenance windows already in your account.

    aws ssm describe-maintenance-windows

    The system returns information like the following.

    {
       "WindowIdentities":[
          {
                "WindowId": "mw-0c50858d01EXAMPLE",
                "Name": "My-First-Maintenance-Window",
                "Enabled": true,
                "Duration": 2,
                "Cutoff": 1,
                "NextExecutionTime": "2019-05-11T16:46:16.991Z"
          }
       ]
    }

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