

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# EventInvokeConfiguration
<a name="sam-property-function-eventinvokeconfiguration"></a>

[异步](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html) Lambda 别名或版本调用的配置选项。

## 语法
<a name="sam-property-function-eventinvokeconfiguration-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-eventinvokeconfiguration-syntax.yaml"></a>

```
  [DestinationConfig](#sam-function-eventinvokeconfiguration-destinationconfig): EventInvokeDestinationConfiguration
  [MaximumEventAgeInSeconds](#sam-function-eventinvokeconfiguration-maximumeventageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-eventinvokeconfiguration-maximumretryattempts): Integer
```

## Properties
<a name="sam-property-function-eventinvokeconfiguration-properties"></a>

 `DestinationConfig`   <a name="sam-function-eventinvokeconfiguration-destinationconfig"></a>
一个配置对象，用于在 Lambda 处理事件后指定事件目的地。  
*类型*：[EventInvokeDestinationConfiguration](sam-property-function-eventinvokedestinationconfiguration.md)  
*必需*：否  
*CloudFormation 兼容性*：此属性类似于`AWS::Lambda::EventInvokeConfig`资源的`[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-destinationconfig.html)`属性。SAM 需要一个在中不存在的额外参数 “类型” CloudFormation。

 `MaximumEventAgeInSeconds`   <a name="sam-function-eventinvokeconfiguration-maximumeventageinseconds"></a>
