

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

# `aws:executeAwsApi` - 调用并运行 AWS API 操作
<a name="automation-action-executeAwsApi"></a>

调用并运行 AWS API 操作。支持大多数 API 操作，但某些 API 操作未经过测试。不支持流式处理 API 操作，例如 [GetObject](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html) 操作。如果不确定要使用的 API 操作是否属于流式操作，请查看该服务的 [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html) 文档，判断该 API 是否需要流式输入或输出。我们会定期更新此操作使用的 Boto3 版本。但是，在新的 Boto3 版本发布后，可能需要长达几周的时间才能将更改反映到此操作中。每个 `aws:executeAwsApi` 操作最多可以运行 25 秒。有关如何使用此操作的更多示例，请参阅 [其他运行手册示例](automation-document-examples.md)。

**注意**  
`aws:executeAwsApi` 操作支持自动节流重试。有关更多信息，请参阅 [为节流的操作配置自动重试](automation-throttling-retry.md)。

**输入**  
由您选择的 API 操作定义的输入。

------
#### [ YAML ]

```
action: aws:executeAwsApi
inputs:
  Service: {{The official namespace of the service}}
  Api: {{The API operation or method name}}
  {{API operation inputs or parameters}}: {{A value}}
outputs: # {{These are user-specified outputs}}
- Name: {{The name for a user-specified output key}}
  Selector: {{A response object specified by using jsonpath format}}
  Type: {{The data type}}
```

------
#### [ JSON ]

```
{
   "action":"aws:executeAwsApi",
   "inputs":{
      "Service":"{{The official namespace of the service}}",
      "Api":"{{The API operation or method name}}",
      "{{API operation inputs or parameters}}":"{{A value}}"
   },
   "outputs":[ {{These are user-specified outputs}}
      {
         "Name":"{{The name for a user-specified output key}}",
         "Selector":"{{A response object specified by using JSONPath format}}",
         "Type":"{{The data type}}"
      }
   ]
}
```

------

服务  
包含要运行的 API 操作的 AWS 服务命名空间。您可以在 适用于 Python (Boto3) 的 AWS SDK 的[可用服务](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html)中查看支持的 AWS 服务命名空间列表。可以在**客户端**部分找到此命名空间。例如，Systems Manager 的命名空间为 `ssm`。Amazon Elastic Compute Cloud (Amazon EC2) 的命名空间为 `ec2`。  
类型：字符串  
是否必需：是

API  
要运行的 API 操作的名称。您可以在以下[服务参考](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html)页面的左侧导航栏中选择服务来查看 API 操作（也称为方法）。在要调用的服务的**客户端**部分中选择一种方法。例如，下面的 [Amazon RDS 方法](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html)页面中列出了 Amazon Relational Database Service (Amazon RDS) 的所有 API 操作（方法）。  
类型：字符串  
是否必需：是

API 操作输入  
一个或多个 API 操作输入。您可以在以下[服务参考](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html)页面的左侧导航栏中选择服务来查看可用的输入（也称为参数）。在要调用的服务的**客户端**部分中选择一种方法。例如，下面的 [Amazon RDS 方法](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html)页面中列出了 Amazon RDS 的所有方法。选择 [describe\_db\_instances](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.describe_db_instances) 方法并向下滚动以查看可用的参数，例如 **DBInstanceIdentifier**、**Name** 和 **Values**。  

```
inputs:
  Service: {{The official namespace of the service}}
  Api: {{The API operation name}}
  {{API input 1}}: {{A value}}
  {{API Input 2}}: {{A value}}
 {{ API Input 3}}: {{A value}}
```

```
"inputs":{
      "Service":"{{The official namespace of the service}}",
      "Api":"{{The API operation name}}",
      "{{API input 1}}":"{{A value}}",
      "{{API Input 2}}":"{{A value}}",
      "{{API Input 3}}":"{{A value}}"
}
```
类型：由选择的 API 操作确定  
是否必需：是

**输出**  
输出由用户根据所选 API 操作的响应指定。

名称  
输出的名称。  
类型：字符串  
是否必需：是

选择器  
响应对象中特定属性的 JSONPath。您可以在以下[服务参考](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html)页面的左侧导航栏中选择服务来查看响应对象。在要调用的服务的**客户端**部分中选择一种方法。例如，下面的 [Amazon RDS 方法](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html)页面中列出了 Amazon RDS 的所有方法：选择 [describe\_db\_instances](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.describe_db_instances) 方法，然后向下滚动到**响应结构**部分。**DBInstances** 被列为响应对象。  
类型：Integer、Boolean、String、StringList、StringMap 或 MapList  
是否必需：是

Type  
响应元素的数据类型。  
类型：可变  
是否必需：是