

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

# Schedule
<a name="sam-property-function-schedule"></a>

描述`Schedule`事件來源類型的物件，會將無伺服器函數設定為排程觸發的 Amazon EventBridge 規則的目標。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》中的[什麼是 Amazon EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html)。

AWS Serverless Application Model (AWS SAM) 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html) 資源。

**注意**  
EventBridge 現在提供新的排程功能：[Amazon EventBridge。 Scheduler](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)Amazon EventBridge Scheduler 是一種無伺服器排程器，可讓您從一個集中的受管服務建立、執行和管理任務。EventBridge Scheduler 可高度自訂，並提供比 EventBridge 排程規則更佳的可擴展性，具有更廣泛的目標 API 操作集和 AWS 服務。  
我們建議您使用 EventBridge 排程Scheduler叫用目標。若要在 AWS SAM 範本中定義此事件來源類型，請參閱 [ScheduleV2](sam-property-function-schedulev2.md)。

## 語法
<a name="sam-property-function-schedule-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [DeadLetterConfig](#sam-function-schedule-deadletterconfig): DeadLetterConfig
  [Description](#sam-function-schedule-description): String
  [Enabled](#sam-function-schedule-enabled): Boolean
  [Input](#sam-function-schedule-input): String
  [Name](#sam-function-schedule-name): String
  [RetryPolicy](#sam-function-schedule-retrypolicy): [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)
  [Schedule](#sam-function-schedule-schedule): String
  [State](#sam-function-schedule-state): String
```

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

 `DeadLetterConfig`   <a name="sam-function-schedule-deadletterconfig"></a>
設定在目標呼叫失敗後 EventBridge 傳送事件的 Amazon Simple Queue Service (Amazon SQS) 佇列。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型 `DeadLetterQueue`，可處理成功叫用目標 Lambda 函數後發生的失敗。這些失敗類型的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。
*類型*：[DeadLetterConfig](sam-property-function-scheduledeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `Description`   <a name="sam-function-schedule-description"></a>
規則的說明。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-description)` 屬性。

 `Enabled`   <a name="sam-function-schedule-enabled"></a>
指出系統是否已啟用規則。  
若要停用規則，請將此屬性設定為 `false`。  
指定 `Enabled`或 `State` 屬性，但不能同時指定兩者。
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。如果此屬性設定為 `true`，則 AWS SAM 傳遞 `ENABLED`，否則傳遞 `DISABLED`。

 `Input`   <a name="sam-function-schedule-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` 屬性。

 `Name`   <a name="sam-function-schedule-name"></a>
 規則的名稱。如果您未指定名稱， CloudFormation 會產生唯一的實體 ID，並將該 ID 用於規則名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name)` 屬性。

 `RetryPolicy`   <a name="sam-function-schedule-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)` 屬性。

 `Schedule`   <a name="sam-function-schedule-schedule"></a>
判斷何時及執行規則頻率的排程表達式。如需詳細資訊，請參閱[規則的排程運算式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[ScheduleExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-scheduleexpression)` 屬性。

 `State`   <a name="sam-function-schedule-state"></a>
規則的狀態。  
*接受的值：* `DISABLED | ENABLED`  
指定 `Enabled`或 `State` 屬性，但不能同時指定兩者。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。

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

### CloudWatch 排程事件
<a name="sam-property-function-schedule--examples--cloudwatch-schedule-event"></a>

CloudWatch 排程事件範例

#### YAML
<a name="sam-property-function-schedule--examples--cloudwatch-schedule-event--yaml"></a>

```
CWSchedule:
  Type: Schedule
  Properties:
    Schedule: 'rate(1 minute)'
    Name: TestSchedule
    Description: test schedule
    Enabled: false
```

# DeadLetterConfig
<a name="sam-property-function-scheduledeadletterconfig"></a>

用來指定 Amazon Simple Queue Service (Amazon SQS) 佇列的物件，其中 EventBridge 會在失敗的目標調用後傳送事件。例如，將事件傳送至不存在的 Lambda 函數時，呼叫可能會失敗，或沒有足夠的許可來叫用 Lambda 函數。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。

**注意**  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型，`DeadLetterQueue`可處理成功調用目標 Lambda 函數後發生的失敗。此類故障的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。

## 語法
<a name="sam-property-function-scheduledeadletterconfig-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Arn](#sam-function-scheduledeadletterconfig-arn): String
  [QueueLogicalId](#sam-function-scheduledeadletterconfig-queuelogicalid): String
  [Type](#sam-function-scheduledeadletterconfig-type): String
```

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

 `Arn`   <a name="sam-function-scheduledeadletterconfig-arn"></a>
指定為無效字母佇列目標之 Amazon SQS 佇列的 Amazon Resource Name (ARN)。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `DeadLetterConfig` 資料類型的 `[Arn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-deadletterconfig.html#cfn-events-rule-deadletterconfig-arn)` 屬性。

 `QueueLogicalId`   <a name="sam-function-scheduledeadletterconfig-queuelogicalid"></a>
`Type` 指定 時 AWS SAM 建立的無效字母佇列自訂名稱。  
如果未設定 `Type` 屬性，則會忽略此屬性。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-function-scheduledeadletterconfig-type"></a>
佇列的類型。設定此屬性時， AWS SAM 會自動建立無效字母佇列，並連接必要的[資源型政策](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-perms)，以授予將事件傳送至佇列的規則資源許可。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*有效值*：`SQS`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### DeadLetterConfig
<a name="sam-property-function-scheduledeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-function-scheduledeadletterconfig--examples--deadletterconfig--yaml"></a>

```
DeadLetterConfig:
  Type: SQS
  QueueLogicalId: MyDLQ
```