Lambda 发送到函数以进行处理的请求的最长期限。  
*类型*：整数  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Lambda::EventInvokeConfig`资源的`[MaximumEventAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventinvokeconfig.html#cfn-lambda-eventinvokeconfig-maximumeventageinseconds)`属性。

 `MaximumRetryAttempts`   <a name="sam-function-eventinvokeconfiguration-maximumretryattempts"></a>
在函数返回错误前重试的最大次数。  
*类型*：整数  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Lambda::EventInvokeConfig`资源的`[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventinvokeconfig.html#cfn-lambda-eventinvokeconfig-maximumretryattempts)`属性。

## 示例
<a name="sam-property-function-eventinvokeconfiguration--examples"></a>

### MaximumEventAgeInSeconds
<a name="sam-property-function-eventinvokeconfiguration--examples--maximumeventageinseconds"></a>

MaximumEventAgeInSeconds 示例

#### YAML
<a name="sam-property-function-eventinvokeconfiguration--examples--maximumeventageinseconds--yaml"></a>

```
EventInvokeConfig:
  MaximumEventAgeInSeconds: 60
  MaximumRetryAttempts: 2
  DestinationConfig:
    OnSuccess:
      Type: SQS
      Destination: arn:aws:sqs:us-west-2:012345678901:my-queue
    OnFailure:
      Type: Lambda
      Destination: !GetAtt DestinationLambda.Arn
```

# EventInvokeDestinationConfiguration
<a name="sam-property-function-eventinvokedestinationconfiguration"></a>

一个配置对象，用于在 Lambda 处理事件后指定事件目的地。

## 语法
<a name="sam-property-function-eventinvokedestinationconfiguration-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-eventinvokedestinationconfiguration-syntax.yaml"></a>

```
  [OnFailure](#sam-function-eventinvokedestinationconfiguration-onfailure): OnFailure
  [OnSuccess](#sam-function-eventinvokedestinationconfiguration-onsuccess): OnSuccess
```

## Properties
<a name="sam-property-function-eventinvokedestinationconfiguration-properties"></a>

 `OnFailure`   <a name="sam-function-eventinvokedestinationconfiguration-onfailure"></a>
处理失败的事件的目的地。  
*类型*：[OnFailure](sam-property-function-onfailure.md)  
*必需*：否  
*CloudFormation 兼容性*：此属性类似于`AWS::Lambda::EventInvokeConfig`资源的`[OnFailure](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-onfailure.html)`属性。需要 `Type`（这是仅适用于 SAM 的附加属性）。

 `OnSuccess`   <a name="sam-function-eventinvokedestinationconfiguration-onsuccess"></a>
已成功处理的事件的目的地。  
*类型*：[OnSuccess](sam-property-function-onsuccess.md)  
*必需*：否  
*CloudFormation 兼容性*：此属性类似于`AWS::Lambda::EventInvokeConfig`资源的`[OnSuccess](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-onsuccess)`属性。需要 `Type`（这是仅适用于 SAM 的附加属性）。

## 示例
<a name="sam-property-function-eventinvokedestinationconfiguration--examples"></a>

### OnSuccess
<a name="sam-property-function-eventinvokedestinationconfiguration--examples--onsuccess"></a>

OnSuccess 示例

#### YAML
<a name="sam-property-function-eventinvokedestinationconfiguration--examples--onsuccess--yaml"></a>

```
EventInvokeConfig:
  DestinationConfig:
    OnSuccess:
      Type: SQS
      Destination: arn:aws:sqs:us-west-2:012345678901:my-queue
    OnFailure:
      Type: Lambda
      Destination: !GetAtt DestinationLambda.Arn
```

# OnFailure
<a name="sam-property-function-onfailure"></a>

处理失败的事件的目的地。

## 语法
<a name="sam-property-function-onfailure-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-onfailure-syntax.yaml"></a>

```
  [Destination](#sam-function-onfailure-destination): String
  [Type](#sam-function-onfailure-type): String
```

## Properties
<a name="sam-property-function-onfailure-properties"></a>

 `Destination`   <a name="sam-function-onfailure-destination"></a>
目标资源的 Amazon Resource Name (ARN)。  
*类型*：字符串  
*必需*：条件  
*CloudFormation 兼容性*：此属性类似于`AWS::Lambda::EventInvokeConfig`资源的`[OnFailure](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-onfailure.html)`属性。SAM 将向与该函数关联的自动生成的 IAM 角色添加任何必要的权限，以访问此属性中引用的资源。  
*其他说明*：如果类型为 Lambda/EventBridge，则必须填写目的地。

 `Type`   <a name="sam-function-onfailure-type"></a>
目标中引用的资源类型。支持的类型有 `SQS`、`SNS`、`S3`、`Lambda` 和 `EventBridge`。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。  
*其他说明*：如果类型为 SQS/SNS 且`Destination`属性留空，则 SQS/SNS 资源由 SAM 自动生成。要引用该资源，请使用 `<function-logical-id>.DestinationQueue`（对于 SQS）或 `<function-logical-id>.DestinationTopic`（对于 SQS）。如果类型为 Lambda/EventBridge，`Destination`则为必填项。

## 示例
<a name="sam-property-function-onfailure--examples"></a>

### EventInvoke 包含 SQS 和 Lambda 目标的配置示例
<a name="sam-property-function-onfailure--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations"></a>

在此示例中，没有给出 SQS OnSuccess 配置的目标，因此 SAM 隐式创建了一个 SQS 队列并添加了所有必要的权限。同样在本示例中，在 OnFailure 配置中指定了在模板文件中声明的 Lambda 资源的目标，因此 SAM 向此 Lambda 函数添加了调用目标 Lambda 函数所需的权限。

#### YAML
<a name="sam-property-function-onfailure--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations--yaml"></a>

```
EventInvokeConfig:
  DestinationConfig:
    OnSuccess:
      Type: SQS
    OnFailure:
      Type: Lambda
      Destination: !GetAtt DestinationLambda.Arn  # Arn of a Lambda function declared in the template file.
```

### EventInvoke 带有 SNS 目标的配置示例
<a name="sam-property-function-onfailure--examples--eventinvoke-configuration-example-with-sns-destination"></a>

在此示例中，为在 OnSuccess 配置的模板文件中声明的 SNS 主题提供了一个目标。

#### YAML
<a name="sam-property-function-onfailure--examples--eventinvoke-configuration-example-with-sns-destination--yaml"></a>

```
EventInvokeConfig:
  DestinationConfig:
    OnSuccess:
      Type: SNS
      Destination:
        Ref: DestinationSNS       # Arn of an SNS topic declared in the tempate file
```

# OnSuccess
<a name="sam-property-function-onsuccess"></a>

已成功处理的事件的目的地。

## 语法
<a name="sam-property-function-onsuccess-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-onsuccess-syntax.yaml"></a>

```
  [Destination](#sam-function-onsuccess-destination): String
  [Type](#sam-function-onsuccess-type): String
```

## Properties
<a name="sam-property-function-onsuccess-properties"></a>

 `Destination`   <a name="sam-function-onsuccess-destination"></a>
目标资源的 Amazon 资源名称（ARN）。  
*类型*：字符串  
*必需*：条件  
*CloudFormation 兼容性*：此属性类似于`AWS::Lambda::EventInvokeConfig`资源的`[OnSuccess](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-onsuccess)`属性。SAM 将向与该函数关联的自动生成的 IAM 角色添加任何必要的权限，以访问此属性中引用的资源。  
*其他说明*：如果类型为 Lambda/EventBridge，则必须填写目的地。

 `Type`   <a name="sam-function-onsuccess-type"></a>
目标中引用的资源类型。支持的类型有 `SQS`、`SNS`、`S3`、`Lambda` 和 `EventBridge`。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。  
*其他说明*：如果类型为 SQS/SNS 且`Destination`属性留空，则 SQS/SNS 资源由 SAM 自动生成。要引用该资源，请使用 `<function-logical-id>.DestinationQueue`（对于 SQS）或 `<function-logical-id>.DestinationTopic`（对于 SQS）。如果类型为 Lambda/EventBridge，`Destination`则为必填项。

## 示例
<a name="sam-property-function-onsuccess--examples"></a>

### EventInvoke 包含 SQS 和 Lambda 目标的配置示例
<a name="sam-property-function-onsuccess--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations"></a>

在此示例中，没有给出 SQS OnSuccess 配置的目标，因此 SAM 隐式创建了一个 SQS 队列并添加了所有必要的权限。同样在本示例中，在 OnFailure 配置中指定了在模板文件中声明的 Lambda 资源的目标，因此 SAM 向此 Lambda 函数添加了调用目标 Lambda 函数所需的权限。

#### YAML
<a name="sam-property-function-onsuccess--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations--yaml"></a>

```
EventInvokeConfig:
  DestinationConfig:
    OnSuccess:
      Type: SQS
    OnFailure:
      Type: Lambda
      Destination: !GetAtt DestinationLambda.Arn  # Arn of a Lambda function declared in the template file.
```

### EventInvoke 带有 SNS 目标的配置示例
<a name="sam-property-function-onsuccess--examples--eventinvoke-configuration-example-with-sns-destination"></a>

在此示例中，为在 OnSuccess 配置的模板文件中声明的 SNS 主题提供了一个目标。

#### YAML
<a name="sam-property-function-onsuccess--examples--eventinvoke-configuration-example-with-sns-destination--yaml"></a>

```
EventInvokeConfig:
  DestinationConfig:
    OnSuccess:
      Type: SNS
      Destination:
        Ref: DestinationSNS       # Arn of an SNS topic declared in the tempate file
```