

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

# 对维护时段进行故障排除
<a name="troubleshooting-maintenance-windows"></a>

可以使用以下信息来帮助您对维护时段的问题进行故障排除。

**Topics**
+ [编辑任务错误：在用于编辑维护时段任务的页面上，IAM 角色列表返回以下错误消息：“We couldn't find the IAM maintenance window role specified for this task。It might have been deleted, or it might not have been created yet. (找不到为此任务指定的 IAM 维护时段角色。它可能已被删除，也可能尚未创建。)”](#maintenance-window-role-troubleshooting)
+ [并非所有维护时段目标都会被更新](#targets-not-updated)
+ [任务失败并显示任务调用状态：“The provided role does not contain the correct SSM permissions”（提供的角色不包含正确的 SSM 权限）。](#incorrect-ssm-permissions)
+ [任务失败并显示错误消息：“Step fails when it is validating and resolving the step inputs (步骤在验证和解析步骤输入时失败)”](#step-fails)
+ [错误消息：“Maintenance window tasks without targets don't support MaxConcurrency values (没有目标的维护时段任务不支持 MaxConcurrency 值)”和“Maintenance window tasks without targets don't support MaxErrors values (没有目标的维护时段任务不支持 MaxErrors 值)”](#maxconcurrency-maxerrors-not-supported)

## 编辑任务错误：在用于编辑维护时段任务的页面上，IAM 角色列表返回以下错误消息：“We couldn't find the IAM maintenance window role specified for this task。It might have been deleted, or it might not have been created yet. (找不到为此任务指定的 IAM 维护时段角色。它可能已被删除，也可能尚未创建。)”
<a name="maintenance-window-role-troubleshooting"></a>

**问题 1**：您最初指定的 AWS Identity and Access Management (IAM) 维护时段角色在您创建任务后被删除。

**可能的修复措施**：1) 选择其他 IAM 维护时段角色（如果您的账户中存在），或者新建一个角色并为任务选择该角色。

**问题 2**：如果任务是使用 AWS Command Line Interface (AWS CLI)、AWS Tools for Windows PowerShell 或 AWS 开发工具包创建的，则可能指定了不存在的 IAM 维护时段角色名称。例如，IAM 维护时段角色可能已在创建任务之前删除，或者键入的角色名称不正确，如 **myrole** 而不是 **my-role**。

**可能的修复措施**：为您要使用的 IAM 维护时段角色选择正确的名称，或者新建一个要为任务指定的角色。

## 并非所有维护时段目标都会被更新
<a name="targets-not-updated"></a>

**问题：**您注意到，维护时段任务未在维护时段设为目标的所有资源上运行。例如，在维护时段运行结果中，该资源的任务被标记为已失败或已超时。

**解决方案：**维护时段任务未在目标资源上运行的最常见原因涉及连接性和可用性。例如：
+ Systems Manager 在维护时段操作之前或期间丢失与资源的连接。
+ 在维护时段操作期间，资源处于离线或停止状态。

您可以等待下一个计划维护时段的时间在资源上运行任务。您可以在不可用或离线的资源上手动运行维护时段任务。

## 任务失败并显示任务调用状态：“The provided role does not contain the correct SSM permissions”（提供的角色不包含正确的 SSM 权限）。
<a name="incorrect-ssm-permissions"></a>

**问题**：您已为任务指定维护时段服务角色，但该任务无法成功运行，并且任务调用状态报告“The provided role does not contain the correct SSM permissions”（提供的角色不包含正确的 SSM 权限）。
+ **解决方案**：在 [任务 1：使用控制台为维护时段服务角色创建自定义策略](configuring-maintenance-window-permissions-console.md#create-custom-policy-console) 中，我们提供了一个基本策略，您可以将其附加到您的[自定义维护时段服务角色](configuring-maintenance-window-permissions-console.md#create-custom-role-console)。该策略包含许多任务方案所需的权限。但是，由于您可以运行的任务种类繁多，您可能需要在策略中为自己的维护时段角色提供其他权限。

  例如，一些 自动化 操作使用 AWS CloudFormation 堆栈。因此，您可能需要将附加权限 `cloudformation:CreateStack`、`cloudformation:DescribeStacks` 和 `cloudformation:DeleteStack` 添加到您的维护时段服务角色的策略中。

  另一个示例：自动化运行手册 `AWS-CopySnapshot` 需要权限来创建 Amazon Elastic Block Store（Amazon EBS）快照，因此，您可能需要添加权限 `ec2:CreateSnapshot`。

  有关 AWS 托管的自动化运行手册所需角色权限的信息，请参阅 [AWS Systems Manager 自动化运行手册参考](https://docs.aws.amazon.com/systems-manager-automation-runbooks/latest/userguide/automation-runbook-reference.html)中的运行手册描述。

  有关 AWS 托管的 SSM 文档所需角色权限的信息，请查看[文档](https://console.aws.amazon.com//systems-manager/documents)部分 Systems Manager 控制台中的文档内容。

  有关 Step Functions 任务、Lambda 任务以及自定义自动化运行手册和 SSM 文档所需角色权限的信息，请向这些资源的作者验证权限要求。

## 任务失败并显示错误消息：“Step fails when it is validating and resolving the step inputs (步骤在验证和解析步骤输入时失败)”
<a name="step-fails"></a>

**问题**：在任务中使用的 自动化 运行手册或 Systems Manager 命令文档要求您指定输入，例如 `InstanceId` 或 `SnapshotId`，但没有提供或未正确提供某个值。
+ **解决方案 1**：如果您的任务将单个资源（例如单个节点或单个快照）设为目标，请在任务的输入参数中输入其 ID。
+ **解决方案 2**：如果您的任务将多个资源设为目标，例如在使用运行手册 `AWS-CreateImage` 时从多个节点创建映像，您可以在输入参数中使用维护时段任务支持的伪参数之一来表示命令中的节点 ID。

  以下命令使用 AWS CLI 将 Systems Manager 自动化 任务注册到维护时段。`--targets` 值指示维护时段目标 ID。此外，即使 `--targets` 参数指定时段目标 ID，自动化运行手册的参数也会要求提供节点 ID。在这种情况下，该命令使用伪参数 `{{RESOURCE_ID}}` 作为 `InstanceId` 值。

  **AWS CLI 命令：**

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

  以下示例命令会重新启动属于 ID 为 e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE 的维护时段目标组的 Amazon Elastic Compute Cloud（Amazon EC2）实例。

  ```
  aws ssm register-task-with-maintenance-window \
      --window-id "mw-0c50858d01EXAMPLE" \
      --targets Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE \
      --task-arn "AWS-RestartEC2Instance" \
      --service-role-arn arn:aws:iam::123456789012:role/MyMaintenanceWindowServiceRole \
      --task-type AUTOMATION \
      --task-invocation-parameters "Automation={DocumentVersion=5,Parameters={InstanceId='{{RESOURCE_ID}}'}}" \
      --priority 0 --max-concurrency 10 --max-errors 5 --name "My-Restart-EC2-Instances-Automation-Task" \
      --description "Automation task to restart EC2 instances"
  ```

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

  ```
  aws ssm register-task-with-maintenance-window ^
      --window-id "mw-0c50858d01EXAMPLE" ^
      --targets Key=WindowTargetIds,Values=e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE ^
      --task-arn "AWS-RestartEC2Instance" ^
      --service-role-arn arn:aws:iam::123456789012:role/MyMaintenanceWindowServiceRole ^
      --task-type AUTOMATION ^
      --task-invocation-parameters "Automation={DocumentVersion=5,Parameters={InstanceId='{{RESOURCE_ID}}'}}" ^
      --priority 0 --max-concurrency 10 --max-errors 5 --name "My-Restart-EC2-Instances-Automation-Task" ^
      --description "Automation task to restart EC2 instances"
  ```

------

  有关使用维护时段任务的伪参数的更多信息，请参阅 [注册维护时段任务时使用伪参数](maintenance-window-tasks-pseudo-parameters.md) 和 [任务注册示例](mw-cli-register-tasks-examples.md#task-examples)。

## 错误消息：“Maintenance window tasks without targets don't support MaxConcurrency values (没有目标的维护时段任务不支持 MaxConcurrency 值)”和“Maintenance window tasks without targets don't support MaxErrors values (没有目标的维护时段任务不支持 MaxErrors 值)”
<a name="maxconcurrency-maxerrors-not-supported"></a>

**问题：**当您注册 Run Command 类型的任务时，必须指定至少一个目标，以便任务能在其上运行。对于其他任务类型（自动化、AWS Lambda 和 AWS Step Functions），根据任务的性质，目标是可选的。选项 `MaxConcurrency`（要同时运行某一任务的资源数量）和 `MaxErrors`（在任务失败之前在目标资源上运行该任务的失败次数）不是必需的，也不支持未指定目标的维护时段任务。当未指定任何任务目标时，如果为这些选项中的任何一个指定值，则系统将生成这些错误消息。

**解决方案**：如果您收到这些错误中的任何一个，请在继续注册或更新维护时段任务之前，删除并发值和错误阈值。

有关运行未指定目标的任务的更多信息，请参阅 *AWS Systems Manager 用户指南*中的 [注册不含目标的维护时段任务](maintenance-windows-targetless-tasks.md)。