

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 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 中的額外參數 "Type"。

 `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`、`Lambda`、 `S3`和 `EventBridge`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*其他備註*：如果類型為 SQS/SNS 且`Destination`屬性為空白，則 SAM 會自動產生 SQS/SNS 資源。若要參考 資源，請`<function-logical-id>.DestinationQueue`針對 SQS 使用 ，或`<function-logical-id>.DestinationTopic`針對 SNS 使用 。如果類型為 Lambda/EventBridge，`Destination`則為必要項目。

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

### 使用 SQS 和 Lambda 目的地的 EventInvoke 組態範例
<a name="sam-property-function-onfailure--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations"></a>

在此範例中，SQS OnSuccess 組態不會指定目的地，因此 SAM 會隱含地建立 SQS 佇列並新增任何必要的許可。此外，在此範例中，範本檔案中宣告的 Lambda 資源目的地是在 OnFailure 組態中指定，因此 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.
```

### 使用 SNS 目的地的 EventInvoke 組態範例
<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 Resource Name (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`、`Lambda`、 `S3`和 `EventBridge`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*其他備註*：如果類型為 SQS/SNS 且`Destination`屬性為空白，則 SAM 會自動產生 SQS/SNS 資源。若要參考 資源，請`<function-logical-id>.DestinationQueue`針對 SQS 使用 ，或`<function-logical-id>.DestinationTopic`針對 SNS 使用 。如果類型為 Lambda/EventBridge，`Destination`則為必要項目。

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

### 使用 SQS 和 Lambda 目的地的 EventInvoke 組態範例
<a name="sam-property-function-onsuccess--examples--eventinvoke-configuration-example-with-sqs-and-lambda-destinations"></a>

在此範例中，SQS OnSuccess 組態不會指定目的地，因此 SAM 會隱含地建立 SQS 佇列並新增任何必要的許可。此外，在此範例中，範本檔案中宣告的 Lambda 資源目的地是在 OnFailure 組態中指定，因此 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.
```

### 使用 SNS 目的地的 EventInvoke 組態範例
<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
```