

• 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:invokeLambdaFunction` – 调用 AWS Lambda 函数
<a name="automation-action-lamb"></a>

调用指定的 AWS Lambda 函数。

**注意**  
每个 `aws:invokeLambdaFunction` 操作最多可以运行 300 秒（5 分钟）。您可以通过指定 `aws:invokeLambdaFunction` 步骤的 `timeoutSeconds` 参数来限制超时。

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

**Input**  
此操作支持 Lambda 服务的大多数调用参数。有关更多信息，请参阅[调用](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html)。

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

```
name: invokeMyLambdaFunction
action: aws:invokeLambdaFunction
maxAttempts: 3
timeoutSeconds: 120
onFailure: Abort
inputs:
  FunctionName: MyLambdaFunction
```

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

```
{
    "name": "invokeMyLambdaFunction",
    "action": "aws:invokeLambdaFunction",
    "maxAttempts": 3,
    "timeoutSeconds": 120,
    "onFailure": "Abort",
    "inputs": {
        "FunctionName": "MyLambdaFunction"
    }
}
```

------

FunctionName  
Lambda 函数的名称。此函数必须存在。  
类型：字符串  
是否必需：是

限定词  
函数版本或别名。  
类型：字符串  
必需：否

InvocationType  
调用类型。默认值为 `RequestResponse`。  
类型：字符串  
有效值：`Event` \$1`RequestResponse` \$1`DryRun`  
必需：否

LogType  
如果默认值为 `Tail`，则调用类型必须是 `RequestResponse`。Lambda 返回 Lambda 函数生成的最后 4KB 日志数据，采用 base64 编码。  
类型：字符串  
有效值：`None` \$1 `Tail`  
必需：否

ClientContext  
特定于客户端的信息。  
必需：否

InputPayload  
传递给处理程序的第一个参数的 YAML 或 JSON 对象。可以使用此输入将数据传递给函数。与传统 `Payload` 输入相比，此输入提供了更大的灵活性和支持。如果为操作同时定义了 `InputPayload` 和 `Payload`，则 `InputPayload` 优先，不使用 `Payload` 值。  
类型：StringMap  
必需：否

有效载荷  
传递给处理程序的第一个参数的 JSON 字符串。这可以用于将输入数据传递给函数。我们建议使用 `InputPayload` 输入来添加功能性。  
类型：字符串  
必需：否Output

StatusCode  
HTTP 状态代码

FunctionError  
如果存在，则表明执行函数时发生错误。响应负载中包含错误详细信息。

LogResult  
Lambda 函数调用的 base64 编码日志。只有在调用类型为 `RequestResponse` 并且请求了日志时，日志才存在。

有效负载  
Lambda 函数返回的对象的 JSON 表示形式。只有在调用类型为 `RequestResponse` 时才存在有效负载。

以下是来自 `AWS-PatchInstanceWithRollback` 运行手册的部分，演示了如何引用来自 `aws:invokeLambdaFunction` 操作的输出。

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

```
- name: IdentifyRootVolume
  action: aws:invokeLambdaFunction
  inputs:
    FunctionName: "IdentifyRootVolumeLambda-{{automation:EXECUTION_ID}}"
    Payload: '{"InstanceId": "{{InstanceId}}"}'
- name: PrePatchSnapshot
  action: aws:executeAutomation
  inputs:
    DocumentName: "AWS-CreateSnapshot"
    RuntimeParameters:
      VolumeId: "{{IdentifyRootVolume.Payload}}"
      Description: "ApplyPatchBaseline restoration case contingency"
```

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

```
{
    "name": "IdentifyRootVolume",
    "action": "aws:invokeLambdaFunction",
    "inputs": {
      "FunctionName": "IdentifyRootVolumeLambda-{{automation:EXECUTION_ID}}",
      "Payload": "{\"InstanceId\": \"{{InstanceId}}\"}"
    }
  },
  {
    "name": "PrePatchSnapshot",
    "action": "aws:executeAutomation",
    "inputs": {
      "DocumentName": "AWS-CreateSnapshot",
      "RuntimeParameters": {
        "VolumeId": "{{IdentifyRootVolume.Payload}}",
        "Description": "ApplyPatchBaseline restoration case contingency"
      }
    }
  }
```

------