

• AWS Systems Manager CloudWatch 控制面板在 2026 年 4 月 30 日之后将不再可用。客户可以像现在一样继续使用 Amazon CloudWatch 控制台来查看、创建和管理其 Amazon CloudWatch 控制面板。有关更多信息，请参阅 [Amazon CloudWatch 控制面板文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

# 步骤 2：使用 AWS CLI 将目标节点注册到维护时段
<a name="mw-cli-tutorial-targets"></a>

在此步骤中，您使用新的维护时段注册目标。在这种情况下，您需指定维护时段运行时要更新的节点。

有关使用节点 ID 一次注册多个节点的示例、使用标签来标识多个节点的示例，以及将资源组指定为目标的示例，请参阅 [示例：向维护时段注册目标](mw-cli-tutorial-targets-examples.md)。

**注意**  
您应该已经创建了要在此步骤中使用的 Amazon Elastic Compute Cloud (Amazon EC2) 实例，如 [Maintenance Windows 教程先决条件](maintenance-windows-tutorials.md)中所述。

**要使用 AWS CLI 将目标节点注册到维护时段**

1. 在本地计算机上运行以下命令。将每个*示例资源占位符*替换为您自己的信息。

------
#### [ 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"
   ```

------

   系统返回类似于以下内容的信息。

   ```
   {
      "WindowTargetId":"e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE"
   }
   ```

1. 现在，在本地计算机上运行以下命令，查看有关您的维护时段目标的详细信息。

------
#### [ Linux & macOS ]

   ```
   aws ssm describe-maintenance-window-targets \
       --window-id "mw-0c50858d01EXAMPLE"
   ```

------
#### [ Windows ]

   ```
   aws ssm describe-maintenance-window-targets ^
       --window-id "mw-0c50858d01EXAMPLE"
   ```

------

   系统返回类似于以下内容的信息。

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

继续[步骤 3：使用 AWS CLI 向维护时段注册任务](mw-cli-tutorial-tasks.md)。