

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

# AWS SAM 範本
<a name="sam-specification"></a>

在您執行 **sam init**命令並完成其後續工作流程後， 會 AWS SAM 建立您的應用程式專案目錄，也就是您的 AWS SAM 專案。您可以透過將程式碼新增至 AWS SAM 專案來定義無伺服器應用程式。雖然您的 AWS SAM 專案包含一組檔案和資料夾，但您主要使用的檔案是您的 AWS SAM 範本 （名為 `template.yaml`)。在此範本中，您會撰寫程式碼來表達資源、事件來源映射，以及其他定義無伺服器應用程式的屬性。

**注意**  
 AWS SAM 範本的關鍵元素是 AWS SAM 範本規格。此規格提供短期語法，相較於 CloudFormation， 可讓您使用較少的程式碼行來定義無伺服器應用程式的資源、事件來源映射、許可、APIs 和其他屬性。

本節提供如何使用 AWS SAM 範本中的區段來定義資源類型、資源屬性、資料類型、資源屬性、內部函數和 API Gateway 延伸的詳細資訊。

AWS SAM 範本是 CloudFormation 範本的延伸，具有唯一的語法類型，使用比較少行程式碼的速記語法 CloudFormation。這可在建置無伺服器應用程式時加速您的開發。如需詳細資訊，請參閱 [AWS SAM 資源和屬性](sam-specification-resources-and-properties.md)。如需 CloudFormation 範本的完整參考，請參閱*AWS CloudFormation 《 使用者指南*》中的[CloudFormation 範本參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-reference.html)。

開發時，您通常會發現將應用程式程式碼分成不同的檔案，以便更好地組織和管理應用程式。其中一個基本範例是為 AWS Lambda 函數程式碼使用單獨的檔案，而不是在 AWS SAM 範本中擁有此程式碼。做法是在專案的子目錄中組織 Lambda 函數程式碼，並在您的 AWS Serverless Application Model (AWS SAM) 範本中參考其本機路徑。

**Topics**
+ [AWS SAM 範本結構](sam-specification-template-anatomy.md)
+ [AWS SAM 資源和屬性](sam-specification-resources-and-properties.md)
+ [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)
+ [支援的資源屬性 AWS SAM](sam-specification-resource-attributes.md)
+ [的 API Gateway 擴充功能 AWS SAM](sam-specification-api-gateway-extensions.md)
+ [的內部 函數 AWS SAM](sam-specification-intrinsic-functions.md)

# AWS SAM 範本結構
<a name="sam-specification-template-anatomy"></a>

 AWS SAM 範本檔案嚴格遵循 CloudFormation 範本檔案的格式，如*AWS CloudFormation 《 使用者指南*》中的[範本結構](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)所述。 AWS SAM 範本檔案和 CloudFormation 範本檔案的主要差異如下：
+ **轉換宣告。**範本檔案`Transform: AWS::Serverless-2016-10-31`需要 AWS SAM 宣告。此宣告會將 CloudFormation 範本檔案識別為 AWS SAM 範本檔案。如需轉換的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html)。
+ **全域區段。**`Globals` 區段對 是唯一的 AWS SAM。它定義了所有無伺服器函數和 APIs屬性。所有 `AWS::Serverless::Function`、`AWS::Serverless::Api`、`AWS::Serverless::CapacityProvider`、`AWS::Serverless::SimpleTable`、 `AWS::Serverless::HttpApi`和 `AWS::Serverless::StateMachine` 資源都會繼承 `Globals`區段中定義的屬性。如需本節的詳細資訊，請參閱 [AWS SAM 範本的全域區段](sam-specification-template-anatomy-globals.md)。
+ **資源區段。**在 AWS SAM 範本中， `Resources`區段可以包含 CloudFormation 資源和資源的組合 AWS SAM 。如需 CloudFormation 資源的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。如需 AWS SAM 資源的詳細資訊，請參閱 [AWS SAM 資源和屬性](sam-specification-resources-and-properties.md)。

 AWS SAM 範本檔案的所有其他區段對應至相同名稱的 CloudFormation 範本檔案區段。

## YAML
<a name="template-anatomy-outline.yaml"></a>

下列範例顯示 YAML 格式的範本片段。

```
Transform: AWS::Serverless-2016-10-31

Globals:
  set of globals

Description:
  String

Metadata:
  template metadata

Parameters:
  set of parameters

Mappings:
  set of mappings

Conditions:
  set of conditions

Resources:
  set of resources

Outputs:
  set of outputs
```

## 範本區段
<a name="template-anatomy-sections"></a>

AWS SAM 範本可以包含數個主要區段。只需要 `Transform`和 `Resources`區段。

您可以按任何順序包含範本區段。不過，如果使用語言延伸模組，您應該在無伺服器轉換`AWS::LanguageExtensions`*之前*新增 （也就是在 之前`AWS::Serverless-2016-10-31`)，如下列範例所示：

```
Transform:
  - AWS::LanguageExtensions
  - AWS::Serverless-2016-10-31
```

當您建置範本時，使用下列清單中顯示的邏輯順序可能會有所幫助。這是因為一個區段中的值可能參照上一個區段的值。

**[轉換 （必要）](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html)**  
對於 AWS SAM 範本，您必須包含此區段的值為 `AWS::Serverless-2016-10-31`。  
其他轉換是選用的。如需轉換的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html)。

**[全域 （選用）](sam-specification-template-anatomy-globals.md)**  
所有無伺服器函數、APIs屬性。所有 `AWS::Serverless::Function`、`AWS::Serverless::Api`、`AWS::Serverless::CapacityProvider`、`AWS::Serverless::SimpleTable`、 `AWS::Serverless::HttpApi`和 `AWS::Serverless::StateMachine` 資源都會繼承 `Globals`區段中定義的屬性。  
本節對 是唯一的 AWS SAM。 CloudFormation 範本中沒有對應的區段。

**[描述 (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-description-structure.html)**  
說明範本的文字字串。  
本節直接對應至 CloudFormation 範本的 `Description`區段。

**[Metadata (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html)**  
提供範本其他資訊的物件。  
本節直接對應至 CloudFormation 範本的 `Metadata`區段。

**[Parameters (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html)**  
要在執行時間傳遞至您範本的值 (當您建立或更新堆疊時)。您可以參照範本之 `Resources` 和 `Outputs` 區段中的參數。在 `Parameters`區段中宣告的物件會導致 **sam deploy --guided**命令向使用者顯示其他提示。  
使用 `sam deploy`命令的 `--parameter-overrides` 參數以及組態檔案中的項目傳入的值，優先於範本檔案中的項目 AWS SAM 。如需 `sam deploy`命令的詳細資訊，請參閱 命令參考[sam deploy](sam-cli-command-reference-sam-deploy.md)中的 AWS SAM CLI 。如需組態檔案的詳細資訊，請參閱 [AWS SAM CLI 組態檔案](serverless-sam-cli-config.md)。

**[Mappings (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html)**  
可用來指定條件式參數值之索引鍵與相關聯值的映射，與查詢表格類似。您可以使用 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html) `Resources`和 `Outputs`區段中的內部 函數，將索引鍵與對應的值進行比對。  
本節直接對應至 CloudFormation 範本的 `Mappings`區段。

**[Conditions (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html)**  
條件，控制是否建立特定資源，或是否在建立或更新堆疊期間指派特定資源屬性的值。例如，您可以有條件地建立資源，取決於堆疊適用於生產還是測試環境。  
本節直接對應至 CloudFormation 範本的 `Conditions`區段。

**[Resources (必要)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html)**  
堆疊資源及其屬性，例如 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體或 Amazon Simple Storage Service (Amazon S3) 儲存貯體。您可以參照範本之 `Resources` 和 `Outputs` 區段中的資源。  
本節類似於 範本的 CloudFormation `Resources`區段。在 AWS SAM 範本中，除了 AWS SAM 資源之外，本節還可以包含 CloudFormation 資源。

**[Outputs (選用)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html)**  
每次檢視堆疊屬性時傳回的值。例如，您可以宣告 S3 儲存貯體名稱的輸出，然後呼叫 `aws cloudformation describe-stacks` AWS Command Line Interface (AWS CLI) 命令來檢視名稱。  
本節直接對應至 CloudFormation 範本的 `Outputs`區段。

## 後續步驟
<a name="template-anatomy-next-steps"></a>

若要下載和部署包含 AWS SAM 範本檔案的範例無伺服器應用程式，請參閱 [入門 AWS SAM](serverless-getting-started.md) 並遵循 中的指示[教學課程：使用 部署 Hello World 應用程式 AWS SAM](serverless-getting-started-hello-world.md)。

# AWS SAM 範本的全域區段
<a name="sam-specification-template-anatomy-globals"></a>

有時，您在 AWS SAM 範本中宣告的資源具有常見的組態。例如，您可能有一個應用程式，其中包含多個具有相同 `Runtime`、`Memory`、`VPCConfig`、 `Environment`和 `Cors`組態`AWS::Serverless::Function`的資源。您可以在 `Globals`區段中宣告一次，並讓資源繼承這些資訊，而不是在每個資源中複製此資訊。

`Globals` 本節支援下列 AWS SAM 資源類型：
+ `AWS::Serverless::Api`
+ `AWS::Serverless::CapacityProvider`
+ `AWS::Serverless::Function`
+ `AWS::Serverless::HttpApi`
+ `AWS::Serverless::SimpleTable`
+ `AWS::Serverless::StateMachine`

範例：

```
Globals:
  Function:
    Runtime: nodejs12.x
    Timeout: 180
    Handler: index.handler
    Environment:
      Variables:
        TABLE_NAME: data-table

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          MESSAGE: "Hello From SAM"

  ThumbnailFunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        Thumbnail:
          Type: Api
          Properties:
            Path: /thumbnail
            Method: POST
```

在此範例中， `HelloWorldFunction`和 都會針對 `ThumbnailFunction`使用「nodejs12.x」`Runtime`、針對 使用「180」秒`Timeout`，以及針對 使用「index.handler」`Handler`。 除了繼承的 TABLE\$1NAME 之外， 還會`HelloWorldFunction`新增 MESSAGE 環境變數。 會`ThumbnailFunction`繼承所有`Globals`屬性並新增 API 事件來源。

## 支援的資源和屬性
<a name="sam-specification-template-anatomy-globals-supported-resources-and-properties"></a>

AWS SAM 支援下列資源和屬性。

```
Globals:
  Api:
    AccessLogSetting:
    Auth:
    BinaryMediaTypes:
    CacheClusterEnabled:
    CacheClusterSize:
    CanarySetting:
    Cors:
    DefinitionUri:
    Domain:
    EndpointConfiguration:
    GatewayResponses:
    MethodSettings:
    MinimumCompressionSize:
    Name:
    OpenApiVersion:
    PropagateTags:
    TracingEnabled:
    Variables:
  
  CapacityProvider:
    InstanceRequirements:
    KmsKeyArn:
    OperatorRole:
    PropagateTags:
    ScalingConfig:
    Tags:
    VpcConfig:
  
  Function:
    Architectures:
    AssumeRolePolicyDocument:
    AutoPublishAlias:
    AutoPublishAliasAllProperties:
    CapacityProviderConfig:
    CodeSigningConfigArn:
    CodeUri:
    DeadLetterQueue:
    DeploymentPreference:
    Description:
    DurableConfig:
    Environment:
    EphemeralStorage:
    EventInvokeConfig:
    FileSystemConfigs:
    FunctionScalingConfig:
    FunctionUrlConfig:
    Handler:
    KmsKeyArn:
    Layers:
    LoggingConfig:
    MemorySize:
    PermissionsBoundary:
    PropagateTags:
    ProvisionedConcurrencyConfig:
    PublishToLatestPublished:
    RecursiveLoop:
    ReservedConcurrentExecutions:
    RolePath:
    Runtime:
    RuntimeManagementConfig:
    SnapStart:
    SourceKMSKeyArn:
    Tags:
    TenancyConfig:
    Timeout:
    Tracing:
    VersionDeletionPolicy:
    VpcConfig:

  HttpApi:
    AccessLogSettings:
    Auth:
    PropagateTags:
    StageVariables:
    Tags:

  SimpleTable:
    SSESpecification:
    
  StateMachine:
    PropagateTags:
```

**注意**  
不支援任何未包含在上一個清單中的資源和屬性。不支援它們的一些原因包括：1) 它們開啟了潛在的安全問題，或 2) 它們使範本難以理解。

## 隱含 APIs
<a name="sam-specification-template-anatomy-globals-implicit-apis"></a>

AWS SAM 當您在 `Events`區段中宣告 * APIs 時， 會建立隱含* API。您可以使用 `Globals`覆寫隱含 APIs 的所有屬性。

## 可覆寫的屬性
<a name="sam-specification-template-anatomy-globals-overrideable"></a>

資源可以覆寫您在 `Globals`區段中宣告的屬性。例如，您可以將新變數新增至環境變數映射，也可以覆寫全域宣告的變數。但是資源無法移除 `Globals`區段中指定的屬性。

一般而言， `Globals`區段會宣告所有資源共用的屬性。有些資源可以為全域宣告的屬性提供新值，但無法將其移除。如果某些資源使用屬性，但其他資源不使用，則不得在 `Globals`區段中宣告它們。

下列各節說明覆寫對不同資料類型的運作方式。

### 取代基本資料類型
<a name="sam-specification-template-anatomy-globals-overrideable-primitives"></a>

基本資料類型包括字串、數字、布林值等。

`Resources` 區段中指定的值會取代`Globals`區段中的值。

範例：

```
Globals:
  Function:
    Runtime: nodejs12.x

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: python3.9
```

`Runtime` 的 `MyFunction`設定為 `python3.9`。

### 映射已合併
<a name="sam-specification-template-anatomy-globals-overrideable-maps"></a>

映射也稱為字典或索引鍵/值對的集合。

`Resources` 區段中的映射項目會與全域映射項目合併。如果有重複項目，`Resource`區段項目會覆寫`Globals`區段項目。

範例：

```
Globals:
  Function:
    Environment:
      Variables:
        STAGE: Production
        TABLE_NAME: global-table

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          TABLE_NAME: resource-table
          NEW_VAR: hello
```

的環境變數`MyFunction`設定為下列：

```
{
  "STAGE": "Production",
  "TABLE_NAME": "resource-table",
  "NEW_VAR": "hello"
}
```

### 清單是附加項目
<a name="sam-specification-template-anatomy-globals-overrideable-lists"></a>

清單也稱為陣列。

`Globals` 區段中的清單項目會附加至`Resources`區段中的清單。

範例：

```
Globals:
  Function:
    VpcConfig:
      SecurityGroupIds:
        - sg-123
        - sg-456

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      VpcConfig:
        SecurityGroupIds:
          - sg-first
```

`SecurityGroupIds` `MyFunction`的 `VpcConfig`設定為下列項目：

```
[ "sg-123", "sg-456", "sg-first" ]
```

# AWS SAM 資源和屬性
<a name="sam-specification-resources-and-properties"></a>

本節說明特定的資源和屬性類型 AWS SAM。您可以使用 AWS SAM 速記語法定義這些資源和屬性。 AWS SAM 也支援 CloudFormation 資源和屬性類型。如需所有 AWS 資源和屬性類型 CloudFormation 和 AWS SAM 支援的參考資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。

**Topics**
+ [AWS::Serverless::Api](sam-resource-api.md)
+ [AWS::Serverless::Application](sam-resource-application.md)
+ [AWS::Serverless::CapacityProvider](sam-resource-capacityprovider.md)
+ [AWS::Serverless::Connector](sam-resource-connector.md)
+ [AWS::Serverless::Function](sam-resource-function.md)
+ [AWS::Serverless::GraphQLApi](sam-resource-graphqlapi.md)
+ [AWS::Serverless::HttpApi](sam-resource-httpapi.md)
+ [AWS::Serverless::LayerVersion](sam-resource-layerversion.md)
+ [AWS::Serverless::SimpleTable](sam-resource-simpletable.md)
+ [AWS::Serverless::StateMachine](sam-resource-statemachine.md)

# AWS::Serverless::Api
<a name="sam-resource-api"></a>

建立可透過 HTTPS 端點叫用之 Amazon API Gateway 資源和方法的集合。

資源[AWS::Serverless::Api](#sam-resource-api)不需要明確新增至無 AWS 伺服器應用程式定義範本。此類型的資源是從在範本中未參考 [AWS::Serverless::Api](#sam-resource-api) 資源所定義[AWS::Serverless::Function](sam-resource-function.md)資源上定義的 Api 事件聯集隱含建立的。

應使用 [AWS::Serverless::Api](#sam-resource-api) 資源來定義和記錄使用 OpenApi 的 API，以便更能夠設定基礎 Amazon API Gateway 資源。

我們建議您使用 CloudFormation 勾點或 IAM 政策來驗證 API Gateway 資源是否已連接授權方，以控制對它們的存取。

如需使用 CloudFormation 勾點的詳細資訊，請參閱 *CloudFormation CLI 使用者指南*中的[註冊勾點](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/registering-hook-python.html)和 [apigw-enforce-authorizer](https://github.com/aws-cloudformation/aws-cloudformation-samples/tree/main/hooks/python-hooks/apigw-enforce-authorizer/) GitHub 儲存庫。

如需使用 IAM 政策的詳細資訊，請參閱[《 API Gateway 開發人員指南》中的要求 API 路由具有授權](https://docs.aws.amazon.com/apigateway/latest/developerguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-require-authorization)。 **

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-api-syntax"></a>

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

### YAML
<a name="sam-resource-api-syntax.yaml"></a>

```
Type: AWS::Serverless::Api
Properties:
  [AccessLogSetting](#sam-api-accesslogsetting): [AccessLogSetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-accesslogsetting)
  AlwaysDeploy: Boolean
  [ApiKeySourceType](#sam-api-apikeysourcetype): String
  [Auth](#sam-api-auth): ApiAuth
  [BinaryMediaTypes](#sam-api-binarymediatypes): List
  [CacheClusterEnabled](#sam-api-cacheclusterenabled): Boolean
  [CacheClusterSize](#sam-api-cacheclustersize): String
  [CanarySetting](#sam-api-canarysetting): [CanarySetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-canarysetting)
  [Cors](#sam-api-cors): String | CorsConfiguration
  [DefinitionBody](#sam-api-definitionbody): JSON
  [DefinitionUri](#sam-api-definitionuri): String | ApiDefinition
  [Description](#sam-api-description): String
  [DisableExecuteApiEndpoint](#sam-api-disableexecuteapiendpoint): Boolean
  [Domain](#sam-api-domain): DomainConfiguration
  [EndpointConfiguration](#sam-api-endpointconfiguration): EndpointConfiguration
  [FailOnWarnings](#sam-api-failonwarnings): Boolean
  [GatewayResponses](#sam-api-gatewayresponses): Map
  MergeDefinitions: Boolean
  [MethodSettings](#sam-api-methodsettings): MethodSettings
  [MinimumCompressionSize](#sam-api-minimumcompressionsize): Integer
  [Mode](#sam-api-mode): String
  [Models](#sam-api-models): Map
  [Name](#sam-api-name): String
  [OpenApiVersion](#sam-api-openapiversion): String
  PropagateTags: Boolean
  [Policy](#sam-api-policy): JSON
  [StageName](#sam-api-stagename): String
  [Tags](#sam-api-tags): Map
  [TracingEnabled](#sam-api-tracingenabled): Boolean
  [Variables](#sam-api-variables): Map
```

## Properties
<a name="sam-resource-api-properties"></a>

 `AccessLogSetting`   <a name="sam-api-accesslogsetting"></a>
設定階段的存取日誌設定。  
*類型*：[AccessLogSetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-accesslogsetting)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[AccessLogSetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-accesslogsetting)` 屬性。

 `AlwaysDeploy`   <a name="sam-api-alwaysdeploy"></a>
即使未偵測到 API 的變更，也一律部署 API。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ApiKeySourceType`   <a name="sam-api-apikeysourcetype"></a>
根據用量計畫進行量測請求的 API 金鑰來源，有效值為 `HEADER` 和 `AUTHORIZER`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[ApiKeySourceType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-apikeysourcetype)` 屬性。

 `Auth`   <a name="sam-api-auth"></a>
設定授權以控制對 API Gateway API 的存取。  
如需使用 設定存取權的詳細資訊， AWS SAM 請參閱 [使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。如需示範如何覆寫全域授權方的範例，請參閱 [覆寫 Amazon API Gateway REST API 的全域授權方](sam-property-function-apifunctionauth.md#sam-property-function-apifunctionauth--examples--override)。  
*類型*：[ApiAuth](sam-property-api-apiauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `BinaryMediaTypes`   <a name="sam-api-binarymediatypes"></a>
您的 API 可能傳回的 MIME 類型清單。使用此項目可啟用 APIs 的二進位支援。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::RestApi` 資源的 `[BinaryMediaTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-binarymediatypes)` 屬性。BinaryMediaTypes 的清單會同時新增至 CloudFormation 資源和 OpenAPI 文件。

 `CacheClusterEnabled`   <a name="sam-api-cacheclusterenabled"></a>
指出是否已為階段啟用快取。若要快取回應，您還必須在 `true`下`CachingEnabled`將 設定為 `MethodSettings`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[CacheClusterEnabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-cacheclusterenabled)` 屬性。

 `CacheClusterSize`   <a name="sam-api-cacheclustersize"></a>
階段的快取叢集大小。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[CacheClusterSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-cacheclustersize)` 屬性。

 `CanarySetting`   <a name="sam-api-canarysetting"></a>
將 Canary 設定設定為一般部署的階段。  
*類型*：[CanarySetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-canarysetting)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[CanarySetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-canarysetting)` 屬性。

 `Cors`   <a name="sam-api-cors"></a>
管理所有 API Gateway APIs 的跨來源資源共用 (CORS)。指定要允許做為字串的網域，或指定具有其他 Cors 組態的字典。  
CORS 需要 AWS SAM 修改您的 OpenAPI 定義。在 中建立內嵌 OpenAPI 定義`DefinitionBody`以開啟 CORS。
如需 CORS 的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的為 API Gateway REST API 資源啟用 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html)。 **  
*類型*：字串 \$1 [CorsConfiguration](sam-property-api-corsconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `DefinitionBody`   <a name="sam-api-definitionbody"></a>
描述 API 的 OpenAPI 規格。如果既未指定`DefinitionUri`也`DefinitionBody`未指定，SAM 會根據範本組態`DefinitionBody`為您產生 。  
若要參考定義 API 的本機OpenAPI檔案，請使用 `AWS::Include`轉換。如需詳細資訊，請參閱 [如何 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
*類型*：JSON  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::RestApi` 資源的 `[Body](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body)` 屬性。如果提供特定屬性，內容可能會在傳遞至 CloudFormation 之前插入或修改至 DefinitionBody。屬性包括 `Auth`、`BinaryMediaTypes`、`Models`、、`Cors``GatewayResponses`，以及對應 `EventSource`的 Api 類型 `AWS::Serverless::Function`。

 `DefinitionUri`   <a name="sam-api-definitionuri"></a>
定義 API 之 OpenAPI 文件的 Amazon S3 Uri、本機檔案路徑或位置物件。此屬性參考的 Amazon S3 物件必須是有效的 OpenAPI 檔案。如果既未指定`DefinitionUri`也`DefinitionBody`未指定，SAM 會根據範本組態`DefinitionBody`為您產生 。  
如果提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換定義。  
參考的外部 OpenApi 檔案不支援內部函數`DefinitionUri`。使用 `DefinitionBody` 屬性搭配[包含轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/create-reusable-transform-function-snippets-and-add-to-your-template-with-aws-include-transform.html)，將 OpenApi 定義匯入範本。  
*類型*：字串 \$1 [ApiDefinition](sam-property-api-apidefinition.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::RestApi` 資源的 `[BodyS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-bodys3location)` 屬性。巢狀 Amazon S3 屬性的名稱不同。

 `Description`   <a name="sam-api-description"></a>
Api 資源的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-description)` 屬性。

 `DisableExecuteApiEndpoint`   <a name="sam-api-disableexecuteapiendpoint"></a>
指定用戶端是否可以使用預設 `execute-api` 端點叫用您的 API。根據預設，用戶端可以使用預設的 叫用您的 API`https://{api_id}.execute-api.{region}.amazonaws.com`。如要要求用戶端使用自訂網域名稱來叫用 API，請指定 `True`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::RestApi` 資源的 `[ DisableExecuteApiEndpoint](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-disableexecuteapiendpoint)` 屬性。它會直接傳遞至 `[ x-amazon-apigateway-endpoint-configuration](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html)`延伸的 `disableExecuteApiEndpoint` 屬性，該延伸會新增至 `AWS::ApiGateway::RestApi` 資源的 ` [ Body](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body)` 屬性。

 `Domain`   <a name="sam-api-domain"></a>
設定此 API Gateway API 的自訂網域。  
*類型*：[DomainConfiguration](sam-property-api-domainconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `EndpointConfiguration`   <a name="sam-api-endpointconfiguration"></a>
REST API 的端點類型。  
*類型*：[EndpointConfiguration](sam-property-api-endpointconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::RestApi` 資源的 `[EndpointConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-endpointconfiguration)` 屬性。巢狀組態屬性的名稱不同。

 `FailOnWarnings`   <a name="sam-api-failonwarnings"></a>
指定在遇到警告時是否要轉返 API 建立 (`true`) 與否 (`false`)。預設值為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[FailOnWarnings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-failonwarnings)` 屬性。

 `GatewayResponses`   <a name="sam-api-gatewayresponses"></a>
設定 API 的閘道回應。Gateway 回應是由 API Gateway 直接或透過使用 Lambda 授權方傳回的回應。如需詳細資訊，請參閱適用於[閘道回應的 Api Gateway OpenApi 擴充功能](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.html)文件。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `MergeDefinitions`   <a name="sam-api-mergedefinitions"></a>
AWS SAM 會從 API 事件來源產生OpenAPI規格。指定 AWS SAM `true`讓 將此合併到 `AWS::Serverless::Api` 資源中定義的內嵌OpenAPI規格。指定 `false`不合併。  
`MergeDefinitions` 需要`AWS::Serverless::Api`定義 的 `DefinitionBody` 屬性。 `MergeDefinitions` 與 的 `DefinitionUri` 屬性不相容`AWS::Serverless::Api`。  
*預設值*：`false`  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `MethodSettings`   <a name="sam-api-methodsettings"></a>
設定 API 階段的所有設定，包括記錄、指標、CacheTTL、調節。  
*類型*：[MethodSetting](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-stage-methodsetting.html) 的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[MethodSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-methodsettings)` 屬性。

 `MinimumCompressionSize`   <a name="sam-api-minimumcompressionsize"></a>
允許根據用戶端的 Accept-Encoding 標頭壓縮回應內文。當回應內文大小大於或等於您設定的閾值時，就會觸發壓縮。主體大小閾值上限為 10 MB (10，485，760 個位元組）。- 支援下列壓縮類型：gzip、deflate 和 identity。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[MinimumCompressionSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-minimumcompressionsize)` 屬性。

 `Mode`   <a name="sam-api-mode"></a>
只有當您使用 OpenAPI 定義 REST API 時，才會套用此屬性。`Mode` 可判定 API Gateway 如何處理資源更新。如需詳細資訊，請參閱 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html) 資源類型的[模式](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-mode)屬性。  
*有效值*：`overwrite` 或 `merge`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[Mode](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-mode)` 屬性。

 `Models`   <a name="sam-api-models"></a>
您的 API 方法要使用的結構描述。您可以使用 JSON 或 YAML 描述這些結構描述。如需範例模型，請參閱此頁面底部的範例一節。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Name`   <a name="sam-api-name"></a>
API Gateway RestApi 資源的名稱  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-name)` 屬性。

 `OpenApiVersion`   <a name="sam-api-openapiversion"></a>
要使用的 OpenApi 版本。這可以是`2.0`用於 Swagger 規格，也可以是其中一個 OpenApi 3.0 版本，例如 `3.0.1`。如需 OpenAPI 的詳細資訊，請參閱 [OpenAPI 規格](https://swagger.io/specification/)。  
 AWS SAM 根據預設， 會建立名為 `Stage` 的階段。將此屬性設定為任何有效值將導致無法建立階段 `Stage`。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`PropagateTags`  <a name="sam-api-propagatetags"></a>
指出是否要將標籤從 `Tags` 屬性傳遞至您[AWS::Serverless::Api](sam-specification-generated-resources-api.md)產生的資源。指定 `True` 在產生的資源中傳播標籤。  
*類型*：布林值  
*必要*：否  
*預設*：`False`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Policy`  <a name="sam-api-policy"></a>
包含 API 許可的政策文件。若要設定政策的 ARN，請使用 `!Join` 內部函數搭配 `""` 做為分隔符號，並使用值 `"execute-api:/"` 和 `"*"`。  
*類型*：JSON  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` 資源的 [ 政策](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-policy)屬性。

 `StageName`   <a name="sam-api-stagename"></a>
API Gateway 做為叫用統一資源識別符 (URI) 中第一個路徑區段的階段名稱。  
若要參考階段資源，請使用 `<api-logical-id>.Stage`。如需參考指定資源時產生的[AWS::Serverless::Api](#sam-resource-api)資源的詳細資訊，請參閱 [CloudFormation 指定 AWS::Serverless::Api 時產生的資源](sam-specification-generated-resources-api.md)。如需已產生 CloudFormation 資源的一般資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::Stage` 資源的 `[StageName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-stagename)` 屬性。在 SAM 中為必要，但在 API Gateway 中為非必要  
*其他備註*：隱含 API 的階段名稱為 "Prod"。

 `Tags`   <a name="sam-api-tags"></a>
映射 （字串到字串），指定要新增至此 API Gateway 階段的標籤。如需標籤有效金鑰和值的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[資源標籤](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::Stage` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-tags)` 屬性。SAM 中的標籤屬性包含 Key：Value 對；在 CloudFormation 中包含標籤物件清單。

 `TracingEnabled`   <a name="sam-api-tracingenabled"></a>
指出是否已針對階段啟用使用 X-Ray 的主動追蹤。如需 X-Ray 的詳細資訊，請參閱《 [ APIs Gateway 開發人員指南》中的使用 X-Ray 追蹤使用者對 REST API 的請求](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-xray.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[TracingEnabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-tracingenabled)` 屬性。

 `Variables`   <a name="sam-api-variables"></a>
定義階段變數的映射 （字串到字串），其中變數名稱是索引鍵，而變數值是值。變數名稱限制為英數字元。值必須符合下列規則表達式：`[A-Za-z0-9._~:/?#&=,-]+`。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::Stage` 資源的 `[Variables](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-variables)` 屬性。

## 傳回值
<a name="sam-resource-api-return-values"></a>

### Ref
<a name="sam-resource-api-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回基礎 API Gateway API 的 ID。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-api-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`RootResourceId`  <a name="RootResourceId-fn::getatt"></a>
`RestApi` 資源的根資源 ID，例如：`a0bc123d4e`。

## 範例
<a name="sam-resource-api--examples"></a>

### SimpleApiExample
<a name="sam-resource-api--examples--simpleapiexample"></a>

Hello World AWS SAM 範本檔案，其中包含具有 API 端點的 Lambda 函數。這是運作中無伺服器應用程式的完整 AWS SAM 範本檔案。

#### YAML
<a name="sam-resource-api--examples--simpleapiexample--yaml"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with a simple API definition
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
  ApiFunction: # Adds a GET method at the root resource via an Api event
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /
            Method: get
            RestApiId:
              Ref: ApiGatewayApi
      Runtime: python3.10
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
            return {'body': 'Hello World!', 'statusCode': 200}
```

### ApiCorsExample
<a name="sam-resource-api--examples--apicorsexample"></a>

具有外部 Swagger 檔案中定義之 API 的 AWS SAM 範本程式碼片段，以及 Lambda 整合和 CORS 組態。這只是 AWS SAM 範本檔案的一部分，顯示 [AWS::Serverless::Api](#sam-resource-api)定義。

#### YAML
<a name="sam-resource-api--examples--apicorsexample--yaml"></a>

```
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      # Allows www.example.com to call these APIs
      # SAM will automatically add AllowMethods with a list of methods for this API
      Cors: "'www.example.com'"
      DefinitionBody: # Pull in an OpenApi definition from S3
        'Fn::Transform':
          Name: 'AWS::Include'
          # Replace "bucket" with your bucket name
          Parameters:
            Location: s3://bucket/swagger.yaml
```

### ApiCognitoAuthExample
<a name="sam-resource-api--examples--apicognitoauthexample"></a>

具有 API 的 AWS SAM 範本程式碼片段，該 API 使用 Amazon Cognito 來授權對 API 的請求。這只是 AWS SAM 範本檔案的一部分，顯示 [AWS::Serverless::Api](#sam-resource-api)定義。

#### YAML
<a name="sam-resource-api--examples--apicognitoauthexample--yaml"></a>

```
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Cors: "'*'"
      Auth:
        DefaultAuthorizer: MyCognitoAuthorizer
        Authorizers:
          MyCognitoAuthorizer:
            UserPoolArn:
              Fn::GetAtt: [MyCognitoUserPool, Arn]
```

### ApiModelsExample
<a name="sam-resource-api--examples--apimodelsexample"></a>

包含模型結構描述之 API 的 AWS SAM 範本程式碼片段。這只是 AWS SAM 範本檔案的一部分，顯示具有兩個模型結構描述[AWS::Serverless::Api](#sam-resource-api)的定義。

#### YAML
<a name="sam-resource-api--examples--apimodelsexample--yaml"></a>

```
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Models:
        User:
          type: object
          required:
            - username
            - employee_id
          properties:
            username:
              type: string
            employee_id:
              type: integer
            department:
              type: string
        Item:
          type: object
          properties:
            count:
              type: integer
            category:
              type: string
            price:
              type: integer
```

### 快取範例
<a name="sam-resource-api--examples--caching-example"></a>

Hello World AWS SAM 範本檔案，其中包含具有 API 端點的 Lambda 函數。API 已針對一個資源和方法啟用快取。如需快取的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的啟用 API 快取以增強回應能力](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html)。 **

#### YAML
<a name="sam-resource-api--examples--caching-example--yaml"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with a simple API definition with caching turned on
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      CacheClusterEnabled: true
      CacheClusterSize: '0.5'
      MethodSettings:
        - ResourcePath: /
          HttpMethod: GET
          CachingEnabled: true
          CacheTtlInSeconds: 300
      Tags:
        CacheMethods: All 

  ApiFunction: # Adds a GET method at the root resource via an Api event
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /
            Method: get
            RestApiId:
              Ref: ApiGatewayApi
      Runtime: python3.10
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
            return {'body': 'Hello World!', 'statusCode': 200}
```

### 具有私有 API 範例的自訂網域
<a name="sam-resource-api--examples--custom-domain-example"></a>

Hello World AWS SAM 範本檔案，其中包含與私有網域對應之 API 端點的 Lambda 函數。範本會在 VPC 端點與私有網域之間建立網域存取關聯。如需詳細資訊，請參閱 [API Gateway 中私有 APIs的自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。

#### YAML
<a name="sam-resource-api--examples--custom-domain-example--yaml"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template configured with a custom domain using a private API

Parameters:
    DomainName:
      Type: String
      Default: mydomain.example.com
    CertificateArn:
      Type: String
    HostedZoneId:
      Type: String
    VpcEndpointId:
      Type: String
    VpcEndpointDomainName:
      Type: String
    VpcEndpointHostedZoneId:
      Type: String

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
        def handler(event, context):
            return {'body': 'Hello World!', 'statusCode': 200}
      Handler: index.handler
      Runtime: python3.13
      Events:
        Fetch:
          Type: Api
          Properties:
            RestApiId:
              Ref: MyApi
            Method: Get
            Path: /get
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      EndpointConfiguration:
        Type: PRIVATE
        VPCEndpointIds:
        - !Ref VpcEndpointId
      Policy:
        Version: '2012-10-17		 	 	 '
        Statement:
        - Effect: Allow
          Principal: '*'
          Action: execute-api:Invoke
          Resource: execute-api:/*
        - Effect: Deny
          Principal: '*'
          Action: execute-api:Invoke
          Resource: execute-api:/*
          Condition:
            StringNotEquals:
              aws:SourceVpce: !Ref VpcEndpointId
      Domain:
        DomainName: !Ref DomainName
        CertificateArn: !Ref CertificateArn
        EndpointConfiguration: PRIVATE
        BasePath:
        - /
        Route53:
          HostedZoneId: !Ref HostedZoneId
          VpcEndpointDomainName: !Ref VpcEndpointDomainName
          VpcEndpointHostedZoneId: !Ref VpcEndpointHostedZoneId
        AccessAssociation:
          VpcEndpointId: !Ref VpcEndpointId
        Policy:
          Version: '2012-10-17		 	 	 '
          Statement:
          - Effect: Allow
            Principal: '*'
            Action: execute-api:Invoke
            Resource: execute-api:/*
          - Effect: Deny
            Principal: '*'
            Action: execute-api:Invoke
            Resource: execute-api:/*
            Condition:
              StringNotEquals:
                aws:SourceVpce: !Ref VpcEndpointId
```

# ApiAuth
<a name="sam-property-api-apiauth"></a>

設定授權以控制對 API Gateway API 的存取。

如需使用 設定存取權的詳細資訊和範例， AWS SAM 請參閱 [使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。

## 語法
<a name="sam-property-api-apiauth-syntax"></a>

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

### YAML
<a name="sam-property-api-apiauth-syntax.yaml"></a>

```
  AddApiKeyRequiredToCorsPreflight: Boolean
  [AddDefaultAuthorizerToCorsPreflight](#sam-api-apiauth-adddefaultauthorizertocorspreflight): Boolean
  [ApiKeyRequired](#sam-api-apiauth-apikeyrequired): Boolean
  [Authorizers](#sam-api-apiauth-authorizers): CognitoAuthorizer | LambdaTokenAuthorizer | LambdaRequestAuthorizer | AWS_IAM
  [DefaultAuthorizer](#sam-api-apiauth-defaultauthorizer): String
  [InvokeRole](#sam-api-apiauth-invokerole): String
  [ResourcePolicy](#sam-api-apiauth-resourcepolicy): ResourcePolicyStatement
  [UsagePlan](#sam-api-apiauth-usageplan): ApiUsagePlan
```

**注意**  
`Authorizers` 屬性包含 `AWS_IAM`，但 不需要額外的組態`AWS_IAM`。如需範例，請參閱 [AWS IAM](#sam-property-api-apiauth--examples--aws_iam)。

## Properties
<a name="sam-property-api-apiauth-properties"></a>

 `AddApiKeyRequiredToCorsPreflight`   <a name="sam-api-apiauth-addapikeyrequiredtocorspreflight"></a>
如果已設定 `ApiKeyRequired`和 `Cors` 屬性，則設定`AddApiKeyRequiredToCorsPreflight`會導致 API 金鑰新增至 `Options` 屬性。  
*類型*：布林值  
*必要*：否  
*預設*：`True`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AddDefaultAuthorizerToCorsPreflight`   <a name="sam-api-apiauth-adddefaultauthorizertocorspreflight"></a>
如果已設定 `DefaultAuthorizer`和 `Cors` 屬性，則設定`AddDefaultAuthorizerToCorsPreflight`會導致預設授權方新增至 OpenAPI 區段中的 `Options` 屬性。  
*類型*：布林值  
*必要*：否  
*預設*：True  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ApiKeyRequired`   <a name="sam-api-apiauth-apikeyrequired"></a>
如果設定為 true，則所有 API 事件都需要 API 金鑰。如需 API 金鑰的詳細資訊，請參閱[《 API Gateway 開發人員指南》中的使用 API 金鑰建立和使用用量計劃](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Authorizers`   <a name="sam-api-apiauth-authorizers"></a>
用於控制 API Gateway API 存取的授權方。  
如需詳細資訊，請參閱[使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。  
*類型*：[CognitoAuthorizer](sam-property-api-cognitoauthorizer.md) \$1 [LambdaTokenAuthorizer](sam-property-api-lambdatokenauthorizer.md) \$1 [LambdaRequestAuthorizer](sam-property-api-lambdarequestauthorizer.md) \$1 AWS\$1IAM  
*必要*：否  
*預設*：無  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。  
*其他備註*：SAM 會將授權方新增至 Api 的 OpenApi 定義。

 `DefaultAuthorizer`   <a name="sam-api-apiauth-defaultauthorizer"></a>
指定 API Gateway API 的預設授權方，該 API Gateway API 預設將用於授權 API 呼叫。  
如果與此 API 相關聯之函數的 Api EventSource 設定為使用 IAM 許可，則此屬性必須設定為 `AWS_IAM`，否則會產生錯誤。
*類型：*字串  
*必要*：否  
*預設*：無  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `InvokeRole`   <a name="sam-api-apiauth-invokerole"></a>
將所有資源和方法的整合登入資料設定為此值。  
`CALLER_CREDENTIALS` 會映射到 `arn:aws:iam:::<user>/`，使用呼叫者登入資料來叫用端點。  
*有效值*：`CALLER_CREDENTIALS`、`NONE`、 `IAMRoleArn`  
*類型：*字串  
*必要*：否  
*預設*：`CALLER_CREDENTIALS`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ResourcePolicy`   <a name="sam-api-apiauth-resourcepolicy"></a>
設定 API 上所有方法和路徑的資源政策。  
*類型*：[ResourcePolicyStatement](sam-property-api-resourcepolicystatement.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。  
*其他備註*：您也可以`AWS::Serverless::Function`使用 在個別 上定義此設定[ApiFunctionAuth](sam-property-function-apifunctionauth.md)。對於具有 APIs，這是必要的`EndpointConfiguration: PRIVATE`。

 `UsagePlan`   <a name="sam-api-apiauth-usageplan"></a>
設定與此 API 相關聯的用量計劃。如需用量計劃的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API 金鑰建立和使用用量計劃](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html)。 **  
此 AWS SAM 屬性會在設定此屬性時產生三個額外的 CloudFormation 資源：[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html)、 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html)和 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html)。如需此案例的資訊，請參閱 [已指定 UsagePlan 屬性](sam-specification-generated-resources-api.md#sam-specification-generated-resources-api-usage-plan)。如需所產生 CloudFormation 資源的一般資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型*：[ApiUsagePlan](sam-property-api-apiusageplan.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-apiauth--examples"></a>

### CognitoAuth
<a name="sam-property-api-apiauth--examples--cognitoauth"></a>

Cognito 驗證範例

#### YAML
<a name="sam-property-api-apiauth--examples--cognitoauth--yaml"></a>

```
Auth:
  Authorizers:
    MyCognitoAuth:
     UserPoolArn:
       Fn::GetAtt:
         - MyUserPool
         - Arn
     AuthType: "COGNITO_USER_POOLS"
  DefaultAuthorizer: MyCognitoAuth
  InvokeRole: CALLER_CREDENTIALS
  AddDefaultAuthorizerToCorsPreflight: false
  ApiKeyRequired: false
  ResourcePolicy:
    CustomStatements: [{
      "Effect": "Allow",
      "Principal": "*",
      "Action": "execute-api:Invoke",
      "Resource": "execute-api:/Prod/GET/pets",
      "Condition": {
          "IpAddress": {
              "aws:SourceIp": "1.2.3.4"
          }
        }
    }]
    IpRangeDenylist:
      - "10.20.30.40"
```

### AWS IAM
<a name="sam-property-api-apiauth--examples--aws_iam"></a>

AWS IAM 範例

#### YAML
<a name="sam-property-api-apiauth--examples--cognitoauth--yaml"></a>

```
Auth:
  Authorizers: AWS_IAM
```

# ApiUsagePlan
<a name="sam-property-api-apiusageplan"></a>

設定 API Gateway API 的用量計劃。如需用量計劃的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API 金鑰建立和使用用量計劃](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html)。 **

## 語法
<a name="sam-property-api-apiusageplan-syntax"></a>

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

### YAML
<a name="sam-property-api-apiusageplan-syntax.yaml"></a>

```
  [CreateUsagePlan](#sam-api-apiusageplan-createusageplan): String
  [Description](#sam-api-apiusageplan-description): String
  [Quota](#sam-api-apiusageplan-quota): [QuotaSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-quota)
  [Tags](#sam-api-apiusageplan-tags): List
  [Throttle](#sam-api-apiusageplan-throttle): [ThrottleSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-throttle)
  [UsagePlanName](#sam-api-apiusageplan-usageplanname): String
```

## Properties
<a name="sam-property-api-apiusageplan-properties"></a>

 `CreateUsagePlan`   <a name="sam-api-apiusageplan-createusageplan"></a>
決定此用量計劃的設定方式。有效值為 `PER_API`、`SHARED` 和 `NONE`。  
`PER_API` 會建立此 API 特有的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html)、 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html)和 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html) 資源。這些資源的邏輯 IDs `<api-logical-id>UsagePlanKey`分別為 `<api-logical-id>UsagePlan`、 `<api-logical-id>ApiKey`和 。  
`SHARED` 會建立 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html)、 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html)和 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplankey.html) 資源，這些資源在相同 AWS SAM 範本`CreateUsagePlan: SHARED`中也有 的任何 API 之間共用。這些資源的邏輯 IDs `ServerlessUsagePlanKey`分別為 `ServerlessUsagePlan`、 `ServerlessApiKey`和 。如果您使用此選項，建議您僅針對一個 API 資源新增此用量計劃的其他組態，以避免衝突的定義和不確定狀態。  
`NONE` 會停用與此 API 建立或關聯用量計劃。只有在 中指定 `PER_API` `SHARED`或 時，才需要這樣做[AWS SAM 範本的全域區段](sam-specification-template-anatomy-globals.md)。  
*有效值*：`PER_API`、`SHARED` 與 `NONE`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Description`   <a name="sam-api-apiusageplan-description"></a>
用量計劃的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::UsagePlan` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-description)` 屬性。

 `Quota`   <a name="sam-api-apiusageplan-quota"></a>
設定使用者可在指定間隔內發出的請求數。  
*類型*：[QuotaSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-quota)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::UsagePlan` 資源的 `[Quota](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-quota)` 屬性。

 `Tags`   <a name="sam-api-apiusageplan-tags"></a>
要與用量計劃關聯的任意標籤陣列 (金鑰值對)。  
此屬性使用 [CloudFormation 標籤類型](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::UsagePlan` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-tags)` 屬性。

 `Throttle`   <a name="sam-api-apiusageplan-throttle"></a>
設定整體請求速率 (每秒平均請求數) 和高載容量。  
*類型*：[ThrottleSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-throttle)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::UsagePlan` 資源的 `[Throttle](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-throttle)` 屬性。

 `UsagePlanName`   <a name="sam-api-apiusageplan-usageplanname"></a>
用量計劃的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::UsagePlan` 資源的 `[UsagePlanName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-usageplan.html#cfn-apigateway-usageplan-usageplanname)` 屬性。

## 範例
<a name="sam-property-api-apiusageplan--examples"></a>

### UsagePlan
<a name="sam-property-api-apiusageplan--examples--usageplan"></a>

以下是用量計劃範例。

#### YAML
<a name="sam-property-api-apiusageplan--examples--usageplan--yaml"></a>

```
Auth:
  UsagePlan:
    CreateUsagePlan: PER_API
    Description: Usage plan for this API
    Quota:
      Limit: 500
      Period: MONTH
    Throttle:
      BurstLimit: 100
      RateLimit: 50
    Tags:
      - Key: TagName
        Value: TagValue
```

# CognitoAuthorizer
<a name="sam-property-api-cognitoauthorizer"></a>

定義 Amazon Cognito 使用者集區授權方。

如需詳細資訊和範例，請參閱 [使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。

## 語法
<a name="sam-property-api-cognitoauthorizer-syntax"></a>

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

### YAML
<a name="sam-property-api-cognitoauthorizer-syntax.yaml"></a>

```
  [AuthorizationScopes](#sam-api-cognitoauthorizer-authorizationscopes): List
  [Identity](#sam-api-cognitoauthorizer-identity): CognitoAuthorizationIdentity
  [UserPoolArn](#sam-api-cognitoauthorizer-userpoolarn): String
```

## Properties
<a name="sam-property-api-cognitoauthorizer-properties"></a>

 `AuthorizationScopes`   <a name="sam-api-cognitoauthorizer-authorizationscopes"></a>
此授權方的授權範圍清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Identity`   <a name="sam-api-cognitoauthorizer-identity"></a>
此屬性可用於在 授權方的傳入請求`IdentitySource`中指定 。  
*類型*：[CognitoAuthorizationIdentity](sam-property-api-cognitoauthorizationidentity.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `UserPoolArn`   <a name="sam-api-cognitoauthorizer-userpoolarn"></a>
可以參考使用者集區/指定您要新增此 cognito 授權方的使用者集區  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-cognitoauthorizer--examples"></a>

### CognitoAuth
<a name="sam-property-api-cognitoauthorizer--examples--cognitoauth"></a>

Cognito 驗證範例

#### YAML
<a name="sam-property-api-cognitoauthorizer--examples--cognitoauth--yaml"></a>

```
Auth:
  Authorizers:
    MyCognitoAuth:
      AuthorizationScopes:
        - scope1
        - scope2
      UserPoolArn:
        Fn::GetAtt:
          - MyCognitoUserPool
          - Arn
      Identity:
        Header: MyAuthorizationHeader
        ValidationExpression: myauthvalidationexpression
```

# CognitoAuthorizationIdentity
<a name="sam-property-api-cognitoauthorizationidentity"></a>

此屬性可用於在 授權方的傳入請求中指定 IdentitySource。如需 IdentitySource 的詳細資訊，請參閱 [ApiGateway 授權方 OpenApi 延伸](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html)。

## 語法
<a name="sam-property-api-cognitoauthorizationidentity-syntax"></a>

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

### YAML
<a name="sam-property-api-cognitoauthorizationidentity-syntax.yaml"></a>

```
  [Header](#sam-api-cognitoauthorizationidentity-header): String
  [ReauthorizeEvery](#sam-api-cognitoauthorizationidentity-reauthorizeevery): Integer
  [ValidationExpression](#sam-api-cognitoauthorizationidentity-validationexpression): String
```

## Properties
<a name="sam-property-api-cognitoauthorizationidentity-properties"></a>

 `Header`   <a name="sam-api-cognitoauthorizationidentity-header"></a>
在 OpenApi 定義中指定授權的標頭名稱。  
*類型：*字串  
*必要*：否  
*預設*：授權  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ReauthorizeEvery`   <a name="sam-api-cognitoauthorizationidentity-reauthorizeevery"></a>
存活期 (TTL) 期間 (秒)，指定 API Gateway 快取授權方結果的時間。如果您指定的值大於 0，則 API Gateway 會快取授權方回應。根據預設，API Gateway 會將此屬性設為 300。值的上限為 3600 (1 小時)。  
*類型*：整數  
*必要*：否  
*預設*：300  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidationExpression`   <a name="sam-api-cognitoauthorizationidentity-validationexpression"></a>
指定驗證表達式以驗證傳入的 Identity  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-cognitoauthorizationidentity--examples"></a>

### CognitoAuthIdentity
<a name="sam-property-api-cognitoauthorizationidentity--examples--cognitoauthidentity"></a>

#### YAML
<a name="sam-property-api-cognitoauthorizationidentity--examples--cognitoauthidentity--yaml"></a>

```
Identity:
  Header: MyCustomAuthHeader
  ValidationExpression: Bearer.*
  ReauthorizeEvery: 30
```

# LambdaRequestAuthorizer
<a name="sam-property-api-lambdarequestauthorizer"></a>

設定 Lambda 授權方，以使用 Lambda 函數控制對 API 的存取。

如需詳細資訊和範例，請參閱 [使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。

## 語法
<a name="sam-property-api-lambdarequestauthorizer-syntax"></a>

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

### YAML
<a name="sam-property-api-lambdarequestauthorizer-syntax.yaml"></a>

```
DisableFunctionDefaultPermissions: Boolean
[FunctionArn](#sam-api-lambdarequestauthorizer-functionarn): String
[FunctionInvokeRole](#sam-api-lambdarequestauthorizer-functioninvokerole): String
[FunctionPayloadType](#sam-api-lambdarequestauthorizer-functionpayloadtype): String
[Identity](#sam-api-lambdarequestauthorizer-identity): LambdaRequestAuthorizationIdentity
```

## Properties
<a name="sam-property-api-lambdarequestauthorizer-properties"></a>

 `DisableFunctionDefaultPermissions`   <a name="sam-api-lambdarequestauthorizer-disablefunctiondefaultpermissions"></a>
指定 `true` AWS SAM 以防止 自動建立 `AWS::Lambda::Permissions` 資源，在您的`AWS::Serverless::Api`資源和授權方 Lambda 函數之間佈建許可。  
*預設值*：`false`  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionArn`   <a name="sam-api-lambdarequestauthorizer-functionarn"></a>
指定提供 API 授權的 Lambda 函數的函數 ARN。  
AWS SAM 當 `FunctionArn` 針對 指定 時， 會自動建立 `AWS::Lambda::Permissions` 資源`AWS::Serverless::Api`。`AWS::Lambda::Permissions` 資源會在您的 API 和授權方 Lambda 函數之間佈建許可。
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionInvokeRole`   <a name="sam-api-lambdarequestauthorizer-functioninvokerole"></a>
將授權方憑證新增至 Lambda 授權方的 OpenApi 定義。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionPayloadType`   <a name="sam-api-lambdarequestauthorizer-functionpayloadtype"></a>
此屬性可用來定義 API 的 Lambda 授權方類型。  
*有效值*：`TOKEN` 或 `REQUEST`  
*類型：*字串  
*必要*：否  
*預設*：`TOKEN`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Identity`   <a name="sam-api-lambdarequestauthorizer-identity"></a>
此屬性可用於在 授權方的傳入請求`IdentitySource`中指定 。只有在 屬性設定為 時，才需要此`FunctionPayloadType`屬性`REQUEST`。  
*類型*：[LambdaRequestAuthorizationIdentity](sam-property-api-lambdarequestauthorizationidentity.md)  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-lambdarequestauthorizer--examples"></a>

### LambdaRequestAuth
<a name="sam-property-api-lambdarequestauthorizer--examples--lambdarequestauth"></a>

#### YAML
<a name="sam-property-api-lambdarequestauthorizer--examples--lambdarequestauth--yaml"></a>

```
Authorizers:
  MyLambdaRequestAuth:
    FunctionPayloadType: REQUEST
    FunctionArn:
      Fn::GetAtt:
        - MyAuthFunction
        - Arn
    FunctionInvokeRole:
      Fn::GetAtt:
        - LambdaAuthInvokeRole
        - Arn
    Identity:
      Headers:
        - Authorization1
```

# LambdaRequestAuthorizationIdentity
<a name="sam-property-api-lambdarequestauthorizationidentity"></a>

此屬性可用於在 授權方的傳入請求中指定 IdentitySource。如需 IdentitySource 的詳細資訊，請參閱 [ApiGateway 授權方 OpenApi 延伸](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html)。

## 語法
<a name="sam-property-api-lambdarequestauthorizationidentity-syntax"></a>

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

### YAML
<a name="sam-property-api-lambdarequestauthorizationidentity-syntax.yaml"></a>

```
  [Context](#sam-api-lambdarequestauthorizationidentity-context): List
  [Headers](#sam-api-lambdarequestauthorizationidentity-headers): List
  [QueryStrings](#sam-api-lambdarequestauthorizationidentity-querystrings): List
  [ReauthorizeEvery](#sam-api-lambdarequestauthorizationidentity-reauthorizeevery): Integer
  [StageVariables](#sam-api-lambdarequestauthorizationidentity-stagevariables): List
```

## Properties
<a name="sam-property-api-lambdarequestauthorizationidentity-properties"></a>

 `Context`   <a name="sam-api-lambdarequestauthorizationidentity-context"></a>
將指定的內容字串轉換為格式 的映射表達式`context.contextString`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Headers`   <a name="sam-api-lambdarequestauthorizationidentity-headers"></a>
將標頭轉換為格式 映射表達式的逗號分隔字串`method.request.header.name`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `QueryStrings`   <a name="sam-api-lambdarequestauthorizationidentity-querystrings"></a>
將指定的查詢字串轉換為格式 映射表達式的逗號分隔字串`method.request.querystring.queryString`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ReauthorizeEvery`   <a name="sam-api-lambdarequestauthorizationidentity-reauthorizeevery"></a>
存活期 (TTL) 期間 (秒)，指定 API Gateway 快取授權方結果的時間。如果您指定的值大於 0，則 API Gateway 會快取授權方回應。根據預設，API Gateway 會將此屬性設為 300。值的上限為 3600 (1 小時)。  
*類型*：整數  
*必要*：否  
*預設*：300  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `StageVariables`   <a name="sam-api-lambdarequestauthorizationidentity-stagevariables"></a>
將指定的階段變數轉換為以逗號分隔的格式映射表達式字串`stageVariables.stageVariable`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-lambdarequestauthorizationidentity--examples"></a>

### LambdaRequestIdentity
<a name="sam-property-api-lambdarequestauthorizationidentity--examples--lambdarequestidentity"></a>

#### YAML
<a name="sam-property-api-lambdarequestauthorizationidentity--examples--lambdarequestidentity--yaml"></a>

```
Identity:
  QueryStrings:
    - auth
  Headers:
    - Authorization
  StageVariables:
    - VARIABLE
  Context:
    - authcontext
  ReauthorizeEvery: 100
```

# LambdaTokenAuthorizer
<a name="sam-property-api-lambdatokenauthorizer"></a>

設定 Lambda 授權方，以使用 Lambda 函數控制對 API 的存取。

如需詳細資訊和範例，請參閱 [使用 AWS SAM 範本控制 API 存取](serverless-controlling-access-to-apis.md)。

## 語法
<a name="sam-property-api-lambdatokenauthorizer-syntax"></a>

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

### YAML
<a name="sam-property-api-lambdatokenauthorizer-syntax.yaml"></a>

```
DisableFunctionDefaultPermissions: Boolean
[FunctionArn](#sam-api-lambdatokenauthorizer-functionarn): String
[FunctionInvokeRole](#sam-api-lambdatokenauthorizer-functioninvokerole): String
[FunctionPayloadType](#sam-api-lambdatokenauthorizer-functionpayloadtype): String
[Identity](#sam-api-lambdatokenauthorizer-identity): LambdaTokenAuthorizationIdentity
```

## Properties
<a name="sam-property-api-lambdatokenauthorizer-properties"></a>

 `DisableFunctionDefaultPermissions`   <a name="sam-api-lambdatokenauthorizer-disablefunctiondefaultpermissions"></a>
指定 `true` AWS SAM 以防止 自動建立 `AWS::Lambda::Permissions` 資源，在您的`AWS::Serverless::Api`資源和授權方 Lambda 函數之間佈建許可。  
*預設值*：`false`  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionArn`   <a name="sam-api-lambdatokenauthorizer-functionarn"></a>
指定提供 API 授權的 Lambda 函數的函數 ARN。  
AWS SAM 當 `FunctionArn` 針對 指定 時， 會自動建立 `AWS::Lambda::Permissions` 資源`AWS::Serverless::Api`。`AWS::Lambda::Permissions` 資源會在您的 API 和授權方 Lambda 函數之間佈建許可。
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionInvokeRole`   <a name="sam-api-lambdatokenauthorizer-functioninvokerole"></a>
將授權方憑證新增至 Lambda 授權方的 OpenApi 定義。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `FunctionPayloadType`   <a name="sam-api-lambdatokenauthorizer-functionpayloadtype"></a>
此屬性可用來定義 Api 的 Lambda 授權方類型。  
*有效值*：`TOKEN` 或 `REQUEST`  
*類型：*字串  
*必要*：否  
*預設*：`TOKEN`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Identity`   <a name="sam-api-lambdatokenauthorizer-identity"></a>
此屬性可用於在 授權方的傳入請求`IdentitySource`中指定 。只有在 屬性設定為 時，才需要此`FunctionPayloadType`屬性`REQUEST`。  
*類型*：[LambdaTokenAuthorizationIdentity](sam-property-api-lambdatokenauthorizationidentity.md)  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-lambdatokenauthorizer--examples"></a>

### LambdaTokenAuth
<a name="sam-property-api-lambdatokenauthorizer--examples--lambdatokenauth"></a>

#### YAML
<a name="sam-property-api-lambdatokenauthorizer--examples--lambdatokenauth--yaml"></a>

```
Authorizers:
  MyLambdaTokenAuth:
    FunctionArn:
      Fn::GetAtt:
        - MyAuthFunction
        - Arn
    Identity:
      Header: MyCustomAuthHeader # OPTIONAL; Default: 'Authorization'
      ValidationExpression: mycustomauthexpression # OPTIONAL
      ReauthorizeEvery: 20 # OPTIONAL; Service Default: 300
```

### BasicLambdaTokenAuth
<a name="sam-property-api-lambdatokenauthorizer--examples--basiclambdatokenauth"></a>

#### YAML
<a name="sam-property-api-lambdatokenauthorizer--examples--basiclambdatokenauth--yaml"></a>

```
Authorizers:
  MyLambdaTokenAuth:
    FunctionArn:
      Fn::GetAtt:
        - MyAuthFunction
        - Arn
```

# LambdaTokenAuthorizationIdentity
<a name="sam-property-api-lambdatokenauthorizationidentity"></a>

此屬性可用於在 授權方的傳入請求中指定 IdentitySource。如需 IdentitySource 的詳細資訊，請參閱 [ApiGateway 授權方 OpenApi 延伸](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html)。

## 語法
<a name="sam-property-api-lambdatokenauthorizationidentity-syntax"></a>

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

### YAML
<a name="sam-property-api-lambdatokenauthorizationidentity-syntax.yaml"></a>

```
  [Header](#sam-api-lambdatokenauthorizationidentity-header): String
  [ReauthorizeEvery](#sam-api-lambdatokenauthorizationidentity-reauthorizeevery): Integer
  [ValidationExpression](#sam-api-lambdatokenauthorizationidentity-validationexpression): String
```

## Properties
<a name="sam-property-api-lambdatokenauthorizationidentity-properties"></a>

 `Header`   <a name="sam-api-lambdatokenauthorizationidentity-header"></a>
在 OpenApi 定義中指定授權的標頭名稱。  
*類型：*字串  
*必要*：否  
*預設*：授權  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ReauthorizeEvery`   <a name="sam-api-lambdatokenauthorizationidentity-reauthorizeevery"></a>
存活期 (TTL) 期間 (秒)，指定 API Gateway 快取授權方結果的時間。如果您指定的值大於 0，則 API Gateway 會快取授權方回應。根據預設，API Gateway 會將此屬性設為 300。值的上限為 3600 (1 小時)。  
*類型*：整數  
*必要*：否  
*預設*：300  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidationExpression`   <a name="sam-api-lambdatokenauthorizationidentity-validationexpression"></a>
指定驗證表達式以驗證傳入的 Identity。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-lambdatokenauthorizationidentity--examples"></a>

### LambdaTokenIdentity
<a name="sam-property-api-lambdatokenauthorizationidentity--examples--lambdatokenidentity"></a>

#### YAML
<a name="sam-property-api-lambdatokenauthorizationidentity--examples--lambdatokenidentity--yaml"></a>

```
Identity:
  Header: MyCustomAuthHeader
  ValidationExpression: Bearer.*
  ReauthorizeEvery: 30
```

# ResourcePolicyStatement
<a name="sam-property-api-resourcepolicystatement"></a>

為 API 的所有方法和路徑設定資源政策。如需資源政策的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API Gateway 資源政策控制對 API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies.html)。 **

## 語法
<a name="sam-property-api-resourcepolicystatement-syntax"></a>

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

### YAML
<a name="sam-property-api-resourcepolicystatement-syntax.yaml"></a>

```
  [AwsAccountBlacklist](#sam-api-resourcepolicystatement-awsaccountblacklist): List
  [AwsAccountWhitelist](#sam-api-resourcepolicystatement-awsaccountwhitelist): List
  [CustomStatements](#sam-api-resourcepolicystatement-customstatements): List
  [IntrinsicVpcBlacklist](#sam-api-resourcepolicystatement-intrinsicvpcblacklist): List
  [IntrinsicVpcWhitelist](#sam-api-resourcepolicystatement-intrinsicvpcwhitelist): List
  [IntrinsicVpceBlacklist](#sam-api-resourcepolicystatement-intrinsicvpceblacklist): List
  [IntrinsicVpceWhitelist](#sam-api-resourcepolicystatement-intrinsicvpcewhitelist): List
  [IpRangeBlacklist](#sam-api-resourcepolicystatement-iprangeblacklist): List
  [IpRangeWhitelist](#sam-api-resourcepolicystatement-iprangewhitelist): List
  [SourceVpcBlacklist](#sam-api-resourcepolicystatement-sourcevpcblacklist): List
  [SourceVpcWhitelist](#sam-api-resourcepolicystatement-sourcevpcwhitelist): List
```

## Properties
<a name="sam-property-api-resourcepolicystatement-properties"></a>

 `AwsAccountBlacklist`   <a name="sam-api-resourcepolicystatement-awsaccountblacklist"></a>
要封鎖 AWS 的帳戶。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AwsAccountWhitelist`   <a name="sam-api-resourcepolicystatement-awsaccountwhitelist"></a>
要允許 AWS 的帳戶。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `CustomStatements`   <a name="sam-api-resourcepolicystatement-customstatements"></a>
要套用至此 API 的自訂資源政策陳述式清單。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IntrinsicVpcBlacklist`   <a name="sam-api-resourcepolicystatement-intrinsicvpcblacklist"></a>
要封鎖的虛擬私有雲端 (VPCs) 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpcWhitelist`   <a name="sam-api-resourcepolicystatement-intrinsicvpcwhitelist"></a>
要允許的 VPCs 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceBlacklist`   <a name="sam-api-resourcepolicystatement-intrinsicvpceblacklist"></a>
要封鎖的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceWhitelist`   <a name="sam-api-resourcepolicystatement-intrinsicvpcewhitelist"></a>
要允許的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeBlacklist`   <a name="sam-api-resourcepolicystatement-iprangeblacklist"></a>
要封鎖的 IP 地址或地址範圍。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeWhitelist`   <a name="sam-api-resourcepolicystatement-iprangewhitelist"></a>
要允許的 IP 地址或地址範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SourceVpcBlacklist`   <a name="sam-api-resourcepolicystatement-sourcevpcblacklist"></a>
要封鎖的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceVpcWhitelist`   <a name="sam-api-resourcepolicystatement-sourcevpcwhitelist"></a>
要允許的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-api-resourcepolicystatement--examples"></a>

### 資源政策範例
<a name="sam-property-api-resourcepolicystatement--examples--resource-policy-example"></a>

下列範例會封鎖兩個 IP 地址和來源 VPC，並允許 AWS 帳戶。

#### YAML
<a name="sam-property-api-resourcepolicystatement--examples--resource-policy-example--yaml"></a>

```
Auth:
  ResourcePolicy:
    CustomStatements: [{
                         "Effect": "Allow",
                         "Principal": "*",
                         "Action": "execute-api:Invoke",
                         "Resource": "execute-api:/Prod/GET/pets",
                         "Condition": {
                           "IpAddress": {
                             "aws:SourceIp": "1.2.3.4"
                           }
                         }
                       }]
    IpRangeBlacklist:
      - "10.20.30.40"
      - "1.2.3.4"
    SourceVpcBlacklist:
      - "vpce-1a2b3c4d"
    AwsAccountWhitelist:
      - "111122223333"
    IntrinsicVpcBlacklist:
      - "{{resolve:ssm:SomeVPCReference:1}}" 
      - !Ref MyVPC
    IntrinsicVpceWhitelist:
      - "{{resolve:ssm:SomeVPCEReference:1}}" 
      - !Ref MyVPCE
```

# ApiDefinition
<a name="sam-property-api-apidefinition"></a>

定義 API 的 OpenAPI 文件。

## 語法
<a name="sam-property-api-apidefinition-syntax"></a>

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

### YAML
<a name="sam-property-api-apidefinition-syntax.yaml"></a>

```
  [Bucket](#sam-api-apidefinition-bucket): String
  [Key](#sam-api-apidefinition-key): String
  [Version](#sam-api-apidefinition-version): String
```

## Properties
<a name="sam-property-api-apidefinition-properties"></a>

 `Bucket`   <a name="sam-api-apidefinition-bucket"></a>
存放 OpenAPI 檔案的 Amazon S3 儲存貯體名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `S3Location` 資料類型的 `[Bucket](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-s3location.html#cfn-apigateway-restapi-s3location-bucket)` 屬性。

 `Key`   <a name="sam-api-apidefinition-key"></a>
OpenAPI 檔案的 Amazon S3 金鑰。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `S3Location` 資料類型的 `[Key](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-s3location.html#cfn-apigateway-restapi-s3location-key)` 屬性。

 `Version`   <a name="sam-api-apidefinition-version"></a>
對於版本控制的物件，則為 OpenAPI 檔案的版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `S3Location` 資料類型的 `[Version](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-s3location.html#cfn-apigateway-restapi-s3location-version)` 屬性。

## 範例
<a name="sam-property-api-apidefinition--examples"></a>

### 定義 Uri 範例
<a name="sam-property-api-apidefinition--examples--definition-uri-example"></a>

API 定義範例

#### YAML
<a name="sam-property-api-apidefinition--examples--definition-uri-example--yaml"></a>

```
DefinitionUri:
  Bucket: amzn-s3-demo-bucket-name
  Key: mykey-name
  Version: 121212
```

# CorsConfiguration
<a name="sam-property-api-corsconfiguration"></a>

管理 API Gateway APIs 的跨來源資源共用 (CORS)。指定要允許做為字串的網域，或指定具有其他 Cors 組態的字典。

**注意**  
CORS 需要 AWS SAM 修改您的 OpenAPI 定義。在 中建立內嵌 OpenAPI 定義`DefinitionBody`以開啟 CORS。如果在 OpenAPI 定義和屬性層級設定 `CorsConfiguration` ， 會 AWS SAM 合併它們。屬性層級優先於 OpenAPI 定義。

如需 CORS 的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的為 API Gateway REST API 資源啟用 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html)。 **

## 語法
<a name="sam-property-api-corsconfiguration-syntax"></a>

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

### YAML
<a name="sam-property-api-corsconfiguration-syntax.yaml"></a>

```
  [AllowCredentials](#sam-api-corsconfiguration-allowcredentials): Boolean
  [AllowHeaders](#sam-api-corsconfiguration-allowheaders): String
  [AllowMethods](#sam-api-corsconfiguration-allowmethods): String
  [AllowOrigin](#sam-api-corsconfiguration-alloworigin): String
  [MaxAge](#sam-api-corsconfiguration-maxage): String
```

## Properties
<a name="sam-property-api-corsconfiguration-properties"></a>

 `AllowCredentials`   <a name="sam-api-corsconfiguration-allowcredentials"></a>
布林值，指出是否允許請求包含登入資料。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AllowHeaders`   <a name="sam-api-corsconfiguration-allowheaders"></a>
要允許的標頭字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AllowMethods`   <a name="sam-api-corsconfiguration-allowmethods"></a>
包含要允許之 HTTP 方法的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AllowOrigin`   <a name="sam-api-corsconfiguration-alloworigin"></a>
要允許的原始伺服器字串。這可以是字串格式的逗號分隔清單。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `MaxAge`   <a name="sam-api-corsconfiguration-maxage"></a>
包含快取 CORS 預檢請求秒數的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-api-corsconfiguration--examples"></a>

### CorsConfiguration
<a name="sam-property-api-corsconfiguration--examples--corsconfiguration"></a>

CORS 組態範例。這只是 AWS SAM 範本檔案的一部分，顯示已設定 CORS 和 [AWS::Serverless::Api](sam-resource-api.md)的定義[AWS::Serverless::Function](sam-resource-function.md)。如果您使用 Lambda 代理整合或 HTTP 代理整合，您的後端必須傳回 `Access-Control-Allow-Origin`、 `Access-Control-Allow-Methods`和 `Access-Control-Allow-Headers`標頭。

#### YAML
<a name="sam-property-api-corsconfiguration--examples--corsconfiguration--yaml"></a>

```
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Cors:
        AllowMethods: "'POST, GET'"
        AllowHeaders: "'X-Forwarded-For'"
        AllowOrigin: "'https://example.com'"
        MaxAge: "'600'"
        AllowCredentials: true
  ApiFunction: # Adds a GET method at the root resource via an Api event
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /
            Method: get
            RestApiId:
              Ref: ApiGatewayApi
      Runtime: python3.10
      Handler: index.handler
      InlineCode: |
        import json
        def handler(event, context):
          return {
          'statusCode': 200,
          'headers': {
            'Access-Control-Allow-Headers': 'Content-Type',
            'Access-Control-Allow-Origin': 'https://example.com',
            'Access-Control-Allow-Methods': 'POST, GET'
            },
          'body': json.dumps('Hello from Lambda!')
          }
```

# DomainConfiguration
<a name="sam-property-api-domainconfiguration"></a>

設定 API 的自訂網域。

## 語法
<a name="sam-property-api-domainconfiguration-syntax"></a>

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

### YAML
<a name="sam-property-api-domainconfiguration-syntax.yaml"></a>

```
  [AccessAssociation](#sam-api-domainconfiguration-domainaccessassociation): DomainAccessAssociation
  [BasePath](#sam-api-domainconfiguration-basepath): List
  [CertificateArn](#sam-api-domainconfiguration-certificatearn): String
  [DomainName](#sam-api-domainconfiguration-domainname): String
  [EndpointConfiguration](#sam-api-domainconfiguration-endpointconfiguration): String
  [MutualTlsAuthentication](#sam-api-domainconfiguration-mutualtlsauthentication): [MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-mutualtlsauthentication)
  [NormalizeBasePath](#sam-api-domainconfiguration-normalizebasepath): Boolean
  [OwnershipVerificationCertificateArn](#sam-api-domainconfiguration-ownershipverificationcertificatearn): String
  [Policy: ](#sam-api-domainconfiguration-policy)Json
  [Route53](#sam-api-domainconfiguration-route53): Route53Configuration
  [SecurityPolicy](#sam-api-domainconfiguration-securitypolicy): String
```

## Properties
<a name="sam-property-api-domainconfiguration-properties"></a>

 `AccessAssociation`   <a name="sam-api-domainconfiguration-domainaccessassociation"></a>
產生` AWS::ApiGateway::DomainNameAccessAssociation`資源所需的組態。  
AWS SAM 會在設定此屬性時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnameaccessassociation.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnameaccessassociation.html) 資源。如需所產生 CloudFormation 資源的資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型*：[DomainAccessAssociation](sam-property-api-domainaccessassociation.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `BasePath`   <a name="sam-api-domainconfiguration-basepath"></a>
使用 Amazon API Gateway 網域名稱設定的基本路徑清單。  
*類型：*清單  
*必要*：否  
*預設*：/  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::BasePathMapping` 資源的 `[BasePath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-basepathmapping.html#cfn-apigateway-basepathmapping-basepath)` 屬性。 會 AWS SAM 建立多個`AWS::ApiGateway::BasePathMapping`資源，此屬性中`BasePath`指定的每個資源一個。

 `CertificateArn`   <a name="sam-api-domainconfiguration-certificatearn"></a>
此網域名稱端點 AWS 受管憑證的 Amazon Resource Name (ARN)。 AWS Certificate Manager 是唯一支援的來源。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGateway::DomainName` 資源的 `[CertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-certificatearn)` 屬性。如果 `EndpointConfiguration` 設定為 `REGIONAL`（預設值），則 會`CertificateArn`映射至 中的 [RegionalCertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-regionalcertificatearn)`AWS::ApiGateway::DomainName`。如果 `EndpointConfiguration` 設定為 `EDGE`， 會`CertificateArn`映射至 中的 [CertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-certificatearn)`AWS::ApiGateway::DomainName`。如果 `EndpointConfiguration` 設定為 `PRIVATE`，則此屬性會傳遞至 [AWS：：ApiGateway：：DomainNameV2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2) 資源。  
*其他備註*：對於 `EDGE`端點，您必須在 `us-east-1` AWS 區域中建立憑證。

 `DomainName`   <a name="sam-api-domainconfiguration-domainname"></a>
API Gateway API 的自訂網域名稱。不支援大寫字母。  
AWS SAM 會在設定此屬性時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html) 資源。如需此案例的資訊，請參閱 [已指定 DomainName 屬性](sam-specification-generated-resources-api.md#sam-specification-generated-resources-api-domain-name)。如需所產生 CloudFormation 資源的資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::DomainName` 資源的 `[DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-domainname)` 屬性，或在 EndpointConfiguration 設定為 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2)時傳遞至 `PRIVATE`。

 `EndpointConfiguration`   <a name="sam-api-domainconfiguration-endpointconfiguration"></a>
定義要映射到自訂網域的 API Gateway 端點類型。此屬性的值會決定`CertificateArn`屬性的映射方式 CloudFormation。  
*有效值*：`EDGE`、`REGIONAL` 或 `PRIVATE`  
*類型：*字串  
*必要*：否  
*預設*：`REGIONAL`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `MutualTlsAuthentication`   <a name="sam-api-domainconfiguration-mutualtlsauthentication"></a>
自訂網域名稱的相互 Transport Layer Security (TLS) 身分驗證組態。  
*類型*：[MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-mutualtlsauthentication)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::DomainName` 資源的 `[MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-mutualtlsauthentication)` 屬性。

 `NormalizeBasePath`   <a name="sam-api-domainconfiguration-normalizebasepath"></a>
指出`BasePath`屬性定義的 Basepaths 中是否允許非英數字元。設為 時`True`，會從 basepaths 中移除非英數字元。  
`NormalizeBasePath` 搭配 `BasePath` 屬性使用 。  
*類型*：布林值  
*必要*：否  
*預設*：True  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `OwnershipVerificationCertificateArn`   <a name="sam-api-domainconfiguration-ownershipverificationcertificatearn"></a>
ACM 核發之公有憑證的 ARN，用於驗證您的自訂網域的擁有權。只有在您設定交互 TLS 並指定 的 ACM 匯入或私有 CA 憑證 ARN 時才需要`CertificateArn`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::DomainName` 資源的 `[OwnershipVerificationCertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-ownershipverificationcertificatearn)` 屬性。

 `Policy`   <a name="sam-api-domainconfiguration-policy"></a>
要連接至 API Gateway 網域名稱的 IAM 政策。僅適用於 `EndpointConfiguration` 設定為 時`PRIVATE`。  
*類型*：Json  
*必要*：否  
*CloudFormation 相容性*：`EndpointConfiguration`當 設定為 時，此屬性會直接傳遞至 `AWS::ApiGateway::DomainNameV2` 資源的 `Policy` 屬性`PRIVATE`。如需有效政策文件的範例，請參閱 [AWS：：ApiGateway：：DomainNameV2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2)。

 `Route53`   <a name="sam-api-domainconfiguration-route53"></a>
定義 Amazon Route 53 組態。  
*類型*：[Route53Configuration](sam-property-api-route53configuration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SecurityPolicy`   <a name="sam-api-domainconfiguration-securitypolicy"></a>
此網域名稱的 TLS 版本加上密碼套件。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::DomainName` 資源的 `[SecurityPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html#cfn-apigateway-domainname-securitypolicy)` 屬性，或在 `EndpointConfiguration` 設定為 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnamev2)時傳遞至 `PRIVATE`。對於`PRIVATE`端點，僅支援 TLS\$11\$12。

## 範例
<a name="sam-property-api-domainconfiguration--examples"></a>

### DomainName
<a name="sam-property-api-domainconfiguration--examples--domainname"></a>

DomainName 範例

#### YAML
<a name="sam-property-api-domainconfiguration--examples--domainname--yaml"></a>

```
Domain:
  DomainName: www.example.com
  CertificateArn: arn-example
  EndpointConfiguration: EDGE
  Route53:
    HostedZoneId: Z1PA6795UKMFR9
  BasePath:
    - foo
    - bar
```

# DomainAccessAssociation
<a name="sam-property-api-domainaccessassociation"></a>

設定存取關聯來源與私有自訂網域名稱之間的網域存取關聯。唯一支援的存取關聯來源是 VPC 端點 ID。如需詳細資訊，請參閱 [API Gateway 中私有 APIs的自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-custom-domains.html)。

## 語法
<a name="sam-property-api-domainaccessassociation-syntax"></a>

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

### YAML
<a name="sam-property-api-domainaccessassociation-syntax.yaml"></a>

```
 VpcEndpointId: String
```

## Properties
<a name="sam-property-api-domainaccessassociation-properties"></a>

 `VpcEndpointId`   <a name="sam-api-domainaccessassociation-vpcendpointid"></a>
與 API Gateway VPC 服務相關聯之 VPC 介面端點的端點 ID。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::DomainNameAccessAssociation` 資源的 `[ AccessAssociationSource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainnameaccessassociation.html#cfn-apigateway-domainnameaccessassociation-accessassociationsource)` 屬性。

# Route53Configuration
<a name="sam-property-api-route53configuration"></a>

設定 API 的 Route53 記錄集。

## 語法
<a name="sam-property-api-route53configuration-syntax"></a>

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

### YAML
<a name="sam-property-api-route53configuration-syntax.yaml"></a>

```
  [DistributionDomainName](#sam-api-route53configuration-distributiondomainname): String
  [EvaluateTargetHealth](#sam-api-route53configuration-evaluatetargethealth): Boolean
  [HostedZoneId](#sam-api-route53configuration-hostedzoneid): String
  [HostedZoneName](#sam-api-route53configuration-hostedzonename): String
  [IpV6](#sam-api-route53configuration-ipv6): Boolean
  Region: String
  SetIdentifier: String
  VpcEndpointDomainName: String
  VpcEndpointHostedZoneId: String
```

## Properties
<a name="sam-property-api-route53configuration-properties"></a>

 `DistributionDomainName`   <a name="sam-api-route53configuration-distributiondomainname"></a>
設定 API 自訂網域名稱的自訂分佈。  
*類型：*字串  
*必要*：否  
*預設*：使用 API Gateway 分佈。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup AliasTarget` 資源的 `[DNSName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget-1.html#cfn-route53-aliastarget-dnshostname)` 屬性。  
*其他備註*：[CloudFront 分佈](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html)的網域名稱。

 `EvaluateTargetHealth`   <a name="sam-api-route53configuration-evaluatetargethealth"></a>
當 EvaluateTargetHealth 為 true 時，別名記錄會繼承參考 AWS 資源的運作狀態，例如 Elastic Load Balancing 負載平衡器或託管區域中的其他記錄。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup AliasTarget` 資源的 `[EvaluateTargetHealth](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html#cfn-route53-aliastarget-evaluatetargethealth)` 屬性。  
*其他備註*：當別名目標為 CloudFront 分佈時，您無法將 EvaluateTargetHealth 設定為 true。

 `HostedZoneId`   <a name="sam-api-route53configuration-hostedzoneid"></a>
託管區域的 ID，您要在其中建立記錄。  
請指定 `HostedZoneName` 或 `HostedZoneId` 其中之一。若有多個託管區域的網域名稱相同，則您必須使用 `HostedZoneId` 以明確指定託管區域。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup RecordSet` 資源的 `[HostedZoneId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzoneid)` 屬性。

 `HostedZoneName`   <a name="sam-api-route53configuration-hostedzonename"></a>
您要在其中建立記錄的託管區域名稱。  
請指定 `HostedZoneName` 或 `HostedZoneId` 其中之一。若有多個託管區域的網域名稱相同，則您必須使用 `HostedZoneId` 以明確指定託管區域。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup RecordSet` 資源的 `[HostedZoneName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzonename)` 屬性。

 `IpV6`   <a name="sam-api-route53configuration-ipv6"></a>
設定此屬性時， 會 AWS SAM 建立`AWS::Route53::RecordSet`資源，並將提供的 HostedZone `AAAA`的 [Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset.html#cfn-route53-recordset-type) 設定為 。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Region`  <a name="sam-api-route53configuration-region"></a>
*僅限延遲型資源記錄集：*您建立資源的 Amazon EC2 區域，這是此資源記錄集指向的資源。資源通常是 AWS 資源，例如 EC2 執行個體或 ELB 負載平衡器，並且根據記錄類型由 IP 地址或 DNS 網域名稱參考。  
當 Amazon Route 53 收到網域名稱和類型的 DNS 查詢，而您已建立其延遲資源記錄集時，Route 53 會選取最低延遲介於最終使用者與相關聯 Amazon EC2 區域之間的延遲資源記錄集。Route 53 接著會傳回與所選資源記錄集相關聯的值。  
注意下列事項：  
+ 每個延遲資源記錄集只能指定一個 `ResourceRecord`。
+ 每個 Amazon EC2 區域都只能建立一個延遲資源記錄集。
+ 您不必為所有的 Amazon EC2 區域建立延遲資源記錄集。Route 53 會從您建立延遲資源記錄集的區域中，選擇具有最佳延遲的區域。
+ 您無法建立和延遲資源記錄集的 `Name` 和 `Type` 元素具有相同值的非延遲資源記錄集。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup``RecordSet`資料類型的 `[ Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-region)` 屬性。

`SetIdentifier`  <a name="sam-api-route53configuration-setidentifier"></a>
*沒有簡單路由政策的資源記錄集：*在具有相同名稱和類型組合的多個資源記錄集中用以區隔的識別碼，例如，多個加權資源記錄集名為 acme.example.com 且類型為 A。在一組具有相同名稱和類型的資源記錄集中，每個資源記錄集的 `SetIdentifier` 值都必須是唯一的。  
如需路由政策的資訊，請參閱《*Amazon Route 53 開發人員指南*》中的[選擇路由政策](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup``RecordSet`資料類型的 `[ SetIdentifier](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-setidentifier)` 屬性。

`VpcEndpointDomainName`  <a name="sam-api-route53configuration-vpcendpointdomainname"></a>
與 API Gateway VPC 服務相關聯之 VPC 介面端點的 DNS 名稱。只有私有網域才需要此屬性。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSet` `AliasTarget` 欄位的 `[DNSName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-aliastarget.html)` 屬性。

`VpcEndpointHostedZoneId`  <a name="sam-api-route53configuration-vpcendpointhostedzoneid"></a>
與 API Gateway VPC 服務相關聯之 VPC 介面端點的託管區域 ID。只有私有網域才需要此屬性。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSet` `AliasTarget` 欄位的 `[HostedZoneId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-aliastarget.html)` 屬性。

## 範例
<a name="sam-property-api-route53configuration--examples"></a>

### 基本範例
<a name="sam-property-api-route53configuration--examples--route-53-configuration-example"></a>

在此範例中，我們為 API 設定自訂網域和 Route 53 記錄集。

#### YAML
<a name="sam-property-api-route53configuration--examples--route-53-configuration-example--yaml"></a>

```
Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Domain:
        DomainName: www.example.com
        CertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/abcdef12-3456-7890-abcd-ef1234567890
        EndpointConfiguration: REGIONAL
        Route53:
          HostedZoneId: ABCDEFGHIJKLMNOP
```

# EndpointConfiguration
<a name="sam-property-api-endpointconfiguration"></a>

REST API 的端點類型。

## 語法
<a name="sam-property-api-endpointconfiguration-syntax"></a>

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

### YAML
<a name="sam-property-api-endpointconfiguration-syntax.yaml"></a>

```
  [IpAddressType](#sam-api-endpointconfiguration-ipaddresstype): String
  [Type](#sam-api-endpointconfiguration-type): String
  [VPCEndpointIds](#sam-api-endpointconfiguration-vpcendpointids): List
```

## Properties
<a name="sam-property-api-endpointconfiguration-properties"></a>

 `IpAddressType`   <a name="sam-api-endpointconfiguration-ipaddresstype"></a>
可叫用 API (RestApi) 的 IP 地址類型。  
*有效值*：`ipv4` 或 `dualstack`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `EndpointConfiguration` 資料類型的 `[IpAddressType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-endpointconfiguration.html#cfn-apigateway-restapi-endpointconfiguration-ipaddresstype)` 屬性。

 `Type`   <a name="sam-api-endpointconfiguration-type"></a>
REST API 的端點類型。  
*有效值*： `EDGE` 或 `REGIONAL`或 `PRIVATE`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `EndpointConfiguration` 資料類型的 `[Types](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-endpointconfiguration.html#cfn-apigateway-restapi-endpointconfiguration-types)` 屬性。

 `VPCEndpointIds`   <a name="sam-api-endpointconfiguration-vpcendpointids"></a>
要建立 Route53 別名之 REST API 的 VPC 端點 IDs 清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway::RestApi` `EndpointConfiguration` 資料類型的 `[VpcEndpointIds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-restapi-endpointconfiguration.html#cfn-apigateway-restapi-endpointconfiguration-vpcendpointids)` 屬性。

## 範例
<a name="sam-property-api-endpointconfiguration--examples"></a>

### EndpointConfiguration
<a name="sam-property-api-endpointconfiguration--examples--endpointconfiguration"></a>

端點組態範例

#### YAML
<a name="sam-property-api-endpointconfiguration--examples--endpointconfiguration--yaml"></a>

```
EndpointConfiguration:
  Type: PRIVATE
  VPCEndpointIds:
    - vpce-123a123a
    - vpce-321a321a
```

# AWS::Serverless::Application
<a name="sam-resource-application"></a>

將來自 [AWS Serverless Application Repository](https://serverlessrepo.aws.amazon.com/applications)或來自 Amazon S3 儲存貯體的無伺服器應用程式內嵌為巢狀應用程式。巢狀應用程式會部署為巢狀[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stack.html)資源，其中可包含多個其他資源，包括其他[AWS::Serverless::Application](#sam-resource-application)資源。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-application-syntax"></a>

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

### YAML
<a name="sam-resource-application-syntax.yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  [Location](#sam-application-location): String | ApplicationLocationObject
  [NotificationARNs](#sam-application-notificationarns): List
  [Parameters](#sam-application-parameters): Map
  [Tags](#sam-application-tags): Map
  [TimeoutInMinutes](#sam-application-timeoutinminutes): Integer
```

## Properties
<a name="sam-resource-application-properties"></a>

 `Location`   <a name="sam-application-location"></a>
巢狀應用程式的範本 URL、檔案路徑或位置物件。  
如果提供範本 URL，其必須遵循 [CloudFormation TemplateUrl 文件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl)中指定的格式，並包含有效的 CloudFormation 或 SAM 範本。[ApplicationLocationObject](sam-property-application-applicationlocationobject.md) 可用來指定已發佈至 的應用程式[AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html)。  
如果提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換應用程式。  
*類型*：字串 \$1 [ApplicationLocationObject](sam-property-application-applicationlocationobject.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::CloudFormation::Stack` 資源的 `[TemplateURL](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl)` 屬性。CloudFormation 版本不會採用 從 [ApplicationLocationObject](sam-property-application-applicationlocationobject.md)擷取應用程式 AWS Serverless Application Repository。

 `NotificationARNs`   <a name="sam-application-notificationarns"></a>
現有 Amazon SNS 主題的清單，其中會傳送堆疊事件的通知。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[NotificationARNs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-notificationarns)` 屬性。

 `Parameters`   <a name="sam-application-parameters"></a>
應用程式參數值。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-parameters)` 屬性。

 `Tags`   <a name="sam-application-tags"></a>
指定要新增到此應用程式之標籤的映射 （字串到字串）。金鑰和值僅限於英數字元。金鑰長度可以是 1 到 127 個 Unicode 字元，且字首不可為 aws：。值長度可以是 1 到 255 個 Unicode 字元。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::CloudFormation::Stack` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-tags)` 屬性。SAM 中的標籤屬性包含 Key：Value 對；在 CloudFormation 中包含標籤物件清單。建立堆疊時，SAM 會自動將`lambda:createdBy:SAM`標籤新增至此應用程式。此外，如果此應用程式來自 AWS Serverless Application Repository，則 SAM 也會自動新增兩個標籤 `serverlessrepo:applicationId:ApplicationId`和 `serverlessrepo:semanticVersion:SemanticVersion`。

 `TimeoutInMinutes`   <a name="sam-application-timeoutinminutes"></a>
 CloudFormation 等待巢狀堆疊達到 `CREATE_COMPLETE` 狀態的時間長度，以分鐘為單位。預設值為無逾時。當 CloudFormation 偵測到巢狀堆疊已達到 `CREATE_COMPLETE` 狀態時，它會將巢狀堆疊資源標記為父堆疊`CREATE_COMPLETE`中，並繼續建立父堆疊。如果逾時期間在巢狀堆疊達到 之前過期`CREATE_COMPLETE`， 會將巢狀堆疊 CloudFormation 標記為失敗，並復原巢狀堆疊和父堆疊。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CloudFormation::Stack` 資源的 `[TimeoutInMinutes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-timeoutinminutes)` 屬性。

## 傳回值
<a name="sam-resource-application-return-values"></a>

### Ref
<a name="sam-resource-application-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回基礎`AWS::CloudFormation::Stack`資源的資源名稱。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-application-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`Outputs.ApplicationOutputName`  <a name="Outputs.ApplicationOutputName-fn::getatt"></a>
名稱為 的堆疊輸出值`ApplicationOutputName`。

## 範例
<a name="sam-resource-application--examples"></a>

### SAR 應用程式
<a name="sam-resource-application--examples--sar-application"></a>

使用 Serverless Application Repository 範本的應用程式

#### YAML
<a name="sam-resource-application--examples--sar-application--yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  Location:
    ApplicationId: 'arn:aws:serverlessrepo:us-east-1:012345678901:applications/my-application'
    SemanticVersion: 1.0.0
  Parameters:
    StringParameter: parameter-value
    IntegerParameter: 2
```

### 一般應用程式
<a name="sam-resource-application--examples--normal-application"></a>

S3 url 的應用程式

#### YAML
<a name="sam-resource-application--examples--normal-application--yaml"></a>

```
Type: AWS::Serverless::Application
Properties:
  Location: https://s3.amazonaws.com/sam-s3-demo-bucket/template.yaml
```

# ApplicationLocationObject
<a name="sam-property-application-applicationlocationobject"></a>

已發佈至 的應用程式[AWS Serverless Application Repository](https://docs.aws.amazon.com/serverlessrepo/latest/devguide/what-is-serverlessrepo.html)。

## 語法
<a name="sam-property-application-applicationlocationobject-syntax"></a>

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

### YAML
<a name="sam-property-application-applicationlocationobject-syntax.yaml"></a>

```
  [ApplicationId](#sam-application-applicationlocationobject-applicationid): String
  [SemanticVersion](#sam-application-applicationlocationobject-semanticversion): String
```

## Properties
<a name="sam-property-application-applicationlocationobject-properties"></a>

 `ApplicationId`   <a name="sam-application-applicationlocationobject-applicationid"></a>
應用程式的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SemanticVersion`   <a name="sam-application-applicationlocationobject-semanticversion"></a>
應用程式的語義版本。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-application-applicationlocationobject--examples"></a>

### my-application
<a name="sam-property-application-applicationlocationobject--examples--my-application"></a>

應用程式位置物件範例

#### YAML
<a name="sam-property-application-applicationlocationobject--examples--my-application--yaml"></a>

```
Location:
  ApplicationId: 'arn:aws:serverlessrepo:us-east-1:012345678901:applications/my-application'
  SemanticVersion: 1.0.0
```

# AWS::Serverless::CapacityProvider
<a name="sam-resource-capacityprovider"></a>

 為啟用在客戶擁有的 Amazon Elastic Compute Cloud 執行個體上執行 Lambda 受管執行個體的 AWS Lambda 函數建立容量提供者。此資源是 Lambda 受管執行個體功能的一部分，可透過使用 Amazon EC2 定價模型，為大規模 Lambda 工作負載提供成本最佳化。

 容量提供者會管理 Amazon EC2 執行個體的生命週期，並為 Lambda 函數提供必要的基礎設施，以在客戶擁有的運算資源上執行，同時維護無伺服器程式設計模型。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM CloudFormation 轉換為 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-capacityprovider-syntax"></a>

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

### YAML
<a name="sam-resource-capacityprovider-syntax.yaml"></a>

```
Type: AWS::Serverless::CapacityProvider
Properties:
  [CapacityProviderName](#sam-capacityprovider-capacityprovidername): String
  [VpcConfig](#sam-capacityprovider-vpcconfig): VpcConfig
  [OperatorRole](#sam-capacityprovider-operatorrole): String
  [Tags](#sam-capacityprovider-tags): Map
  [PropagateTags](#sam-capacityprovider-propagatetags): Boolean
  [InstanceRequirements](#sam-capacityprovider-instancerequirements): InstanceRequirements
  [ScalingConfig](#sam-capacityprovider-scalingconfig): ScalingConfig
  [KmsKeyArn](#sam-capacityprovider-kmskeyarn): String
```

## Properties
<a name="sam-resource-capacityprovider-properties"></a>

 `CapacityProviderName`   <a name="sam-capacityprovider-capacityprovidername"></a>
容量提供者的名稱。此名稱在 AWS 您的帳戶和區域中必須是唯一的。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[CapacityProviderName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-capacityprovidername)` 屬性。

 `VpcConfig`   <a name="sam-capacityprovider-vpcconfig"></a>
容量提供者的 VPC 組態。指定要啟動 Amazon EC2 執行個體的 VPC 子網路和安全群組。  
*類型*：[VpcConfig](sam-property-capacityprovider-vpcconfig.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-vpcconfig)` 屬性。

 `OperatorRole`   <a name="sam-capacityprovider-operatorrole"></a>
 Lambda 運算子角色的 ARN，具有在客戶帳戶中建立和管理 Amazon EC2 執行個體和相關資源的許可。如果未提供， AWS SAM 會自動產生具有必要許可的角色。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[PermissionsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-permissionsconfig)`的 `[CapacityProviderOperatorRoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityproviderpermissionsconfig.html#cfn-lambda-capacityprovider-capacityproviderpermissionsconfig-capacityprovideroperatorrolearn)` 屬性。

 `Tags`   <a name="sam-capacityprovider-tags"></a>
要套用至容量提供者及其相關聯資源的鍵/值對映射。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-tags)` 屬性。中的 `Tags` 屬性 AWS SAM 包含鍵值對 （而 CloudFormation 此屬性包含標籤物件清單）。此外， AWS SAM 會自動將`lambda:createdBy:SAM`標籤新增至此 Lambda 函數，以及新增至為此函數產生的預設角色。

 `PropagateTags`   <a name="sam-capacityprovider-propagatetags"></a>
 指出是否將標籤從標籤屬性傳遞至您`AWS::Serverless::CapacityProvider`產生的資源。將此設定為 `True`以在產生的資源中傳播標籤。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `InstanceRequirements`   <a name="sam-capacityprovider-instancerequirements"></a>
 容量提供者可以使用之運算執行個體類型的規格。這包括架構需求和 `allowed`或 `excluded` 執行個體類型。  
*類型*：[InstanceRequirements](sam-property-capacityprovider-instancerequirements.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[InstanceRequirements](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements)` 屬性。

 `ScalingConfig`   <a name="sam-capacityprovider-scalingconfig"></a>
 容量提供者的擴展組態。定義容量提供者如何根據需求擴展 Amazon EC2 執行個體。  
*類型*：[ScalingConfig](sam-property-capacityprovider-scalingconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[CapacityProviderScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig)` 屬性。

 `KmsKeyArn`   <a name="sam-capacityprovider-kmskeyarn"></a>
用於加密容量提供者靜態和傳輸中資料的 AWS KMS 金鑰 ARN。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-kmskeyarn)` 屬性。

## 傳回值
<a name="sam-resource-capacityprovider-return-values"></a>

### Ref
<a name="sam-resource-capacityprovider-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回容量提供者的名稱。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-capacityprovider-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`Arn`  <a name="Arn-fn::getatt"></a>
容量提供者的 ARN。

## 範例
<a name="sam-resource-capacityprovider-examples"></a>

### 基本容量提供者
<a name="sam-resource-capacityprovider-examples-basic"></a>

下列範例會使用 VPC 組態建立基本容量提供者。

```
MyCapacityProvider:
  Type: AWS::Serverless::CapacityProvider
  Properties:
    CapacityProviderName: my-capacity-provider
    VpcConfig:
      SubnetIds:
        - subnet-12345678
        - subnet-87654321
      SecurityGroupIds:
        - sg-12345678
    Tags:
      Environment: Production
      Team: ServerlessTeam
```

### 具有擴展功能的進階容量提供者
<a name="sam-resource-capacityprovider-examples-advanced"></a>

下列範例會建立具有自訂執行個體需求和擴展組態的容量提供者。

```
AdvancedCapacityProvider:
  Type: AWS::Serverless::CapacityProvider
  Properties:
    CapacityProviderName: advanced-capacity-provider
    VpcConfig:
      SubnetIds:
        - subnet-12345678
        - subnet-87654321
      SecurityGroupIds:
        - sg-12345678
    OperatorRole: arn:aws:iam::123456789012:role/MyCapacityProviderRole
    PropagateTags: true
    InstanceRequirements:
      Architectures:
        - x86_64
      ExcludedTypes:
        - t2.micro
    ScalingConfig:
      MaxInstanceCount: 10
      ManualScalingPolicies:
        AverageCPUUtilization: 70.0
    KmsKeyArn: arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
    Tags:
      Environment: Production
      CostCenter: Engineering
```

# VpcConfig
<a name="sam-property-capacityprovider-vpcconfig"></a>

設定容量提供者的 VPC 設定，包括將啟動 EC2 執行個體的子網路和安全群組。

## 語法
<a name="sam-property-capacityprovider-vpcconfig-syntax"></a>

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

### YAML
<a name="sam-property-capacityprovider-vpcconfig-syntax.yaml"></a>

```
[SubnetIds](#sam-capacityprovider-vpcconfig-subnetids): List
[SecurityGroupIds](#sam-capacityprovider-vpcconfig-securitygroupids): List
```

## Properties
<a name="sam-property-capacityprovider-vpcconfig-properties"></a>

 `SubnetIds`   <a name="sam-capacityprovider-vpcconfig-subnetids"></a>
將啟動 EC2 執行個體IDs 清單。至少必須指定一個子網路。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-vpcconfig) `的 `[SubnetIds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityprovidervpcconfig.html#cfn-lambda-capacityprovider-capacityprovidervpcconfig-subnetids)` 屬性。

 `SecurityGroupIds`   <a name="sam-capacityprovider-vpcconfig-securitygroupids"></a>
要與 EC2 執行個體建立關聯的安全群組 IDs 清單。如果未指定，則會使用 VPC 的預設安全群組。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[SecurityGroupIds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityprovidervpcconfig.html#cfn-lambda-capacityprovider-capacityprovidervpcconfig-securitygroupids)`的 `[VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-vpcconfig)` 屬性。

## 範例
<a name="sam-property-capacityprovider-vpcconfig-examples"></a>

### VPC 組態
<a name="sam-property-capacityprovider-vpcconfig-examples-basic"></a>

下列範例顯示具有多個子網路和安全群組的 VPC 組態。

```
VpcConfig:
  SubnetIds:
    - subnet-12345678
    - subnet-87654321
  SecurityGroupIds:
    - sg-12345678
    - sg-87654321
```

# InstanceRequirements
<a name="sam-property-capacityprovider-instancerequirements"></a>

指定容量提供者將啟動之 EC2 執行個體的需求，包括架構和執行個體類型限制。

## 語法
<a name="sam-property-capacityprovider-instancerequirements-syntax"></a>

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

### YAML
<a name="sam-property-capacityprovider-instancerequirements-syntax.yaml"></a>

```
[Architectures](#sam-capacityprovider-instancerequirements-architectures): List
[AllowedTypes](#sam-capacityprovider-instancerequirements-allowedtypes): List
[ExcludedTypes](#sam-capacityprovider-instancerequirements-excludedtypes): List
```

**注意**  
您可以選擇在定義容量提供者的執行個體需求`ExcludedTypes`時指定 `AllowedTypes`或 ，但不能同時指定兩者。

## Properties
<a name="sam-property-capacityprovider-instancerequirements-properties"></a>

 `Architectures`   <a name="sam-capacityprovider-instancerequirements-architectures"></a>
容量提供者執行個體的指示集架構。  
*有效值*：`x86_64` 或 `arm64`  
*類型：*清單  
*必要*：否  
*預設*：`x86_64`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[InstanceRequirements](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements)`的 `[Architectures](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-instancerequirements.html#cfn-lambda-capacityprovider-instancerequirements-architectures)` 屬性。

 `AllowedTypes`   <a name="sam-capacityprovider-instancerequirements-allowedtypes"></a>
容量提供者執行個體允許的 EC2 執行個體類型清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[InstanceRequirements](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements)`的 `[AllowedInstanceTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-instancerequirements.html#cfn-lambda-capacityprovider-instancerequirements-allowedinstancetypes)` 屬性。

 `ExcludedTypes`   <a name="sam-capacityprovider-instancerequirements-excludedtypes"></a>
要從容量提供者排除的 EC2 執行個體類型清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[InstanceRequirements](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements)`的 `[ExcludedInstanceTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-instancerequirements.html#cfn-lambda-capacityprovider-instancerequirements-excludedinstancetypes)` 屬性。

## 範例
<a name="sam-property-capacityprovider-instancerequirements-examples"></a>

### 執行個體需求組態
<a name="sam-property-capacityprovider-instancerequirements-examples-basic"></a>

下列範例顯示具有特定架構和執行個體類型限制條件的執行個體需求。

```
InstanceRequirements:
  Architectures:
    - x86_64
  ExcludedTypes:
    - t2.micro
```

# ScalingConfig
<a name="sam-property-capacityprovider-scalingconfig"></a>

設定容量提供者如何根據需求擴展 EC2 執行個體，包括執行個體上限和擴展政策。

## 語法
<a name="sam-property-capacityprovider-scalingconfig-syntax"></a>

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

### YAML
<a name="sam-property-capacityprovider-scalingconfig-syntax.yaml"></a>

```
[MaxVCpuCount](#sam-capacityprovider-scalingconfig-maxvcpucount): Integer
[AverageCPUUtilization](#sam-capacityprovider-scalingconfig-averagecpuutilization): Double
```

## Properties
<a name="sam-property-capacityprovider-scalingconfig-properties"></a>

 `MaxVCpuCount`   <a name="sam-capacityprovider-scalingconfig-maxvcpucount"></a>
容量提供者可在所有運算執行個體中佈建vCPUs 數量上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::CapacityProvider` 資源`[CapacityProviderScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig)`的 `[MaxVCpuCount](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityproviderscalingconfig.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig-maxvcpucount)` 屬性。

 `AverageCPUUtilization`   <a name="sam-capacityprovider-scalingconfig-averagecpuutilization"></a>
擴展決策的目標平均 CPU 使用率百分比 (0-100)。當平均 CPU 使用率超過此閾值時，容量提供者將擴展 Amazon EC2 執行個體。指定時， `[CapacityProviderScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig)`會 AWS SAM 建構 `AWS::Lambda::CapacityProvider` 資源，並將 `[ScalingMode](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityproviderscalingconfig.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig-scalingmode)`設定為 `'Manual'`，並將 `[ScalingPolicies](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-capacityprovider-capacityproviderscalingconfig.html#cfn-lambda-capacityprovider-capacityproviderscalingconfig-scalingpolicies)`設定為 `[{PredefinedMetricType: 'LambdaCapacityProviderAverageCPUUtilization', TargetValue: <this value>}]`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-capacityprovider-scalingconfig-examples"></a>

### 擴展組態
<a name="sam-property-capacityprovider-scalingconfig-examples-basic"></a>

下列範例顯示具有最大 VCpu 計數和平均 CPU 使用率的擴展組態。

```
ScalingConfig:
  MaxVCpuCount: 10
  AverageCPUUtilization: 70.0
```

# AWS::Serverless::Connector
<a name="sam-resource-connector"></a>

設定兩個資源之間的許可。如需連接器的簡介，請參閱 [使用 AWS SAM 連接器管理資源許可](managing-permissions-connectors.md)。

如需所產生 AWS CloudFormation 資源的詳細資訊，請參閱 [CloudFormation 當您指定 時產生的資源 AWS::Serverless::Connector](sam-specification-generated-resources-connector.md)。

若要提供連接器的意見回饋，請在 *serverless-application-model AWS GitHub儲存庫*[提交新問題](https://github.com/aws/serverless-application-model/issues/new?assignees=&labels=area%2Fconnectors,stage%2Fneeds-triage&template=other.md&title=%28Feature%20Request%29)。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-connector-syntax"></a>

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

**注意**  
對於大多數使用案例，我們建議使用內嵌連接器語法。內嵌在來源資源中可讓您隨著時間更輕鬆地讀取和維護。當您需要參考不在相同 AWS SAM 範本內的來源資源時，例如巢狀堆疊中的資源或共用資源，請使用 `AWS::Serverless::Connector` 語法。

### 內嵌連接器
<a name="sam-resource-connector-syntax-embedded"></a>

```
<source-resource-logical-id>:
  Connectors:
    <connector-logical-id:
      Properties:
        [Destination](#sam-connector-destination): ResourceReference | List of ResourceReference
        [Permissions](#sam-connector-permissions): List
        [SourceReference](#sam-connector-sourcereference): SourceReference
```

### AWS::Serverless::Connector
<a name="sam-resource-connector-syntax-connector"></a>

```
Type: AWS::Serverless::Connector
Properties:
  [Destination](#sam-connector-destination): ResourceReference | List of ResourceReference
  [Permissions](#sam-connector-permissions): List
  [Source](#sam-connector-source): ResourceReference
```

## Properties
<a name="sam-resource-connector-properties"></a>

 `Destination`   <a name="sam-connector-destination"></a>
目的地資源。  
*類型*：[ResourceReference](sam-property-connector-resourcereference.md) \$1 [ResourceReference](sam-property-connector-resourcereference.md) 的清單  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Permissions`   <a name="sam-connector-permissions"></a>
允許來源資源在目的地資源上執行的許可類型。  
`Read` 包含允許從資源讀取資料的 AWS Identity and Access Management (IAM) 動作。  
`Write` 包含允許啟動資料並將資料寫入資源的 IAM 動作。  
*有效值*：`Read` 或 `Write`  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Source`   <a name="sam-connector-source"></a>
來源資源。使用 `AWS::Serverless::Connector`語法時為必要。  
*類型*：[ResourceReference](sam-property-connector-resourcereference.md)  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SourceReference`   <a name="sam-connector-sourcereference"></a>
來源資源。  
定義來源資源的其他屬性時，請使用 搭配內嵌連接器語法。
*類型*：[SourceReference](sam-property-connector-sourcereference.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-resource-connector-examples"></a>

### 內嵌連接器
<a name="sam-resource-connector-examples-embedded"></a>

下列範例使用內嵌連接器來定義 AWS Lambda 函數與 Amazon DynamoDB 資料表之間的`Write`資料連線：

```
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyTable:
    Type: AWS::Serverless::SimpleTable
  MyFunction:
    Type: AWS::Serverless::Function
    Connectors:
      MyConn:
        Properties:
          Destination:
            Id: MyTable
          Permissions:
            - Write
    ...
```

下列範例使用內嵌連接器來定義 `Read`和 `Write`許可：

```
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Connectors:
      MyConn:
        Properties:
          Destination:
            Id: MyTable
          Permissions:
            - Read
            - Write
  MyTable:
    Type: AWS::DynamoDB::Table
    ...
```

下列範例使用內嵌連接器來定義具有 以外屬性的來源資源`Id`：

```
Transform: AWS::Serverless-2016-10-31
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Connectors:
      ApitoLambdaConn:
        Properties:
          SourceReference:
            Qualifier: Prod/GET/foobar
          Destination:
            Id: MyTable
          Permissions:
            - Read
            - Write
  MyTable:
    Type: AWS::DynamoDB::Table
    ...
```

### AWS::Serverless::Connector
<a name="sam-resource-connector--examples-connector"></a>

下列範例使用 [AWS::Serverless::Connector](#sam-resource-connector) 資源從 讀取和寫入 Amazon DynamoDB 資料表的 AWS Lambda 函數：

```
MyConnector:
  Type: AWS::Serverless::Connector
  Properties:
    Source:
      Id: MyFunction
    Destination:
      Id: MyTable
    Permissions:
      - Read
      - Write
```

下列範例使用 [AWS::Serverless::Connector](#sam-resource-connector) 資源將 Lambda 函數寫入 Amazon SNS 主題，而這兩個資源位於相同的範本中：

```
MyConnector:
  Type: AWS::Serverless::Connector
  Properties:
    Source:
      Id: MyLambda
    Destination:
      Id: MySNSTopic
    Permissions:
      - Write
```

下列範例使用 [AWS::Serverless::Connector](#sam-resource-connector) 資源將 Amazon SNS 主題寫入 Lambda 函數，然後寫入 Amazon DynamoDB 資料表，其中包含相同範本中的所有資源：

```
Transform: AWS::Serverless-2016-10-31
Resources:
  Topic:
    Type: AWS::SNS::Topic
    Properties:
      Subscription:
        - Endpoint: !GetAtt Function.Arn
          Protocol: lambda

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs16.x
      Handler: index.handler
      InlineCode: |
        const AWS = require('aws-sdk');
        exports.handler = async (event, context) => {
          const docClient = new AWS.DynamoDB.DocumentClient();
          await docClient.put({ 
            TableName: process.env.TABLE_NAME, 
            Item: {
              id: context.awsRequestId,
              event: JSON.stringify(event)
            }
          }).promise();
        };
      Environment:
        Variables:
          TABLE_NAME: !Ref Table

  Table:
    Type: AWS::Serverless::SimpleTable

  TopicToFunctionConnector:
    Type: AWS::Serverless::Connector
    Properties:
      Source: 
        Id: Topic
      Destination: 
        Id: Function
      Permissions:
        - Write

  FunctionToTableConnector:
    Type: AWS::Serverless::Connector
    Properties:
      Source: 
        Id: Function
      Destination: 
        Id: Table
      Permissions:
        - Write
```

以下是上述範例中的轉換 AWS CloudFormation 範本：

```
"FunctionToTableConnectorPolicy": {
  "Type": "AWS::IAM::ManagedPolicy",
  "Metadata": {
    "aws:sam:connectors": {
      "FunctionToTableConnector": {
        "Source": {
          "Type": "AWS::Lambda::Function"
        },
        "Destination": {
          "Type": "AWS::DynamoDB::Table"
        }
      }
    }
  },
  "Properties": {
    "PolicyDocument": {
      "Version": "2012-10-17",		 	 	 
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "dynamodb:PutItem",
            "dynamodb:UpdateItem",
            "dynamodb:DeleteItem",
            "dynamodb:BatchWriteItem",
            "dynamodb:PartiQLDelete",
            "dynamodb:PartiQLInsert",
            "dynamodb:PartiQLUpdate"
          ],
          "Resource": [
            {
              "Fn::GetAtt": [
                "MyTable",
                "Arn"
              ]
            },
            {
              "Fn::Sub": [
                "${DestinationArn}/index/*",
                {
                  "DestinationArn": {
                    "Fn::GetAtt": [
                      "MyTable",
                      "Arn"
                    ]
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    "Roles": [
      {
        "Ref": "MyFunctionRole"
      }
    ]
  }
}
```

# ResourceReference
<a name="sam-property-connector-resourcereference"></a>

資源類型使用[AWS::Serverless::Connector](sam-resource-connector.md)的資源參考。

**注意**  
對於相同範本中的資源，請提供 `Id`。對於不在相同範本中的資源，請使用其他屬性的組合。如需詳細資訊，請參閱[AWS SAM 連接器參考](reference-sam-connector.md)。

## 語法
<a name="sam-property-connector-resourcereference-syntax"></a>

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

### YAML
<a name="sam-property-connector-resourcereference-syntax.yaml"></a>

```
  [Arn](#sam-connector-resourcereference-arn): String
  [Id](#sam-connector-resourcereference-id): String
  [Name](#sam-connector-resourcereference-name): String
  [Qualifier](#sam-connector-resourcereference-qualifier): String
  [QueueUrl](#sam-connector-resourcereference-queueurl): String
  [ResourceId](#sam-connector-resourcereference-resourceid): String
  [RoleName](#sam-connector-resourcereference-rolename): String
  [Type](#sam-connector-resourcereference-type): String
```

## Properties
<a name="sam-property-connector-resourcereference-properties"></a>

 `Arn`   <a name="sam-connector-resourcereference-arn"></a>
資源的 ARN。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Id`   <a name="sam-connector-resourcereference-id"></a>
相同範本中資源的[邏輯 ID](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html)。  
指定 `Id` 時，如果連接器產生 AWS Identity and Access Management (IAM) 政策，則會從資源 推斷與這些政策相關聯的 IAM 角色`Id`。`Id` 未指定 時，請為連接器提供 `RoleName` 資源，以將產生的 IAM 政策連接至 IAM 角色。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Name`   <a name="sam-connector-resourcereference-name"></a>
資源的名稱。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Qualifier`   <a name="sam-connector-resourcereference-qualifier"></a>
資源的限定詞縮小其範圍。 會`Qualifier`取代資源限制條件 ARN 結尾`*`的值。如需範例，請參閱 [API Gateway 叫用 Lambda 函數](#sam-property-connector-resourcereference--examples--api-gateway-invoking-a-lambda-function)。  
限定詞定義因資源類型而異。如需支援的來源和目的地資源類型清單，請參閱 [AWS SAM 連接器參考](reference-sam-connector.md)。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `QueueUrl`   <a name="sam-connector-resourcereference-queueurl"></a>
Amazon SQS 佇列 URL。此屬性僅適用於 Amazon SQS 資源。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ResourceId`   <a name="sam-connector-resourcereference-resourceid"></a>
資源的 ID。例如，API Gateway API ID。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RoleName`   <a name="sam-connector-resourcereference-rolename"></a>
與資源相關聯的角色名稱。  
指定 `Id` 時，如果連接器產生 IAM 政策，則會從資源 推斷與這些政策相關聯的 IAM 角色`Id`。`Id` 未指定 時，請提供 `RoleName` 資源供連接器將產生的 IAM 政策連接至 IAM 角色。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Type`   <a name="sam-connector-resourcereference-type"></a>
資源的 CloudFormation 類型。如需詳細資訊，請前往[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-connector-resourcereference--examples"></a>

### API Gateway 叫用 Lambda 函數
<a name="sam-property-connector-resourcereference--examples--api-gateway-invoking-a-lambda-function"></a>

下列範例使用 [AWS::Serverless::Connector](sam-resource-connector.md) 資源來允許 Amazon API Gateway 叫用 AWS Lambda 函數。

#### YAML
<a name="sam-property-connector-resourcereference--examples--api-gateway-invoking-a-lambda-function--yaml"></a>

```
Transform: AWS::Serverless-2016-10-31
Resources:
  MyRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Effect: Allow
            Action: sts:AssumeRole
            Principal:
              Service: lambda.amazonaws.com
      ManagedPolicyArns:
        - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      Role: !GetAtt MyRole.Arn
      Runtime: nodejs16.x
      Handler: index.handler
      Code:
        ZipFile: |
          exports.handler = async (event) => {
            return {
              statusCode: 200,
              body: JSON.stringify({
                "message": "It works!"
              }),
            };
          };

  MyApi:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: MyApi
      ProtocolType: HTTP

  MyStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      ApiId: !Ref MyApi
      StageName: prod
      AutoDeploy: True

  MyIntegration:
    Type: AWS::ApiGatewayV2::Integration
    Properties:
      ApiId: !Ref MyApi
      IntegrationType: AWS_PROXY
      IntegrationUri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations
      IntegrationMethod: POST
      PayloadFormatVersion: "2.0"

  MyRoute:
    Type: AWS::ApiGatewayV2::Route
    Properties:
      ApiId: !Ref MyApi
      RouteKey: GET /hello
      Target: !Sub integrations/${MyIntegration}

  MyConnector:
    Type: AWS::Serverless::Connector
    Properties:
      Source: # Use 'Id' when resource is in the same template
        Type: AWS::ApiGatewayV2::Api
        ResourceId: !Ref MyApi
        Qualifier: prod/GET/hello # Or "*" to allow all routes
      Destination: # Use 'Id' when resource is in the same template
        Type: AWS::Lambda::Function
        Arn: !GetAtt MyFunction.Arn
      Permissions:
        - Write

Outputs:
  Endpoint:
    Value: !Sub https://${MyApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/prod/hello
```

# SourceReference
<a name="sam-property-connector-sourcereference"></a>

資源[AWS::Serverless::Connector](sam-resource-connector.md)類型使用的來源資源參考。

## 語法
<a name="sam-property-connector-sourcereference-syntax"></a>

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

### YAML
<a name="sam-property-connector-sourcereference-syntax.yaml"></a>

```
[Qualifier](#sam-connector-sourcereference-qualifier): String
```

## Properties
<a name="sam-property-connector-sourcereference-properties"></a>

 `Qualifier`   <a name="sam-connector-sourcereference-qualifier"></a>
資源的限定詞縮小其範圍。 會`Qualifier`取代資源限制條件 ARN 結尾`*`的值。  
限定詞定義因資源類型而異。如需支援的來源和目的地資源類型清單，請參閱 [AWS SAM 連接器參考](reference-sam-connector.md)。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

## 範例
<a name="sam-property-connector-sourcereference--examples"></a>

**下列範例使用內嵌連接器來定義具有 以外屬性的來源資源`Id`：**

```
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Connectors:
      ApitoLambdaConn:
        Properties:
          SourceReference:
            Qualifier: Prod/GET/foobar
          Destination:
            Id: MyTable
          Permissions:
            - Read
            - Write
  MyTable:
    Type: AWS::DynamoDB::Table
    ...
```

# AWS::Serverless::Function
<a name="sam-resource-function"></a>

建立觸發 AWS Lambda 函數的函數、 AWS Identity and Access Management (IAM) 執行角色和事件來源映射。

[AWS::Serverless::Function](#sam-resource-function) 資源也支援 `Metadata` 資源屬性，因此您可以指示 AWS SAM 建置應用程式所需的自訂執行時間。如需建置自訂執行時間的詳細資訊，請參閱 [在 中使用自訂執行期建置 Lambda 函數 AWS SAM](building-custom-runtimes.md)。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

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

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

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

```
Type: AWS::Serverless::Function
Properties:
  [Architectures](#sam-function-architectures): List
  [AssumeRolePolicyDocument](#sam-function-assumerolepolicydocument): JSON
  [AutoPublishAlias](#sam-function-autopublishalias): String
  AutoPublishAliasAllProperties: Boolean
  [AutoPublishCodeSha256](#sam-function-autopublishcodesha256): String
  [CapacityProviderConfig](#sam-function-capacityproviderconfig): CapacityProviderConfig
  [CodeSigningConfigArn](#sam-function-codesigningconfigarn): String
  [CodeUri](#sam-function-codeuri): String | FunctionCode
  [DeadLetterQueue](#sam-function-deadletterqueue): Map | DeadLetterQueue
  [DeploymentPreference](#sam-function-deploymentpreference): DeploymentPreference
  [Description](#sam-function-description): String
  [DurableConfig](#sam-function-durableconfig): DurableConfig
  [Environment](#sam-function-environment): [Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html)
  [EphemeralStorage](#sam-function-ephemeralstorage): [EphemeralStorage](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-ephemeralstorage)
  [EventInvokeConfig](#sam-function-eventinvokeconfig): EventInvokeConfiguration
  [Events](#sam-function-events): EventSource
  [FileSystemConfigs](#sam-function-filesystemconfigs): List
  [FunctionName](#sam-function-functionname): String
  [FunctionScalingConfig](#sam-function-functionscalingconfig): FunctionScalingConfig
  [FunctionUrlConfig](#sam-function-functionurlconfig): FunctionUrlConfig
  [Handler](#sam-function-handler): String
  [ImageConfig](#sam-function-imageconfig): [ImageConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-imageconfig)
  [ImageUri](#sam-function-imageuri): String
  [InlineCode](#sam-function-inlinecode): String
  [KmsKeyArn](#sam-function-kmskeyarn): String
  [Layers](#sam-function-layers): List
  LoggingConfig: [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-loggingconfig.html)
  [MemorySize](#sam-function-memorysize): Integer
  [PackageType](#sam-function-packagetype): String
  [PermissionsBoundary](#sam-function-permissionsboundary): String
  [Policies](#sam-function-policies): String | List | Map
  [PublishToLatestPublished](#sam-function-publishtolatestpublished): Boolean
  PropagateTags: Boolean
  [ProvisionedConcurrencyConfig](#sam-function-provisionedconcurrencyconfig): [ProvisionedConcurrencyConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html#cfn-lambda-alias-provisionedconcurrencyconfig)
  RecursiveLoop: String
  [ReservedConcurrentExecutions](#sam-function-reservedconcurrentexecutions): Integer
  [Role](#sam-function-role): String
  [RolePath](#sam-function-rolepath): String
  [Runtime](#sam-function-runtime): String
  RuntimeManagementConfig: [RuntimeManagementConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-runtimemanagementconfig.html)
  SnapStart: [SnapStart](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-snapstart.html)
  [SourceKMSKeyArn](#sam-function-sourcekmskeyarn): String
  [Tags](#sam-function-tags): Map
  [TenancyConfig](#sam-function-tenancyconfig): TenancyConfig
  [Timeout](#sam-function-timeout): Integer
  [Tracing](#sam-function-tracing): String
  [VersionDescription](#sam-function-versiondescription): String
  [VersionDeletionPolicy](#sam-function-versiondeletionpolicy): String
  [VpcConfig](#sam-function-vpcconfig): [VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html)
```

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

 `Architectures`   <a name="sam-function-architectures"></a>
函數的指示集架構。  
如需此屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 指令集架構](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html)。  
*有效值*： `x86_64`或 之一 `arm64`  
*類型：*清單  
*必要*：否  
*預設*：`x86_64`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Architectures](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-architectures)` 屬性。

 `AssumeRolePolicyDocument`   <a name="sam-function-assumerolepolicydocument"></a>
為此`Role`函數建立的預設 新增 AssumeRolePolicyDocument。如果未指定此屬性， 會為此函數 AWS SAM 新增預設擔任角色。  
*類型*：JSON  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::IAM::Role` 資源的 `[AssumeRolePolicyDocument](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-assumerolepolicydocument)` 屬性。 會將此屬性 AWS SAM 新增至此函數產生的 IAM 角色。如果此函數提供角色的 Amazon Resource Name (ARN)，則此屬性不會執行任何動作。

 `AutoPublishAlias`   <a name="sam-function-autopublishalias"></a>
Lambda 別名的名稱。如需 Lambda 別名的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 函數別名](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)。如需使用此屬性的範例，請參閱 [使用 逐步部署無伺服器應用程式 AWS SAM](automating-updates-to-serverless-apps.md)。  
AWS SAM 會在設定此屬性時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html) [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html)和資源。如需此案例的資訊，請參閱 [已指定 AutoPublishAlias 屬性](sam-specification-generated-resources-function.md#sam-specification-generated-resources-function-autopublishalias)。如需所產生 CloudFormation 資源的一般資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AutoPublishAliasAllProperties`   <a name="sam-function-autopublishaliasallproperties"></a>
指定何時建立新的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html) 。當 時`true`，會在修改 Lambda 函數中的任何屬性時建立新的 Lambda 版本。當 時`false`，只有在修改下列任何屬性時，才會建立新的 Lambda 版本：  
+ `Environment`, `MemorySize`, 或 `SnapStart`.
+ 導致 `Code` 屬性更新的任何變更，例如 `CodeDict`、 `ImageUri`或 `InlineCode`。
此屬性`AutoPublishAlias`需要定義。  
如果也指定 `AutoPublishCodeSha256` ，則其行為優先於 `AutoPublishAliasAllProperties: true`。  
*類型*：布林值  
*必要*：否  
*預設值*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AutoPublishCodeSha256`   <a name="sam-function-autopublishcodesha256"></a>
使用時，此字串會搭配 `CodeUri`值運作，以判斷是否需要發佈新的 Lambda 版本。此屬性通常用於解決下列部署問題：部署套件會存放在 Amazon S3 位置，並以具有更新 Lambda 函數程式碼的新部署套件取代，但 `CodeUri` 屬性保持不變 （而不是將新的部署套件上傳至新的 Amazon S3 位置，並將 `CodeUri` 變更為新的位置）。  
此問題由具有下列特性的 AWS SAM 範本標記：  
+ `DeploymentPreference` 物件已設定為逐步部署 （如中所述[使用 逐步部署無伺服器應用程式 AWS SAM](automating-updates-to-serverless-apps.md))
+ `AutoPublishAlias` 屬性已設定，不會在部署之間變更
+ `CodeUri` 屬性已設定，不會在部署之間變更。
在此案例中，更新 `AutoPublishCodeSha256` 會導致新的 Lambda 版本成功建立。不過，部署到 Amazon S3 的新函數程式碼將無法辨識。若要辨識新的函數程式碼，請考慮在 Amazon S3 儲存貯體中使用版本控制。為您的 Lambda 函數指定 `Version` 屬性，並將儲存貯體設定為一律使用最新的部署套件。  
在此案例中，若要成功觸發逐步部署，您必須提供 的唯一值`AutoPublishCodeSha256`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `CapacityProviderConfig`   <a name="sam-function-capacityproviderconfig"></a>
設定將附加發佈版本函數的容量提供者。這可讓函數在由 Lambda 受管執行個體管理的客戶擁有 EC2 執行個體上執行。  
*類型*：[CapacityProviderConfig](sam-property-function-capacityproviderconfig.md)  
*必要*：否  
*CloudFormation 相容性*：SAM 會扁平化傳遞至 `AWS::Lambda::Function` 資源屬性的 `[CapacityProviderConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-capacityproviderconfig)` 屬性，並重建巢狀結構。

 `CodeSigningConfigArn`   <a name="sam-function-codesigningconfigarn"></a>
[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-codesigningconfig.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-codesigningconfig.html) 資源的 ARN，用於啟用此函數的程式碼簽署。如需有關程式碼簽署的詳細資訊，請參閱[為您的 AWS SAM 應用程式設定程式碼簽署](authoring-codesigning.md)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[CodeSigningConfigArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-codesigningconfigarn)` 屬性。

 `CodeUri`   <a name="sam-function-codeuri"></a>
函數的程式碼。接受的值包括：  
+ 函數的 Amazon S3 URI。例如 `s3://bucket-123456789/sam-app/1234567890abcdefg`。
+ 函數的本機路徑。例如 `hello_world/`。
+ [FunctionCode](sam-property-function-functioncode.md) 物件。
如果您提供函數的 Amazon S3 URI 或[FunctionCode](sam-property-function-functioncode.md)物件，則必須參考有效的 [Lambda 部署套件](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)。  
如果您提供本機檔案路徑，請使用 在 AWS SAM CLI部署時上傳本機檔案。如需詳細資訊，請參閱 [如何在部署時 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
如果您在 `CodeUri` 屬性中使用內部函數， AWS SAM 將無法正確剖析值。請考慮改用 [AWS：：LanguageExtensions 轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-languageextensions.html)。
*類型*：【字串 \$1 [FunctionCode](sam-property-function-functioncode.md) 】  
*必要*：有條件限制。當 `PackageType` 設定為 時`Zip`，`InlineCode`需要其中一個 `CodeUri`或 。  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::Function` 資源的 `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` 屬性。巢狀 Amazon S3 屬性的名稱不同。

 `DeadLetterQueue`   <a name="sam-function-deadletterqueue"></a>
設定 Amazon Simple Notification Service (Amazon SNS) 主題或 Amazon Simple Queue Service (Amazon SQS) 佇列，其中 Lambda 會傳送無法處理的事件。如需無效字母佇列功能的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async-retain-records.html#invocation-dlq)。  
如果您 Lambda 函數的事件來源是 Amazon SQS 佇列，請為來源佇列設定無效字母佇列，而非 Lambda 函數。您為函數設定的無效字母佇列會用於函數[的非同步叫用佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html)，而非事件來源佇列。
*類型*：映射 \$1 [DeadLetterQueue](sam-property-function-deadletterqueue.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::Function` 資源的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html)` 屬性。在 CloudFormation 類型衍生自 `TargetArn`，而在 中 AWS SAM ，您必須將 類型與 一起傳遞`TargetArn`。

 `DeploymentPreference`   <a name="sam-function-deploymentpreference"></a>
啟用逐步 Lambda 部署的設定。  
如果指定`DeploymentPreference`物件， 會 AWS SAM 建立[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-application.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-application.html)稱為 的 `ServerlessDeploymentApplication`（每個堆疊一個）`<function-logical-id>DeploymentGroup`、[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html)稱為 的 和[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html)稱為 的 `CodeDeployServiceRole`。  
*類型*：[DeploymentPreference](sam-property-function-deploymentpreference.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*另請參閱*：如需此屬性的詳細資訊，請參閱 [使用 逐步部署無伺服器應用程式 AWS SAM](automating-updates-to-serverless-apps.md)。

 `Description`   <a name="sam-function-description"></a>
函數的敘述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description)` 屬性。

 `DurableConfig`   <a name="sam-function-durableconfig"></a>
耐用函數的組態。使用自動檢查點和重播功能啟用有狀態執行。  
*類型*：[DurableConfig](sam-property-function-durableconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Environment`   <a name="sam-function-environment"></a>
執行時間環境的組態。  
*類型*：[Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html)` 屬性。

 `EphemeralStorage`   <a name="sam-function-ephemeralstorage"></a>
指定 中 Lambda 函數可用磁碟空間的物件，以 MB 為單位`/tmp`。  
如需此屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 執行環境](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html)。  
*類型*：[EphemeralStorage](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-ephemeralstorage)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[EphemeralStorage](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-ephemeralstorage)` 屬性。

 `EventInvokeConfig`   <a name="sam-function-eventinvokeconfig"></a>
描述事件在 Lambda 函數上叫用組態的物件。  
*類型*：[EventInvokeConfiguration](sam-property-function-eventinvokeconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Events`   <a name="sam-function-events"></a>
指定觸發此函數的事件。事件由類型和一組屬性組成，這些屬性取決於類型。  
*類型*︰[EventSource](sam-property-function-eventsource.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FileSystemConfigs`   <a name="sam-function-filesystemconfigs"></a>
指定 Amazon Elastic File System (Amazon EFS) 檔案系統連線設定的 [FileSystemConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html) 物件清單。  
如果您的範本包含 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-mounttarget.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-mounttarget.html) 資源，您還必須指定`DependsOn`資源屬性，以確保掛載目標在函數之前已建立或更新。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[FileSystemConfigs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-filesystemconfigs)` 屬性。

 `FunctionName`   <a name="sam-function-functionname"></a>
函數名稱。如果您未指定名稱，則會為您產生唯一的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[FunctionName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionname)` 屬性。

 `FunctionScalingConfig`   <a name="sam-function-functionscalingconfig"></a>
為在容量提供者上執行的 Lambda 函數設定擴展行為。定義執行環境的最小和最大數量。  
*類型*：[FunctionScalingConfig](sam-property-function-functionscalingconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[FunctionScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionscalingconfig)` 屬性。

 `FunctionUrlConfig`   <a name="sam-function-functionurlconfig"></a>
描述函數 URL 的物件。函數 URL 是 HTTPS 端點，可用來叫用函數。  
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*[》中的函數 URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html)。  
*類型*：[FunctionUrlConfig](sam-property-function-functionurlconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Handler`   <a name="sam-function-handler"></a>
您程式碼中的 函數，稱為 以開始執行。只有在 屬性設定為 時，才需要此`PackageType`屬性`Zip`。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Handler](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-handler)` 屬性。

 `ImageConfig`   <a name="sam-function-imageconfig"></a>
用來設定 Lambda 容器映像設定的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配 Lambda 使用容器映像](https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html)。  
*類型*：[ImageConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-imageconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[ImageConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-imageconfig)` 屬性。

 `ImageUri`   <a name="sam-function-imageuri"></a>
Lambda 函數容器映像的 Amazon Elastic Container Registry (Amazon ECR) 儲存庫的 URI。此屬性僅適用於 `PackageType` 屬性設為 時`Image`，否則會予以忽略。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配 Lambda 使用容器映像](https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html)。  
如果 `PackageType` 屬性設定為 `Image`，則需要 `ImageUri` ，或者您必須使用 AWS SAM 範本檔案中的必要`Metadata`項目來建置應用程式。如需詳細資訊，請參閱[使用 的預設建置 AWS SAM](serverless-sam-cli-using-build.md)。
使用必要`Metadata`項目建置您的應用程式優先於 `ImageUri`，因此如果您指定兩者，`ImageUri`則會忽略 。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `Code` 資料類型的 `[ImageUri](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-imageuri)` 屬性。

 `InlineCode`   <a name="sam-function-inlinecode"></a>
直接寫入範本中的 Lambda 函數程式碼。此屬性僅適用於 `PackageType` 屬性設為 時`Zip`，否則會予以忽略。  
如果 `PackageType` 屬性設定為 `Zip`（預設），`InlineCode`則需要其中一個 `CodeUri`或 。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `Code` 資料類型的 `[ZipFile](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-zipfile)` 屬性。

 `KmsKeyArn`   <a name="sam-function-kmskeyarn"></a>
Lambda 用來加密和解密函數環境變數的 AWS Key Management Service (AWS KMS) 金鑰 ARN。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-kmskeyarn)` 屬性。

 `Layers`   <a name="sam-function-layers"></a>
此函數應使用的 `LayerVersion` ARNs 清單。此處指定的順序是在執行 Lambda 函數時匯入的順序。版本是完整的 ARN，包括版本或 LayerVersion 資源的參考。例如， 的參考`LayerVersion`將是 ，`!Ref MyLayer`而包含 版本的完整 ARN 將是 `arn:aws:lambda:region:account-id:layer:layer-name:version`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Layers](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-layers)` 屬性。

 `LoggingConfig`   <a name="sam-function-loggingconfig"></a>
該功能的 Amazon CloudWatch Logs 組態設定。  
*類型*︰[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-loggingconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-loggingconfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-loggingconfig) 屬性。

 `MemorySize`   <a name="sam-function-memorysize"></a>
每次叫用函數時配置的記憶體大小，以 MB 為單位。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[MemorySize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-memorysize)` 屬性。

 `PackageType`   <a name="sam-function-packagetype"></a>
Lambda 函數的部署套件類型。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 部署套件](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)。  
**備註**：  
1. 如果此屬性設為 `Zip`（預設），則會`InlineCode`套用 `CodeUri`或 ，並`ImageUri`忽略 。  
2. 如果此屬性設為 `Image`，則只會`ImageUri`套用 ，且`InlineCode`會忽略 `CodeUri`和 。儲存函數容器映像所需的 Amazon ECR 儲存庫可由 自動建立 AWS SAM CLI。如需詳細資訊，請參閱[sam deploy](sam-cli-command-reference-sam-deploy.md)。  
*有效值*：`Zip` 或 `Image`  
*類型：*字串  
*必要*：否  
*預設*：`Zip`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[PackageType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-packagetype)` 屬性。

 `PermissionsBoundary`   <a name="sam-function-permissionsboundary"></a>
要用於此函數執行角色之許可界限的 ARN。此屬性只有在為您產生角色時才有效。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)` 屬性。

 `Policies`   <a name="sam-function-policies"></a>
此函數的許可政策。政策會附加至函數的預設 AWS Identity and Access Management (IAM) 執行角色。  
此屬性接受單一值或值清單。允許數值包括：  
+ [AWS SAM 政策範本](serverless-policy-templates.md).
+ [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)或[客戶受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#customer-managed-policies)ARN的 。
+ 下列[清單中](https://github.com/aws/serverless-application-model/blob/develop/samtranslator/internal/data/aws_managed_policies.json)受 AWS 管政策的名稱。
+ 在 中格式化YAML為映射的[內嵌 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#inline-policies)。
如果您設定 `Role` 屬性，則會忽略此屬性。
*類型*：字串 \$1 清單 \$1 地圖  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::IAM::Role` 資源的 `[Policies](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-policies)` 屬性。

 `PublishToLatestPublished`   <a name="sam-function-publishtolatestpublished"></a>
指定是否要在更新函數時發佈最新的函數版本。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[PublishToLatestPublished](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-publishtolatestpublished)` 屬性。

`PropagateTags`  <a name="sam-function-propagatetags"></a>
指出是否要將標籤從 `Tags` 屬性傳遞至您[AWS::Serverless::Function](sam-specification-generated-resources-function.md)產生的資源。指定 `True` 在產生的資源中傳播標籤。  
*類型*：布林值  
*必要*：否  
*預設*：`False`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ProvisionedConcurrencyConfig`   <a name="sam-function-provisionedconcurrencyconfig"></a>
函數別名的佈建並行組態。  
`ProvisionedConcurrencyConfig` 只有在設定 `AutoPublishAlias` 時，才能指定 。否則會產生錯誤結果。
*類型*：[ProvisionedConcurrencyConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html#cfn-lambda-alias-provisionedconcurrencyconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Alias` 資源的 `[ProvisionedConcurrencyConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html#cfn-lambda-alias-provisionedconcurrencyconfig)` 屬性。

 `RecursiveLoop`   <a name="sam-function-recursiveloop"></a>
函數遞迴迴圈偵測組態的狀態。  
當此值設為 `Allow`且 Lambda 偵測到您的函數被調用為遞迴迴圈的一部分時，它不會採取任何動作。  
當此值設為 `Terminate`且 Lambda 偵測到您的函數被調用為遞迴迴圈的一部分時，它會停止您的函數被調用並通知您。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[RecursiveLoop](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-recursiveloop)` 屬性。

 `ReservedConcurrentExecutions`   <a name="sam-function-reservedconcurrentexecutions"></a>
您要保留給函數的並行執行數目上限。  
如需此屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 函數擴展](https://docs.aws.amazon.com/lambda/latest/dg/scaling.html)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[ReservedConcurrentExecutions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-reservedconcurrentexecutions)` 屬性。

 `Role`   <a name="sam-function-role"></a>
要用作此函數執行角色之 IAM 角色的 ARN。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::Function` 資源的 `[Role](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-role)` 屬性。這是 中的必要項目 CloudFormation ，但不是 中的必要項目 AWS SAM。如果未指定角色，則會為您建立邏輯 ID 為 的角色`<function-logical-id>Role`。

 `RolePath`   <a name="sam-function-rolepath"></a>
函數 IAM 執行角色的路徑。  
為您產生角色時，請使用此屬性。使用 `Role` 屬性指定角色時，請勿使用 。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[Path](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-path)` 屬性。

 `Runtime`   <a name="sam-function-runtime"></a>
函數的[執行時間](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)的識別符。只有在 屬性設定為 時，才需要此`PackageType`屬性`Zip`。  
如果您為此屬性指定`provided`識別符，您可以使用 `Metadata` 資源屬性來指示 AWS SAM 建置此函數所需的自訂執行期。如需建置自訂執行時間的詳細資訊，請參閱 [在 中使用自訂執行期建置 Lambda 函數 AWS SAM](building-custom-runtimes.md)。
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Runtime](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-runtime)` 屬性。

 `RuntimeManagementConfig`   <a name="sam-function-runtimemanagementconfig"></a>
為您的 Lambda 函數設定執行時間管理選項，例如執行時間環境更新、復原行為，以及選取特定的執行時間版本。若要進一步了解，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 執行時間更新](https://docs.aws.amazon.com//lambda/latest/dg/runtimes-update.html)。  
*類型*：[RuntimeManagementConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-runtimemanagementconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[ RuntimeManagementConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-runtimemanagementconfig.html)` 屬性。

 `SnapStart`   <a name="sam-function-snapstart"></a>
建立任何新 Lambda 函數版本的快照。快照是初始化函數的快取狀態，包括其所有相依性。函數只會初始化一次，快取狀態會重複使用於所有未來的調用，藉由減少必須初始化函數的次數來改善應用程式效能。若要進一步了解，請參閱《 *AWS Lambda 開發人員指南*》中的[使用 Lambda SnapStart 改善啟動效能](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html)。  
*類型*：[SnapStart](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-snapstart.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[SnapStart](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-snapstart.html)` 屬性。

 `SourceKMSKeyArn`   <a name="sam-function-sourcekmskeyarn"></a>
代表用來加密客戶 ZIP 函數程式碼的 KMS 金鑰 ARN。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function``Code`資料類型的 `[SourceKMSKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-sourcekmskeyarn)` 屬性。

 `Tags`   <a name="sam-function-tags"></a>
指定新增至此函數之標籤的映射 （字串到字串）。如需標籤有效金鑰和值的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[標籤金鑰和值需求](https://docs.aws.amazon.com/lambda/latest/dg/configuration-tags.html#configuration-tags-restrictions)。  
建立堆疊時， AWS SAM 會自動將`lambda:createdBy:SAM`標籤新增至此 Lambda 函數，以及此函數產生的預設角色。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::Function` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tags)` 屬性。中的 `Tags` 屬性 AWS SAM 包含鍵值對 （而 CloudFormation 此屬性包含`Tag`物件清單）。此外， AWS SAM 自動將`lambda:createdBy:SAM`標籤新增至此 Lambda 函數，以及此函數產生的預設角色。

 `TenancyConfig`   <a name="sam-function-tenancyconfig"></a>
Lambda 租用戶隔離模式的組態。確保執行環境永遠不會在不同租用戶 IDs 之間共用，為多租用戶應用程式提供運算層級隔離。  
*類型*：[TenancyConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-tenancyconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[TenancyConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tenancyconfig)` 屬性。

 `Timeout`   <a name="sam-function-timeout"></a>
函數在停止之前可以執行的時間上限，以秒為單位。  
*類型*：整數  
*必要*：否  
*預設：*3  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[Timeout](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-timeout)` 屬性。

 `Tracing`   <a name="sam-function-tracing"></a>
指定函數 X-Ray 追蹤模式的字串。  
+ `Active` – 啟用函數的 X-Ray 追蹤。
+ `Disabled` – 停用函數的 X-Ray。
+ `PassThrough` – 啟用函數的 X-Ray 追蹤。抽樣決策會委派給下游服務。
如果指定為 `Active`或 `PassThrough`且未設定 `Role` 屬性， 會將`arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess`政策 AWS SAM 新增至其為您建立的 Lambda 執行角色。  
如需 X-Ray 的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[使用 AWS Lambda 搭配 AWS X-Ray](https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html) 。  
*有效值*：【`Active`\$1`Disabled`\$1`PassThrough`】  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::Function` 資源的 `[TracingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tracingconfig)` 屬性。

 `VersionDescription`   <a name="sam-function-versiondescription"></a>
指定在新的 Lambda 版本資源上新增`Description`的欄位。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Version` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html#cfn-lambda-version-description)` 屬性。

 `VersionDeletionPolicy`   <a name="sam-function-versiondeletionpolicy"></a>
指定設定 時所建立 Lambda `AutoPublishAlias` 版本資源的刪除政策。這會控制在刪除堆疊時保留或刪除版本資源。  
*有效值*：`Delete`、`Retain` 或 `Snapshot`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。它會在產生的`AWS::Lambda::Version`資源上設定 `DeletionPolicy` 屬性。

 `VpcConfig`   <a name="sam-function-vpcconfig"></a>
可讓此函數存取虛擬私有雲端 (VPC) 內私有資源的組態。  
*類型*：[VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[VpcConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html)` 屬性。

## 傳回值
<a name="sam-resource-function-return-values"></a>

### Ref
<a name="sam-resource-function-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回基礎 Lambda 函數的資源名稱。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-function-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`Arn`  <a name="Arn-fn::getatt"></a>
基礎 Lambda 函數的 ARN。

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

### 簡單函數
<a name="sam-resource-function-examples-simple-function"></a>

以下是 Amazon S3 儲存貯體中套件類型 `Zip`（預設） 和函數程式碼 [AWS::Serverless::Function](#sam-resource-function) 資源的基本範例。

#### YAML
<a name="sam-resource-function-examples-simple-function--yaml"></a>

```
Type: AWS::Serverless::Function
Properties:
  Handler: index.handler
  Runtime: python3.9
  CodeUri: s3://bucket-name/key-name
```

### 函數屬性範例
<a name="sam-resource-function-examples-function-properties-example"></a>

以下是使用 `InlineCode`、`Layers`、、`Amazon EFS`、 和 `Api`事件來源[AWS::Serverless::Function](#sam-resource-function)的套件類型 `Zip`（預設） `Tracing` `Policies`的範例。

#### YAML
<a name="sam-resource-function-examples-function-properties-example--yaml"></a>

```
Type: AWS::Serverless::Function
DependsOn: MyMountTarget        # This is needed if an AWS::EFS::MountTarget resource is declared for EFS
Properties:
  Handler: index.handler
  Runtime: python3.9
  InlineCode: |
    def handler(event, context):
      print("Hello, world!")
  ReservedConcurrentExecutions: 30
  Layers:
    - Ref: MyLayer
  Tracing: Active
  Timeout: 120
  FileSystemConfigs:
    - Arn: !Ref MyEfsFileSystem
      LocalMountPath: /mnt/EFS
  Policies:
    - AWSLambdaExecute
    - Version: '2012-10-17		 	 	 ' 
      Statement:
        - Effect: Allow
          Action:
            - s3:GetObject
            - s3:GetObjectACL
          Resource: 'arn:aws:s3:::sam-s3-demo-bucket/*'
  Events:
    ApiEvent:
      Type: Api
      Properties:
        Path: /path
        Method: get
```

### ImageConfig 範例
<a name="sam-resource-function-examples-imageconfig-example"></a>

以下是套件類型 之 `ImageConfig` Lambda 函數的 範例`Image`。

#### YAML
<a name="sam-resource-function-examples-imageconfig-example--yaml"></a>

```
HelloWorldFunction:
  Type: AWS::Serverless::Function
  Properties:
    PackageType: Image
    ImageUri: account-id.dkr.ecr.region.amazonaws.com/ecr-repo-name:image-name
    ImageConfig:
      Command:
        - "app.lambda_handler"
      EntryPoint:
        - "entrypoint1"
      WorkingDirectory: "workDir"
```

### RuntimeManagementConfig 範例
<a name="sam-resource-function-examples-runtimemanagementconfig-examples"></a>

設定為根據目前行為更新其執行時間環境的 Lambda 函數：

```
TestFunction
  Type: AWS::Serverless::Function
  Properties:
    ...
    Runtime: python3.9
    RuntimeManagementConfig:
      UpdateRuntimeOn: Auto
```

設定為在函數更新時更新其執行時間環境的 Lambda 函數：

```
TestFunction
  Type: AWS::Serverless::Function
  Properties:
    ...
    Runtime: python3.9
    RuntimeManagementConfig:
      UpdateRuntimeOn: FunctionUpdate
```

設定為手動更新其執行時間環境的 Lambda 函數：

```
TestFunction
  Type: AWS::Serverless::Function
  Properties:
    ...
    Runtime: python3.9
    RuntimeManagementConfig:
      RuntimeVersionArn: arn:aws:lambda:us-east-1::runtime:4c459dd0104ee29ec65dcad056c0b3ddbe20d6db76b265ade7eda9a066859b1e
      UpdateRuntimeOn: Manual
```

### SnapStart 範例
<a name="sam-resource-function-examples-snapstart-examples"></a>

為未來版本開啟 SnapStart 的 Lambda 函數範例：

```
TestFunc
  Type: AWS::Serverless::Function
  Properties:
    ...
    SnapStart:
      ApplyOn: PublishedVersions
```

### TenancyConfig 範例
<a name="sam-resource-function-examples-tenancyconfig-examples"></a>

開啟租用戶隔離模式的 Lambda 函數範例：

```
TestFunction
  Type: AWS::Serverless::Function
  Properties:
    ...
    TenancyConfig:
      TenantIsolationMode: PER_TENANT
```

# DeadLetterQueue
<a name="sam-property-function-deadletterqueue"></a>

指定 SQS 佇列或 SNS 主題，當事件無法處理時， AWS Lambda (Lambda) 會將事件傳送至該主題。如需無效字母佇列功能的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async-retain-records.html#invocation-dlq)。

SAM 會自動為您的 Lambda 函數執行角色新增適當的許可，讓 Lambda 服務存取 資源。SQS 佇列將新增 sqs：SendMessage，SNS 主題將新增 sns：Publish。

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

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

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

```
  [TargetArn](#sam-function-deadletterqueue-targetarn): String
  [Type](#sam-function-deadletterqueue-type): String
```

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

 `TargetArn`   <a name="sam-function-deadletterqueue-targetarn"></a>
Amazon SQS 佇列或 Amazon SNS 主題的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `DeadLetterConfig` 資料類型的 `[TargetArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html#cfn-lambda-function-deadletterconfig-targetarn)` 屬性。

 `Type`   <a name="sam-function-deadletterqueue-type"></a>
無效字母佇列的類型。  
*有效值*：`SNS`、`SQS`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### DeadLetterQueue
<a name="sam-property-function-deadletterqueue--examples--deadletterqueue"></a>

SNS 主題的無效字母佇列範例。

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

```
DeadLetterQueue:
  Type: SNS
  TargetArn: arn:aws:sns:us-east-2:123456789012:my-topic
```

# DeploymentPreference
<a name="sam-property-function-deploymentpreference"></a>

指定要啟用逐步 Lambda 部署的組態。如需設定逐步 Lambda 部署的詳細資訊，請參閱 [使用 逐步部署無伺服器應用程式 AWS SAM](automating-updates-to-serverless-apps.md)。

**注意**  
您必須在 `AutoPublishAlias`中指定 [AWS::Serverless::Function](sam-resource-function.md)以使用`DeploymentPreference`物件，否則會產生錯誤。

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

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

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

```
  [Alarms](#sam-function-deploymentpreference-alarms): List
  [Enabled](#sam-function-deploymentpreference-enabled): Boolean
  [Hooks](#sam-function-deploymentpreference-hooks): Hooks
  [PassthroughCondition](#sam-function-deploymentpreference-passthroughcondition): Boolean
  [Role](#sam-function-deploymentpreference-role): String
  [TriggerConfigurations](#sam-function-deploymentpreference-triggerconfigurations): List
  [Type](#sam-function-deploymentpreference-type): String
```

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

 `Alarms`   <a name="sam-function-deploymentpreference-alarms"></a>
您希望由部署引發的任何錯誤觸發的 CloudWatch 警示清單。  
此屬性接受 `Fn::If` 內部函數。如需使用 的範例範本，請參閱本主題底部的範例一節`Fn::If`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Enabled`   <a name="sam-function-deploymentpreference-enabled"></a>
此部署偏好設定是否已啟用。  
*類型*：布林值  
*必要*：否  
*預設*：True  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Hooks`   <a name="sam-function-deploymentpreference-hooks"></a>
驗證流量轉移前後執行的 Lambda 函數。  
*類型*：[勾點](sam-property-function-hooks.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `PassthroughCondition`   <a name="sam-function-deploymentpreference-passthroughcondition"></a>
如果為 True，且啟用此部署偏好設定，則函數的條件會傳遞至產生的 CodeDeploy 資源。一般而言，您應該將此設定為 True。否則，即使函數的條件解析為 False，也會建立 CodeDeploy 資源。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Role`   <a name="sam-function-deploymentpreference-role"></a>
CodeDeploy 將用於流量轉移的 IAM 角色 ARN。如果提供此功能，則不會建立 IAM 角色。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `TriggerConfigurations`   <a name="sam-function-deploymentpreference-triggerconfigurations"></a>
您要與部署群組建立關聯的觸發組態清單。用來通知生命週期事件的 SNS 主題。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::CodeDeploy::DeploymentGroup` 資源的 `[TriggerConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html#cfn-codedeploy-deploymentgroup-triggerconfigurations)` 屬性。

 `Type`   <a name="sam-function-deploymentpreference-type"></a>
目前有兩種部署類型：線性和 Canary。如需可用部署類型的詳細資訊，請參閱 [使用 逐步部署無伺服器應用程式 AWS SAM](automating-updates-to-serverless-apps.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### 具有流量前後掛鉤的 DeploymentPreference。
<a name="sam-property-function-deploymentpreference--examples--deploymentpreference-with-pre--and-post-traffic-hooks."></a>

包含流量前後掛鉤的範例部署偏好設定。

#### YAML
<a name="sam-property-function-deploymentpreference--examples--deploymentpreference-with-pre--and-post-traffic-hooks.--yaml"></a>

```
DeploymentPreference:
  Enabled: true
  Type: Canary10Percent10Minutes 
  Alarms:
    - !Ref: AliasErrorMetricGreaterThanZeroAlarm
    - !Ref: LatestVersionErrorMetricGreaterThanZeroAlarm
  Hooks:
    PreTraffic:
      !Ref: PreTrafficLambdaFunction
    PostTraffic:
      !Ref: PostTrafficLambdaFunction
```

### 具有 Fn：：If 內部函數的 DeploymentPreference
<a name="sam-property-function-deploymentpreference--examples--deploymentpreference-with-fn::if-intrinsic-function"></a>

`Fn::If` 用於設定警示的範例部署偏好設定。在此範例中，如果 `MyCondition`是 ，`Alarm1`則會設定 `true`，如果 `MyCondition`是 ，`Alarm2``Alarm5`則會設定 `false`。

#### YAML
<a name="sam-property-function-deploymentpreference--examples--deploymentpreference-with-fn::if-intrinsic-function--yaml"></a>

```
DeploymentPreference:
  Enabled: true
  Type: Canary10Percent10Minutes 
  Alarms:
    Fn::If:
      - MyCondition
      - - Alarm1
      - - Alarm2
        - Alarm5
```

# Hooks
<a name="sam-property-function-hooks"></a>

驗證流量轉移前後執行的 Lambda 函數。

**注意**  
此屬性中參考的 Lambda 函數會設定產生[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html)資源的`CodeDeployLambdaAliasUpdate`物件。如需詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的 [CodeDeployLambdaAliasUpdate 政策](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-codedeploylambdaaliasupdate)。

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

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

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

```
  [PostTraffic](#sam-function-hooks-posttraffic): String
  [PreTraffic](#sam-function-hooks-pretraffic): String
```

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

 `PostTraffic`   <a name="sam-function-hooks-posttraffic"></a>
在流量轉移後執行的 Lambda 函數。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `PreTraffic`   <a name="sam-function-hooks-pretraffic"></a>
在流量轉移之前執行的 Lambda 函數。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

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

### 勾點
<a name="sam-property-function-hooks--examples--hooks"></a>

掛鉤函數範例

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

```
Hooks:
  PreTraffic:
    Ref: PreTrafficLambdaFunction
  PostTraffic:
    Ref: PostTrafficLambdaFunction
```

# DurableConfig
<a name="sam-property-function-durableconfig"></a>

設定 AWS Lambda 函數的耐久執行設定。耐用的函數可以執行長達一年，並自動檢查點進度，啟用長時間執行的工作流程和容錯應用程式。如需耐用函數的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 耐用函數](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html)。

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

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

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

```
  [ExecutionTimeout](#sam-function-durableconfig-executiontimeout): Integer
  [RetentionPeriodInDays](#sam-function-durableconfig-retentionperiodindays): Integer
```

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

 `ExecutionTimeout`   <a name="sam-function-durableconfig-executiontimeout"></a>
Lambda 允許耐用函數在停止之前執行的時間量 （以秒為單位）。上限為一年 366 天或 31，622，400 秒。  
*類型*：整數  
*必要*：是  
*下限*：1  
*上限*：31622400  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `DurableConfig` 資料類型的 `[ExecutionTimeout](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-durableconfig.html#cfn-lambda-function-durableconfig-executiontimeout)` 屬性。

 `RetentionPeriodInDays`   <a name="sam-function-durableconfig-retentionperiodindays"></a>
持久性執行關閉後的天數，Lambda 會保留其歷史記錄，從 1 天到 90 天。預設值是 14 天。  
*類型*：整數  
*必要*：否  
*預設*：14  
*下限*：1  
*上限*：90  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `DurableConfig` 資料類型的 `[RetentionPeriodInDays](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-durableconfig.html#cfn-lambda-function-durableconfig-retentionperiodindays)` 屬性。

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

### DurableConfig
<a name="sam-property-function-durableconfig--examples--durableconfig"></a>

具有 1 小時執行逾時和 7 天保留期的函數的耐用組態範例。

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

```
DurableConfig:
  ExecutionTimeout: 3600
  RetentionPeriodInDays: 7
```

# 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
```

# EventSource
<a name="sam-property-function-eventsource"></a>

描述觸發函數之事件來源的物件。每個事件都包含一個類型和一組取決於該類型的屬性。如需每個事件來源屬性的詳細資訊，請參閱與該類型對應的主題。

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

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

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

```
  [Properties](#sam-function-eventsource-properties): AlexaSkill | Api | CloudWatchEvent | CloudWatchLogs | Cognito | DocumentDB | DynamoDB | EventBridgeRule | HttpApi | IoTRule | Kinesis | MQ | MSK | S3 | Schedule | ScheduleV2 | SelfManagedKafka | SNS | SQS
  [Type](#sam-function-eventsource-type): String
```

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

 `Properties`   <a name="sam-function-eventsource-properties"></a>
描述此事件映射屬性的物件。一組屬性必須符合定義的類型。  
*類型*：[AlexaSkill](sam-property-function-alexaskill.md) \$1 [Api](sam-property-function-api.md) \$1 [CloudWatchEvent](sam-property-function-cloudwatchevent.md) \$1 [CloudWatchLogs](sam-property-function-cloudwatchlogs.md) \$1 [Cognito](sam-property-function-cognito.md) \$1 [DocumentDB](sam-property-function-documentdb.md) \$1 [DynamoDB](sam-property-function-dynamodb.md) \$1 [EventBridgeRule](sam-property-function-eventbridgerule.md) \$1 [HttpApi](sam-property-function-httpapi.md) \$1 [IoTRule](sam-property-function-iotrule.md) \$1 [Kinesis](sam-property-function-kinesis.md) \$1 [MQ](sam-property-function-mq.md) \$1 [MSK](sam-property-function-msk.md) \$1 [S3](sam-property-function-s3.md) \$1 [Schedule](sam-property-function-schedule.md) \$1 [ScheduleV2](sam-property-function-schedulev2.md) \$1 [SelfManagedKafka](sam-property-function-selfmanagedkafka.md) \$1 [SNS](sam-property-function-sns.md) \$1 [SQS](sam-property-function-sqs.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-function-eventsource-type"></a>
事件類型。  
*有效值*：`AlexaSkill`、`Api`、`CloudWatchEvent`、`CloudWatchLogs`、`Cognito`、`DocumentDB`、`DynamoDB``EventBridgeRule`、`HttpApi`、`IoTRule`、`Kinesis`、、`MQ`、、`MSK``S3`、`Schedule`、 `ScheduleV2` `SelfManagedKafka` `SNS` `SQS`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### APIEvent
<a name="sam-property-function-eventsource--examples--apievent"></a>

使用 API 事件的範例

#### YAML
<a name="sam-property-function-eventsource--examples--apievent--yaml"></a>

```
ApiEvent:
  Type: Api
  Properties:
    Method: get
    Path: /group/{user}
    RestApiId: 
      Ref: MyApi
```

# AlexaSkill
<a name="sam-property-function-alexaskill"></a>

描述`AlexaSkill`事件來源類型的物件。

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

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

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

```
  [SkillId](#sam-function-alexaskill-skillid): String
```

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

 `SkillId`   <a name="sam-function-alexaskill-skillid"></a>
Alexa Skill 的 Alexa Skill ID。如需技能 ID 的詳細資訊，請參閱 [Alexa Skills Kit 文件中的設定 Lambda 函數的觸發](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#configuring-the-alexa-skills-kit-trigger)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### AlexaSkillTrigger
<a name="sam-property-function-alexaskill--examples--alexaskilltrigger"></a>

Alexa 技能事件範例

#### YAML
<a name="sam-property-function-alexaskill--examples--alexaskilltrigger--yaml"></a>

```
AlexaSkillEvent:
  Type: AlexaSkill
```

# Api
<a name="sam-property-function-api"></a>

描述`Api`事件來源類型的物件。如果已定義[AWS::Serverless::Api](sam-resource-api.md)資源，路徑和方法值必須對應至 API OpenAPI 定義中的 操作。

如果[AWS::Serverless::Api](sam-resource-api.md)未定義任何 ，則函數輸入和輸出代表 HTTP 請求和 HTTP 回應。

例如，使用 JavaScript API，可以透過傳回具有金鑰 statusCode 和內文的物件來控制回應statusCode和內文。

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

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

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

```
  [Auth](#sam-function-api-auth): ApiFunctionAuth
  [Method](#sam-function-api-method): String
  [Path](#sam-function-api-path): String
  [RequestModel](#sam-function-api-requestmodel): RequestModel
  [RequestParameters](#sam-function-api-requestparameters): List of [ String | RequestParameter ]
  [RestApiId](#sam-function-api-restapiid): String
  [ResponseTransferMode](#sam-function-api-responsetransfermode): String
  TimeoutInMillis: Integer
```

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

 `Auth`   <a name="sam-function-api-auth"></a>
此特定 Api\$1Path\$1Method 的身分驗證組態。  
用於在未`DefaultAuthorizer`指定或覆寫預設設定時，覆寫個別路徑上 API `DefaultAuthorizer` `ApiKeyRequired`的設定身分驗證組態。  
*類型*：[ApiFunctionAuth](sam-property-function-apifunctionauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-function-api-method"></a>
叫用此函數的 HTTP 方法。選項包括 `DELETE`、`GET`、`HEAD`、`OPTIONS`、`PATCH`、`PUT`、 `POST`和 `ANY`。如需詳細資訊，請參閱《 ** [API Gateway 開發人員指南》中的設定 HTTP 方法](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-request.html#setup-method-add-http-method)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Path`   <a name="sam-function-api-path"></a>
叫用此函數的 Uri 路徑。必須以 開頭`/`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RequestModel`   <a name="sam-function-api-requestmodel"></a>
請求使用此特定 Api\$1Path\$1Method 的模型。這應該參考 [AWS::Serverless::Api](sam-resource-api.md) 資源 `Models`區段中指定的模型名稱。  
*類型*：[RequestModel](sam-property-function-requestmodel.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RequestParameters`   <a name="sam-function-api-requestparameters"></a>
請求此特定 Api\$1Path\$1Method 的參數組態。所有參數名稱都必須以 開頭`method.request.header`，`method.request`且必須限制為 `method.request.querystring`、 或 `method.request.path`。  
清單可以同時包含參數名稱字串和 [RequestParameter](sam-property-function-requestparameter.md) 物件。對於字串， `Required`和 `Caching` 屬性預設為 `false`。  
*類型*：【 String \$1 [RequestParameter](sam-property-function-requestparameter.md) 】 的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RestApiId`   <a name="sam-function-api-restapiid"></a>
RestApi 資源的識別符，必須包含具有指定路徑和方法的操作。一般而言，這會設定為參考此範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
如果您未定義此屬性， 會使用產生的`OpenApi`文件 AWS SAM 建立預設[AWS::Serverless::Api](sam-resource-api.md)資源。該資源包含由相同範本中未指定 之`Api`事件定義的所有路徑和方法的聯集`RestApiId`。  
這無法參考另一個範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`ResponseTransferMode`  <a name="sam-function-api-responsetransfermode"></a>
Lambda 函數整合的回應傳輸模式。設定為 `RESPONSE_STREAM` 以透過 API Gateway 啟用 Lambda 回應串流，允許函數將回應串流回用戶端。設為 時`RESPONSE_STREAM`，API Gateway 會使用 Lambda InvokeWithResponseStreaming API。  
*類型：*字串  
*必要*：否  
*有效值*：`BUFFERED` \$1 `RESPONSE_STREAM`  
*CloudFormation 相容性*：此屬性會直接傳遞至 的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html#cfn-apigateway-method-integration-responsetransfermode](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html#cfn-apigateway-method-integration-responsetransfermode) 屬性`AWS::ApiGateway::Method Integration`。

`TimeoutInMillis`  <a name="sam-function-api-timeoutinmillis"></a>
自訂介於 50 和 29,000 毫秒之間的逾時。  
當您指定此屬性時， 會 AWS SAM 修改您的 OpenAPI 定義。OpenAPI 定義必須使用 `DefinitionBody` 屬性內嵌指定。
*類型*：整數  
*必要*：否  
*預設*：29，000 毫秒或 29 秒  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

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

### 基本範例
<a name="sam-property-function-api--examples--apievent"></a>

#### YAML
<a name="sam-property-function-api--examples--apievent--yaml"></a>

```
Events:
  ApiEvent:
    Type: Api
    Properties:
      Path: /path
      Method: get
      RequestParameters:
        - method.request.header.Authorization
        - method.request.querystring.keyword:
            Required: true
            Caching: false
```

# ApiFunctionAuth
<a name="sam-property-function-apifunctionauth"></a>

為特定 API、路徑和方法設定事件層級的授權。

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

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

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

```
  [ApiKeyRequired](#sam-function-apifunctionauth-apikeyrequired): Boolean
  [AuthorizationScopes](#sam-function-apifunctionauth-authorizationscopes): List
  [Authorizer](#sam-function-apifunctionauth-authorizer): String
  [InvokeRole](#sam-function-apifunctionauth-invokerole): String
  OverrideApiAuth: Boolean
  [ResourcePolicy](#sam-function-apifunctionauth-resourcepolicy): ResourcePolicyStatement
```

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

 `ApiKeyRequired`   <a name="sam-function-apifunctionauth-apikeyrequired"></a>
此 API、路徑和方法需要 API 金鑰。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等的。

 `AuthorizationScopes`   <a name="sam-function-apifunctionauth-authorizationscopes"></a>
要套用至此 API、路徑和方法的授權範圍。  
如果您已指定 屬性套用的任何範圍，您指定的範圍將會覆寫該`DefaultAuthorizer`屬性所套用的任何範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等的。

 `Authorizer`   <a name="sam-function-apifunctionauth-authorizer"></a>
特定函數`Authorizer`的 。  
如果您為`AWS::Serverless::Api`資源指定了全域授權方，則可以將 `Authorizer`設定為 來覆寫授權方`NONE`。如需範例，請參閱 [覆寫 Amazon API Gateway REST API 的全域授權方](#sam-property-function-apifunctionauth--examples--override)。  
如果您使用 `AWS::Serverless::Api` 資源的 `DefinitionBody` 屬性來描述 API，則必須使用 `OverrideApiAuth`搭配 `Authorizer` 來覆寫您的全域授權方。如需詳細資訊，請參閱`OverrideApiAuth`。
*有效值*：`AWS_IAM`、 `NONE`或 AWS SAM 範本中定義之任何授權方的邏輯 ID。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等的。

 `InvokeRole`   <a name="sam-function-apifunctionauth-invokerole"></a>
指定`InvokeRole`用於`AWS_IAM`授權的 。  
*類型：*字串  
*必要*：否  
*預設*：`CALLER_CREDENTIALS`  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等屬性。  
*其他備註*：`CALLER_CREDENTIALS`映射至 `arn:aws:iam:::<user>/`，這會使用呼叫者登入資料來叫用端點。

`OverrideApiAuth`  <a name="sam-function-apifunctionauth-overrideapiauth"></a>
將 指定為 `true`以覆寫`AWS::Serverless::Api`資源的全域授權方組態。只有在您指定全域授權方並使用 `AWS::Serverless::Api` 資源的 屬性來描述 API 時，才需要此`DefinitionBody`屬性。  
當您將 指定`OverrideApiAuth`為 時`true`， AWS SAM 會使用為 `ApiKeyRequired`、 `Authorizer`或 提供的任何值來覆寫您的全域授權方`ResourcePolicy`。因此，使用 時，至少也必須指定其中一個屬性`OverrideApiAuth`。如需範例，請參閱 [指定 DefinitionBody for AWS::Serverless::Api 時覆寫全域授權方](#sam-property-function-apifunctionauth--examples--override2)。
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ResourcePolicy`   <a name="sam-function-apifunctionauth-resourcepolicy"></a>
在 API 上設定此路徑的資源政策。  
*類型*：[ResourcePolicyStatement](sam-property-function-resourcepolicystatement.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，且沒有 CloudFormation 同等屬性。

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

### Function-Auth
<a name="sam-property-function-apifunctionauth--examples--function-auth"></a>

下列範例會在函數層級指定授權。

#### YAML
<a name="sam-property-function-apifunctionauth--examples--function-auth--yaml"></a>

```
Auth:
  ApiKeyRequired: true
  Authorizer: NONE
```

### 覆寫 Amazon API Gateway REST API 的全域授權方
<a name="sam-property-function-apifunctionauth--examples--override"></a>

您可以為您的`AWS::Serverless::Api`資源指定全域授權方。以下是設定全域預設授權方的範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
```

若要覆寫 AWS Lambda 函數的預設授權方，您可以將 指定`Authorizer`為 `NONE`。以下是範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  ...
  MyFn:
    Type: AWS::Serverless::Function
    Properties:
      ...
      Events:
        LambdaRequest:
          Type: Api
          Properties:
            RestApiId: !Ref MyApiWithLambdaRequestAuth
            Method: GET
            Auth:
              Authorizer: NONE
```

### 指定 DefinitionBody for AWS::Serverless::Api 時覆寫全域授權方
<a name="sam-property-function-apifunctionauth--examples--override2"></a>

使用 `DefinitionBody` 屬性描述`AWS::Serverless::Api`資源時，先前的覆寫方法無法運作。以下是將 `DefinitionBody` 屬性用於 `AWS::Serverless::Api` 資源的範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      DefinitionBody:
        swagger: 2.0
        ...
        paths:
          /lambda-request:
            ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
```

若要覆寫全域授權方，請使用 `OverrideApiAuth` 屬性。以下是使用 `OverrideApiAuth`以 提供的 值覆寫全域授權方的範例`Authorizer`：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      DefinitionBody:
        swagger: 2-0
        ...
        paths:
          /lambda-request:
            ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
    
    MyAuthFn:
      Type: AWS::Serverless::Function
      ...
    
    MyFn:
      Type: AWS::Serverless::Function
        Properties:
          ...
          Events:
            LambdaRequest:
              Type: Api
              Properties:
                RestApiId: !Ref MyApiWithLambdaRequestAuth
                Method: GET
                Auth:
                  Authorizer: NONE
                  OverrideApiAuth: true
                Path: /lambda-token
```

# ResourcePolicyStatement
<a name="sam-property-function-resourcepolicystatement"></a>

為 API 的所有方法和路徑設定資源政策。如需資源政策的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API Gateway 資源政策控制對 API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies.html)。 **

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

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

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

```
  [AwsAccountBlacklist](#sam-function-resourcepolicystatement-awsaccountblacklist): List
  [AwsAccountWhitelist](#sam-function-resourcepolicystatement-awsaccountwhitelist): List
  [CustomStatements](#sam-function-resourcepolicystatement-customstatements): List
  [IntrinsicVpcBlacklist](#sam-function-resourcepolicystatement-intrinsicvpcblacklist): List
  [IntrinsicVpcWhitelist](#sam-function-resourcepolicystatement-intrinsicvpcwhitelist): List
  [IntrinsicVpceBlacklist](#sam-function-resourcepolicystatement-intrinsicvpceblacklist): List
  [IntrinsicVpceWhitelist](#sam-function-resourcepolicystatement-intrinsicvpcewhitelist): List
  [IpRangeBlacklist](#sam-function-resourcepolicystatement-iprangeblacklist): List
  [IpRangeWhitelist](#sam-function-resourcepolicystatement-iprangewhitelist): List
  [SourceVpcBlacklist](#sam-function-resourcepolicystatement-sourcevpcblacklist): List
  [SourceVpcWhitelist](#sam-function-resourcepolicystatement-sourcevpcwhitelist): List
```

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

 `AwsAccountBlacklist`   <a name="sam-function-resourcepolicystatement-awsaccountblacklist"></a>
要封鎖 AWS 的帳戶。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AwsAccountWhitelist`   <a name="sam-function-resourcepolicystatement-awsaccountwhitelist"></a>
要允許 AWS 的帳戶。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `CustomStatements`   <a name="sam-function-resourcepolicystatement-customstatements"></a>
要套用至此 API 的自訂資源政策陳述式清單。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IntrinsicVpcBlacklist`   <a name="sam-function-resourcepolicystatement-intrinsicvpcblacklist"></a>
要封鎖的虛擬私有雲端 (VPCs) 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpcWhitelist`   <a name="sam-function-resourcepolicystatement-intrinsicvpcwhitelist"></a>
要允許的 VPCs 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceBlacklist`   <a name="sam-function-resourcepolicystatement-intrinsicvpceblacklist"></a>
要封鎖的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceWhitelist`   <a name="sam-function-resourcepolicystatement-intrinsicvpcewhitelist"></a>
要允許的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeBlacklist`   <a name="sam-function-resourcepolicystatement-iprangeblacklist"></a>
要封鎖的 IP 地址或地址範圍。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeWhitelist`   <a name="sam-function-resourcepolicystatement-iprangewhitelist"></a>
要允許的 IP 地址或地址範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SourceVpcBlacklist`   <a name="sam-function-resourcepolicystatement-sourcevpcblacklist"></a>
要封鎖的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceVpcWhitelist`   <a name="sam-function-resourcepolicystatement-sourcevpcwhitelist"></a>
要允許的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### 資源政策範例
<a name="sam-property-function-resourcepolicystatement--examples--resource-policy-example"></a>

下列範例會封鎖兩個 IP 地址和來源 VPC，並允許 AWS 帳戶。

#### YAML
<a name="sam-property-function-resourcepolicystatement--examples--resource-policy-example--yaml"></a>

```
Auth:
  ResourcePolicy:
    CustomStatements: [{
                         "Effect": "Allow",
                         "Principal": "*",
                         "Action": "execute-api:Invoke",
                         "Resource": "execute-api:/Prod/GET/pets",
                         "Condition": {
                           "IpAddress": {
                             "aws:SourceIp": "1.2.3.4"
                           }
                         }
                       }]
    IpRangeBlacklist:
      - "10.20.30.40"
      - "1.2.3.4"
    SourceVpcBlacklist:
      - "vpce-1a2b3c4d"
    AwsAccountWhitelist:
      - "111122223333"
    IntrinsicVpcBlacklist:
      - "{{resolve:ssm:SomeVPCReference:1}}" 
      - !Ref MyVPC
    IntrinsicVpceWhitelist:
      - "{{resolve:ssm:SomeVPCEReference:1}}" 
      - !Ref MyVPCE
```

# RequestModel
<a name="sam-property-function-requestmodel"></a>

設定特定 Api\$1Path\$1Method 的請求模型。

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

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

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

```
  [Model](#sam-function-requestmodel-model): String
  [Required](#sam-function-requestmodel-required): Boolean
  [ValidateBody](#sam-function-requestmodel-validatebody): Boolean
  [ValidateParameters](#sam-function-requestmodel-validateparameters): Boolean
```

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

 `Model`   <a name="sam-function-requestmodel-model"></a>
在 的模型屬性中定義的模型名稱[AWS::Serverless::Api](sam-resource-api.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Required`   <a name="sam-function-requestmodel-required"></a>
在指定 API 端點的 OpenApi 定義的參數區段中新增`required`屬性。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidateBody`   <a name="sam-function-requestmodel-validatebody"></a>
指定 API Gateway 是否使用 `Model` 驗證請求內文。如需詳細資訊，請參閱《 [API Gateway 開發人員指南》中的在 API Gateway 中啟用請求驗證](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidateParameters`   <a name="sam-function-requestmodel-validateparameters"></a>
指定 API Gateway 是否使用 `Model` 驗證請求路徑參數、查詢字串和標頭。如需詳細資訊，請參閱《 [API Gateway 開發人員指南》中的在 API Gateway 中啟用請求驗證](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### 請求模型
<a name="sam-property-function-requestmodel--examples--request-model"></a>

請求模型範例

#### YAML
<a name="sam-property-function-requestmodel--examples--request-model--yaml"></a>

```
RequestModel:
  Model: User
  Required: true
  ValidateBody: true
  ValidateParameters: true
```

# RequestParameter
<a name="sam-property-function-requestparameter"></a>

設定特定 Api\$1Path\$1Method 的請求參數。

請求參數需要指定 `Required`或 `Caching` 屬性

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

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

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

```
  [Caching](#sam-function-requestparameter-caching): Boolean
  [Required](#sam-function-requestparameter-required): Boolean
```

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

 `Caching`   <a name="sam-function-requestparameter-caching"></a>
將 `cacheKeyParameters` 區段新增至 API Gateway OpenApi 定義  
*類型*：布林值  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Required`   <a name="sam-function-requestparameter-required"></a>
此欄位指定是否需要參數  
*類型*：布林值  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### 請求參數
<a name="sam-property-function-requestparameter--examples--request-parameter"></a>

設定請求參數的範例

#### YAML
<a name="sam-property-function-requestparameter--examples--request-parameter--yaml"></a>

```
RequestParameters:
  - method.request.header.Authorization:
      Required: true
      Caching: true
```

# CloudWatchEvent
<a name="sam-property-function-cloudwatchevent"></a>

描述`CloudWatchEvent`事件來源類型的物件。

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) 資源。

**重要注意事項**： [EventBridgeRule](sam-property-function-eventbridgerule.md)是要使用的慣用事件來源類型，而不是 `CloudWatchEvent`。 `EventBridgeRule` 和 `CloudWatchEvent`會使用相同的基礎服務、API CloudFormation 和資源。不過， AWS SAM 只會將新功能的支援新增至 `EventBridgeRule`。

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

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

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

```
  [Enabled](#sam-function-cloudwatchevent-enabled): Boolean
  [EventBusName](#sam-function-cloudwatchevent-eventbusname): String
  [Input](#sam-function-cloudwatchevent-input): String
  [InputPath](#sam-function-cloudwatchevent-inputpath): String
  [Pattern](#sam-function-cloudwatchevent-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  [State](#sam-function-cloudwatchevent-state): String
```

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

 `Enabled`   <a name="sam-function-cloudwatchevent-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`。

 `EventBusName`   <a name="sam-function-cloudwatchevent-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-function-cloudwatchevent-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)` 屬性。

 `InputPath`   <a name="sam-function-cloudwatchevent-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

 `Pattern`   <a name="sam-function-cloudwatchevent-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

 `State`   <a name="sam-function-cloudwatchevent-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-cloudwatchevent--examples"></a>

### CloudWatchEvent
<a name="sam-property-function-cloudwatchevent--examples--cloudwatchevent"></a>

以下是`CloudWatchEvent`事件來源類型的範例。

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

```
CWEvent:
  Type: CloudWatchEvent
  Properties:
    Enabled: false
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - running
```

# CloudWatchLogs
<a name="sam-property-function-cloudwatchlogs"></a>

描述`CloudWatchLogs`事件來源類型的物件。

此事件會產生[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html)資源並指定訂閱篩選條件，並將其與指定的日誌群組建立關聯。

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

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

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

```
  [FilterPattern](#sam-function-cloudwatchlogs-filterpattern): String
  [LogGroupName](#sam-function-cloudwatchlogs-loggroupname): String
```

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

 `FilterPattern`   <a name="sam-function-cloudwatchlogs-filterpattern"></a>
篩選表達式，限制交付至目的地 AWS 資源的項目。如需篩選條件模式語法的詳細資訊，請參閱[篩選條件及模式語法](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Logs::SubscriptionFilter` 資源的 `[FilterPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html#cfn-cwl-subscriptionfilter-filterpattern)` 屬性。

 `LogGroupName`   <a name="sam-function-cloudwatchlogs-loggroupname"></a>
要與訂閱篩選條件關聯的日誌群組。如果篩選條件模式符合日誌事件，則上傳至此日誌群組的所有日誌事件都會經過篩選，並交付至指定的 AWS 資源。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Logs::SubscriptionFilter` 資源的 `[LogGroupName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html#cfn-cwl-subscriptionfilter-loggroupname)` 屬性。

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

### Cloudwatchlogs 訂閱篩選條件
<a name="sam-property-function-cloudwatchlogs--examples--cloudwatchlogs-subscription-filter"></a>

Cloudwatchlogs 訂閱篩選條件範例

#### YAML
<a name="sam-property-function-cloudwatchlogs--examples--cloudwatchlogs-subscription-filter--yaml"></a>

```
CWLog:
  Type: CloudWatchLogs
  Properties:
    LogGroupName:
      Ref: CloudWatchLambdaLogsGroup
    FilterPattern: My pattern
```

# Cognito
<a name="sam-property-function-cognito"></a>

描述`Cognito`事件來源類型的物件。

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

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

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

```
  [Trigger](#sam-function-cognito-trigger): List
  [UserPool](#sam-function-cognito-userpool): String
```

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

 `Trigger`   <a name="sam-function-cognito-trigger"></a>
新使用者集區的 Lambda 觸發組態資訊。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Cognito::UserPool` 資源的 `[LambdaConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-lambdaconfig.html)` 屬性。

 `UserPool`   <a name="sam-function-cognito-userpool"></a>
相同範本中定義的 UserPool 參考  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### Cognito 事件
<a name="sam-property-function-cognito--examples--cognito-event"></a>

Cognito 事件範例

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

```
CognitoUserPoolPreSignup:
  Type: Cognito
  Properties:
    UserPool:
      Ref: MyCognitoUserPool
    Trigger: PreSignUp
```

# DocumentDB
<a name="sam-property-function-documentdb"></a>

描述`DocumentDB`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon DocumentDB](https://docs.aws.amazon.com/lambda/latest/dg/with-documentdb.html)。

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

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

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

```
BatchSize: Integer
Cluster: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
CollectionName: String
DatabaseName: String
Enabled: Boolean
FilterCriteria: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
FullDocument: String
KmsKeyArn: String  
MaximumBatchingWindowInSeconds: Integer
SecretsManagerKmsKeyId: String
SourceAccessConfigurations: List
StartingPosition: String
StartingPositionTimestamp: Double
```

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

 `BatchSize`   <a name="sam-function-documentdb-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。

 `Cluster`   <a name="sam-function-documentdb-cluster"></a>
Amazon DocumentDB 叢集的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `CollectionName`   <a name="sam-function-documentdb-collectionname"></a>
要在資料庫內使用的集合名稱。如果您未指定集合，Lambda 會使用所有集合。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ CollectionName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-collectionname)` 屬性。

 `DatabaseName`   <a name="sam-function-documentdb-databasename"></a>
Amazon DocumentDB 叢集內要使用的資料庫名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ DatabaseName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-databasename)` 屬性。

 `Enabled`   <a name="sam-function-documentdb-enabled"></a>
如果為 `true`，則事件來源映射為作用中。若要暫停輪詢和調用，請將 設定為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-documentdb-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [ Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FullDocument`   <a name="sam-function-documentdb-fulldocument"></a>
決定 Amazon DocumentDB 在文件更新操作期間傳送到事件串流的內容。如果設定為 `UpdateLookup`，Amazon DocumentDB 會傳送描述變更的差異，以及整個文件的副本。否則，Amazon DocumentDB 只會傳送包含變更的部分文件。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ FullDocument](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-fulldocument)` 屬性。

 `KmsKeyArn`   <a name="sam-function-documentdb-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-documentdb-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `SecretsManagerKmsKeyId`   <a name="sam-function-documentdb-secretsmanagerkmskeyid"></a>
 AWS Secrets Manager 的客戶受管金鑰的 AWS Key Management Service (AWS KMS) 金鑰 ID。當您使用 Secrets Manager 的客戶受管金鑰搭配不包含 `kms:Decrypt`許可的 Lambda 執行角色時，此為必要項目。  
此屬性的值是 UUID。例如：`1abc23d4-567f-8ab9-cde0-1fab234c5d67`。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 的。

 `SourceAccessConfigurations`   <a name="sam-function-documentdb-sourceaccessconfigurations"></a>
身分驗證通訊協定或虛擬主機的陣列。使用 [ SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 資料類型指定此項目。  
對於`DocumentDB`事件來源類型，唯一的有效組態類型為 `BASIC_AUTH`。  
+ `BASIC_AUTH` – 存放代理程式登入資料的 Secrets Manager 秘密。對於此類型，登入資料必須採用下列格式：`{"username": "your-username", "password": "your-password"}`。僅允許一個 類型的物件`BASIC_AUTH`。
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)` 屬性。

 `StartingPosition`   <a name="sam-function-documentdb-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-documentdb-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

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

### Amazon DocumentDB 事件來源
<a name="sam-property-function-documentdb-examples-example1"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
    ...
      Events:
        MyDDBEvent:
          Type: DocumentDB
          Properties:
            Cluster: "arn:aws:rds:us-west-2:123456789012:cluster:docdb-2023-01-01"
            BatchSize: 10
            MaximumBatchingWindowInSeconds: 5
            DatabaseName: "db1"
            CollectionName: "collection1"
            FullDocument: "UpdateLookup"
            SourceAccessConfigurations:
              - Type: BASIC_AUTH
                URI: "arn:aws:secretsmanager:us-west-2:123456789012:secret:doc-db"
```

# DynamoDB
<a name="sam-property-function-dynamodb"></a>

描述`DynamoDB`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon DynamoDB](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html)。

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

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

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

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

```
  [BatchSize](#sam-function-dynamodb-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-dynamodb-bisectbatchonfunctionerror): Boolean
  [DestinationConfig](#sam-function-dynamodb-destinationconfig): [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)
  [Enabled](#sam-function-dynamodb-enabled): Boolean
  [FilterCriteria](#sam-function-dynamodb-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-dynamodb-functionresponsetypes): List
  KmsKeyArn: String          
  [MaximumBatchingWindowInSeconds](#sam-function-dynamodb-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-dynamodb-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-dynamodb-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-dynamodb-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ParallelizationFactor](#sam-function-dynamodb-parallelizationfactor): Integer
  [StartingPosition](#sam-function-dynamodb-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-dynamodb-stream): String
  [TumblingWindowInSeconds](#sam-function-dynamodb-tumblingwindowinseconds): Integer
```

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

 `BatchSize`   <a name="sam-function-dynamodb-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`1000`

 `BisectBatchOnFunctionError`   <a name="sam-function-dynamodb-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `DestinationConfig`   <a name="sam-function-dynamodb-destinationconfig"></a>
捨棄記錄的 Amazon Simple Queue Service (Amazon SQS) 佇列或 Amazon Simple Notification Service (Amazon SNS) 主題目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-dynamodb-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-dynamodb-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-dynamodb-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-dynamodb-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-dynamodb-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-dynamodb-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-dynamodb-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `MetricsConfig`   <a name="sam-function-dynamodb-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ParallelizationFactor`   <a name="sam-function-dynamodb-parallelizationfactor"></a>
要同時處理每個碎片的批次數量。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ParallelizationFactor](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-parallelizationfactor)` 屬性。

 `StartingPosition`   <a name="sam-function-dynamodb-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-dynamodb-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-dynamodb-stream"></a>
DynamoDB 串流的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `TumblingWindowInSeconds`   <a name="sam-function-dynamodb-tumblingwindowinseconds"></a>
處理時段的持續時間，以秒為單位。有效範圍為 1 到 900 (15 分鐘）。  
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[輪轉視窗](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#streams-tumbling)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[TumblingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-tumblingwindowinseconds)` 屬性。

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

### MetricsConfig 事件
<a name="sam-property-function-dynamodb-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### 現有 DynamoDB 資料表的 DynamoDB 事件來源
<a name="sam-property-function-dynamodb--examples--dynamodb-event-source-for-existing-dynamodb-table"></a>

 AWS 帳戶中已存在的 DynamoDB 資料表的 DynamoDB 事件來源。

#### YAML
<a name="sam-property-function-dynamodb--examples--dynamodb-event-source-for-existing-dynamodb-table--yaml"></a>

```
Events:
  DDBEvent:
    Type: DynamoDB
    Properties:
      Stream: arn:aws:dynamodb:us-east-1:123456789012:table/TestTable/stream/2016-08-11T21:21:33.291
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
```

### 範本中宣告的 DynamoDB 資料表的 DynamoDB 事件
<a name="sam-property-function-dynamodb--examples--dynamodb-event-for-dynamodb-table-declared-in-template"></a>

在相同範本檔案中宣告的 DynamoDB 資料表的 DynamoDB 事件。

#### YAML
<a name="sam-property-function-dynamodb--examples--dynamodb-event-for-dynamodb-table-declared-in-template--yaml"></a>

```
Events:
  DDBEvent:
    Type: DynamoDB
    Properties:
      Stream: 
        !GetAtt MyDynamoDBTable.StreamArn   # This must be the name of a DynamoDB table declared in the same template file
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
```

# EventBridgeRule
<a name="sam-property-function-eventbridgerule"></a>

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

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) 資源。 AWS SAM 也會建立 資源`AWS::Lambda::Permission`，這是必要的，以便 `EventBridgeRule`可以呼叫 Lambda。

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

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

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

```
  [DeadLetterConfig](#sam-function-eventbridgerule-deadletterconfig): DeadLetterConfig
  [EventBusName](#sam-function-eventbridgerule-eventbusname): String
  [Input](#sam-function-eventbridgerule-input): String
  [InputPath](#sam-function-eventbridgerule-inputpath): String
  InputTransformer: [InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)
  [Pattern](#sam-function-eventbridgerule-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  [RetryPolicy](#sam-function-eventbridgerule-retrypolicy): [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)
  RuleName: String 
  State: String
  [Target](#sam-function-eventbridgerule-target): Target
```

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

 `DeadLetterConfig`   <a name="sam-function-eventbridgerule-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-deadletterconfig.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 建立無效字母佇列。

 `EventBusName`   <a name="sam-function-eventbridgerule-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-function-eventbridgerule-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)` 屬性。

 `InputPath`   <a name="sam-function-eventbridgerule-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

 `InputTransformer`   <a name="sam-function-eventbridgerule-inputtransformer"></a>
此設定能讓您以特定事件資料為基礎，向目標提供自訂輸入。您可從事件擷取一或多組鍵/值對，然後使用該資料將自訂輸入傳送至目標。如需詳細資訊，請參閱《[Amazon EventBridge 使用者指南》中的 Amazon EventBridge 輸入轉換](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。 * EventBridge *   
*類型*：[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputtransformer)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule``Target`資料類型的 `[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)` 屬性。

 `Pattern`   <a name="sam-function-eventbridgerule-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《[Amazon EventBridge ](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html) 使用者指南》中的 Amazon [EventBridge 事件和 EventBridge 事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

 `RetryPolicy`   <a name="sam-function-eventbridgerule-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)` 屬性。

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

 `State`   <a name="sam-function-eventbridgerule-state"></a>
規則的狀態。  
*接受的值*： `DISABLED` \$1 `ENABLED` \$1 `ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state) ` 屬性。

 `Target`   <a name="sam-function-eventbridgerule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-function-target.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。 `Amazon EC2 RebootInstances API call` 是目標屬性的範例。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

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

### EventBridgeRule
<a name="sam-property-function-eventbridgerule--examples--eventbridgerule"></a>

以下是`EventBridgeRule`事件來源類型的範例。

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

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - terminated
    RetryPolicy:
      MaximumRetryAttempts: 5
      MaximumEventAgeInSeconds: 900
    DeadLetterConfig:
      Type: SQS
      QueueLogicalId: EBRuleDLQ
    Target:
      Id: MyTarget
```

# DeadLetterConfig
<a name="sam-property-function-deadletterconfig"></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-deadletterconfig-syntax"></a>

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

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

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

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

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

 `Type`   <a name="sam-function-deadletterconfig-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-deadletterconfig--examples"></a>

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

DeadLetterConfig

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

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

# Target
<a name="sam-property-function-target"></a>

設定觸發規則時 EventBridge 叫用 AWS 的資源。

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

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

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

```
  [Id](#sam-function-target-id): String
```

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

 `Id`   <a name="sam-function-target-id"></a>
目標的邏輯 ID。  
的值`Id`可以包含英數字元、句點 (`.`)、連字號 (`-`) 和底線 ()`_`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[Id](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-id)` 屬性。

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

### Target
<a name="sam-property-function-target--examples--target"></a>

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

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Target:
      Id: MyTarget
```

# HttpApi
<a name="sam-property-function-httpapi"></a>

描述具有 HttpApi 類型的事件來源的物件。

如果 API 上存在指定路徑和方法的 OpenApi 定義，SAM 會為您新增 Lambda 整合和安全性區段 （如適用）。

如果 API 上沒有指定路徑和方法的 OpenApi 定義，SAM 會為您建立此定義。

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

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

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

```
  [ApiId](#sam-function-httpapi-apiid): String
  [Auth](#sam-function-httpapi-auth): HttpApiFunctionAuth
  [Method](#sam-function-httpapi-method): String
  [Path](#sam-function-httpapi-path): String
  [PayloadFormatVersion](#sam-function-httpapi-payloadformatversion): String
  [RouteSettings](#sam-function-httpapi-routesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [TimeoutInMillis](#sam-function-httpapi-timeoutinmillis): Integer
```

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

 `ApiId`   <a name="sam-function-httpapi-apiid"></a>
此範本中定義之[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源的識別符。  
如果未定義，則會`ServerlessHttpApi`使用產生的 OpenApi 文件來建立稱為 的預設[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源，其中包含由此範本中未指定 之 Api 事件所定義的所有路徑和方法的聯集`ApiId`。  
這無法參考另一個範本中定義的[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Auth`   <a name="sam-function-httpapi-auth"></a>
此特定 Api\$1Path\$1Method 的驗證組態。  
用於在未指定 `DefaultAuthorizer` 時覆寫 API 的 `DefaultAuthorizer`或設定個別路徑上的身分驗證組態。  
*類型*：[HttpApiFunctionAuth](sam-property-function-httpapifunctionauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-function-httpapi-method"></a>
叫用此函數的 HTTP 方法。  
如果未指定 `Method` `Path`和 ，SAM 會建立預設 API 路徑，將任何未對應至不同端點的請求路由至此 Lambda 函數。每個 API 只能存在其中一個預設路徑。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Path`   <a name="sam-function-httpapi-path"></a>
叫用此函數的 Uri 路徑。必須以 開頭`/`。  
如果未指定 `Method` `Path`和 ，SAM 會建立預設 API 路徑，將任何未對應至不同端點的請求路由至此 Lambda 函數。每個 API 只能存在其中一個預設路徑。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `PayloadFormatVersion`   <a name="sam-function-httpapi-payloadformatversion"></a>
為傳送至整合的承載指定格式。  
注意：PayloadFormatVersion 需要 SAM 修改您的 OpenAPI 定義，因此僅適用於 `DefinitionBody` 屬性中定義的內嵌 OpenApi。  
*類型：*字串  
*必要*：否  
*預設*：2.0  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RouteSettings`   <a name="sam-function-httpapi-routesettings"></a>
此 HTTP API 的每個路由路由設定。如需路由設定的詳細資訊，請參閱 *API Gateway 開發人員指南*中的 [AWS::ApiGatewayV2::Stage RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html)。  
注意：如果在 HttpApi 資源和事件來源中都指定 RouteSettings， 會將它們與優先的事件來源屬性 AWS SAM 合併。  
*類型*：[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)` 屬性。

 `TimeoutInMillis`   <a name="sam-function-httpapi-timeoutinmillis"></a>
自訂介於 50 和 29,000 毫秒之間的逾時。  
注意：TimeoutInMillis 需要 SAM 修改您的 OpenAPI 定義，因此僅適用於 `DefinitionBody` 屬性中定義的內嵌 OpenApi。  
*類型*：整數  
*必要*：否  
*預設*：5000  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

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

### 預設 HttpApi 事件
<a name="sam-property-function-httpapi--examples--default-httpapi-event"></a>

使用預設路徑的 HttpApi 事件。此 API 上所有未映射的路徑和方法都會路由至此端點。

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

```
Events:
  HttpApiEvent:
    Type: HttpApi
```

### HttpApi
<a name="sam-property-function-httpapi--examples--httpapi"></a>

使用特定路徑和方法的 HttpApi 事件。

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

```
Events:
  HttpApiEvent:
    Type: HttpApi
    Properties:
      Path: /
      Method: GET
```

### HttpApi 授權
<a name="sam-property-function-httpapi--examples--httpapi-authorization"></a>

使用 授權方的 HttpApi 事件。

#### YAML
<a name="sam-property-function-httpapi--examples--httpapi-authorization--yaml"></a>

```
Events:
  HttpApiEvent:
    Type: HttpApi
    Properties:
      Path: /authenticated
      Method: GET
      Auth:
        Authorizer: OpenIdAuth
        AuthorizationScopes:
          - scope1
          - scope2
```

# HttpApiFunctionAuth
<a name="sam-property-function-httpapifunctionauth"></a>

在事件層級設定授權。

設定特定 API \$1 路徑 \$1 方法的驗證

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

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

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

```
  [AuthorizationScopes](#sam-function-httpapifunctionauth-authorizationscopes): List
  [Authorizer](#sam-function-httpapifunctionauth-authorizer): String
```

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

 `AuthorizationScopes`   <a name="sam-function-httpapifunctionauth-authorizationscopes"></a>
要套用至此 API、路徑和方法的授權範圍。  
`DefaultAuthorizer` 如果存在，此處列出的範圍會覆寫 套用的任何範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Authorizer`   <a name="sam-function-httpapifunctionauth-authorizer"></a>
特定函數`Authorizer`的 。若要使用 IAM 授權，請在範本的 `Globals`區段`EnableIamAuthorizer`中指定 `AWS_IAM`和 `true`的 。  
如果您已在 API 上指定全域授權方，並想要將特定函數設為公有，請將 `Authorizer`設定為 以覆寫 `NONE`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### Function-Auth
<a name="sam-property-function-httpapifunctionauth--examples--function-auth"></a>

在函數層級指定授權

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--function-auth--yaml"></a>

```
Auth:
  Authorizer: OpenIdAuth
  AuthorizationScopes:
    - scope1
    - scope2
```

### IAM 授權
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization"></a>

在事件層級指定 IAM 授權。若要在事件層級使用`AWS_IAM`授權，您還必須在範本的 `Globals`區段`EnableIamAuthorizer`中指定 `true` 的 。如需詳細資訊，請參閱[AWS SAM 範本的全域區段](sam-specification-template-anatomy-globals.md)。

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization--yaml"></a>

```
Globals:
  HttpApi:
    Auth:
      EnableIamAuthorizer: true

Resources:
  HttpApiFunctionWithIamAuth:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: HttpApi
          Properties:
            Path: /iam-auth
            Method: GET
            Auth:
              Authorizer: AWS_IAM
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
          return {'body': 'HttpApiFunctionWithIamAuth', 'statusCode': 200}
      Runtime: python3.9
```

# IoTRule
<a name="sam-property-function-iotrule"></a>

描述`IoTRule`事件來源類型的物件。

建立 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html) 資源以宣告 AWS IoT 規則。如需詳細資訊，請參閱 [CloudFormation 文件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html)

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

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

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

```
  [AwsIotSqlVersion](#sam-function-iotrule-awsiotsqlversion): String
  [Sql](#sam-function-iotrule-sql): String
```

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

 `AwsIotSqlVersion`   <a name="sam-function-iotrule-awsiotsqlversion"></a>
評估規則時所用的 SQL 規則引擎版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IoT::TopicRule TopicRulePayload` 資源的 `[AwsIotSqlVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-awsiotsqlversion)` 屬性。

 `Sql`   <a name="sam-function-iotrule-sql"></a>
用於查詢主題的 SQL 陳述式。如需詳細資訊，請參閱《 *AWS IoT 開發人員指南*》中的 [AWS IoT SQL 參考](https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html#aws-iot-sql-reference)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IoT::TopicRule TopicRulePayload` 資源的 `[Sql](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-sql)` 屬性。

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

### IOT 規則
<a name="sam-property-function-iotrule--examples--iot-rule"></a>

IOT 規則範例

#### YAML
<a name="sam-property-function-iotrule--examples--iot-rule--yaml"></a>

```
IoTRule:
  Type: IoTRule
  Properties:
    Sql: SELECT * FROM 'topic/test'
```

# Kinesis
<a name="sam-property-function-kinesis"></a>

描述`Kinesis`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon Kinesis](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html)。

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

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

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

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

```
  [BatchSize](#sam-function-kinesis-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-kinesis-bisectbatchonfunctionerror): Boolean
  [DestinationConfig](#sam-function-kinesis-destinationconfig): [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)
  [Enabled](#sam-function-kinesis-enabled): Boolean
  [FilterCriteria](#sam-function-kinesis-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-kinesis-functionresponsetypes): List
  KmsKeyArn: String          
  [MaximumBatchingWindowInSeconds](#sam-function-kinesis-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-kinesis-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-kinesis-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-kinesis-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ParallelizationFactor](#sam-function-kinesis-parallelizationfactor): Integer
  [StartingPosition](#sam-function-kinesis-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-kinesis-stream): String
  [TumblingWindowInSeconds](#sam-function-kinesis-tumblingwindowinseconds): Integer
```

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

 `BatchSize`   <a name="sam-function-kinesis-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `BisectBatchOnFunctionError`   <a name="sam-function-kinesis-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `DestinationConfig`   <a name="sam-function-kinesis-destinationconfig"></a>
捨棄記錄的 Amazon Simple Queue Service (Amazon SQS) 佇列或 Amazon Simple Notification Service (Amazon SNS) 主題目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-kinesis-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-kinesis-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-kinesis-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-batchfailurereporting)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-kinesis-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-kinesis-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-kinesis-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-kinesis-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `MetricsConfig`   <a name="sam-function-kinesis-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](sam-property-function-dynamodb.md#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ParallelizationFactor`   <a name="sam-function-kinesis-parallelizationfactor"></a>
要同時處理每個碎片的批次數量。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ParallelizationFactor](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-parallelizationfactor)` 屬性。

 `StartingPosition`   <a name="sam-function-kinesis-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-kinesis-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-kinesis-stream"></a>
資料串流或串流消費者的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `TumblingWindowInSeconds`   <a name="sam-function-kinesis-tumblingwindowinseconds"></a>
處理時段的持續時間，以秒為單位。有效範圍為 1 到 900 (15 分鐘）。  
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[輪轉視窗](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#streams-tumbling)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[TumblingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-tumblingwindowinseconds)` 屬性。

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

### MetricsConfig 事件
<a name="sam-property-function-kinesis-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### Kinesis 事件來源
<a name="sam-property-function-kinesis--examples--kinesis-event-source"></a>

以下是 Kinesis 事件來源的範例。

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

```
Events:
  KinesisEvent:
    Type: Kinesis
    Properties:
      Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
      FilterCriteria: 
        Filters: 
          - Pattern: '{"key": ["val1", "val2"]}'
```

# MQ
<a name="sam-property-function-mq"></a>

描述`MQ`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 Lambda 與 Amazon MQ](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html)。

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

**注意**  
若要在虛擬私有雲端 (VPC) 中擁有連線至公有網路中 Lambda 函數的 Amazon MQ 佇列，函數的執行角色必須包含下列許可：  
`ec2:CreateNetworkInterface`
`ec2:DeleteNetworkInterface`
`ec2:DescribeNetworkInterfaces`
`ec2:DescribeSecurityGroups`
`ec2:DescribeSubnets`
`ec2:DescribeVpcs`
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[執行角色許可](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions)。

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

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

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

```
  [BatchSize](#sam-function-mq-batchsize): Integer
  [Broker](#sam-function-mq-broker): String
  DynamicPolicyName: Boolean
  [Enabled](#sam-function-mq-enabled): Boolean
  [FilterCriteria](#sam-function-mq-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  KmsKeyArn: String 
  [MaximumBatchingWindowInSeconds](#sam-function-mq-maximumbatchingwindowinseconds): Integer
  [Queues](#sam-function-mq-queues): List
  [SecretsManagerKmsKeyId](#sam-function-mq-secretsmanagerkmskeyid): String
  [SourceAccessConfigurations](#sam-function-mq-sourceaccessconfigurations): List
```

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

 `BatchSize`   <a name="sam-function-mq-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `Broker`   <a name="sam-function-mq-broker"></a>
Amazon MQ 代理程式的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `DynamicPolicyName`   <a name="sam-function-mq-dynamicpolicyname"></a>
根據預設， AWS Identity and Access Management (IAM) 政策名稱`SamAutoGeneratedAMQPolicy`用於回溯相容性。指定 `true` 為您的 IAM 政策使用自動產生的名稱。此名稱將包含 Amazon MQ 事件來源邏輯 ID。  
使用多個 Amazon MQ 事件來源時，請指定 `true`以避免重複的 IAM 政策名稱。
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Enabled`   <a name="sam-function-mq-enabled"></a>
如果為 `true`，則事件來源映射為作用中。若要暫停輪詢和調用，請將 設定為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-mq-filtercriteria"></a>
定義決定 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `KmsKeyArn`   <a name="sam-function-mq-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-mq-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `Queues`   <a name="sam-function-mq-queues"></a>
要使用的 Amazon MQ 代理程式目的地佇列的名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Queues](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-queues)` 屬性。

 `SecretsManagerKmsKeyId`   <a name="sam-function-mq-secretsmanagerkmskeyid"></a>
客戶受管金鑰的 AWS Key Management Service (AWS KMS) 金鑰 ID AWS Secrets Manager。當您使用來自 Secrets Manager 的客戶受管金鑰搭配不包含 `kms:Decrypt`許可的 Lambda 執行角色時，此為必要項目。  
此屬性的值是 UUID。例如：`1abc23d4-567f-8ab9-cde0-1fab234c5d67`。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceAccessConfigurations`   <a name="sam-function-mq-sourceaccessconfigurations"></a>
身分驗證通訊協定或虛擬主機的陣列。使用 [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 資料類型指定此項目。  
對於`MQ`事件來源類型，唯一有效的組態類型是 `BASIC_AUTH`和 `VIRTUAL_HOST`。  
+ **`BASIC_AUTH`** – 存放代理程式登入資料的 Secrets Manager 秘密。對於此類型，登入資料必須採用下列格式：`{"username": "your-username", "password": "your-password"}`。僅允許一個 類型的物件`BASIC_AUTH`。
+ **`VIRTUAL_HOST`** – RabbitMQ 代理程式中的虛擬主機名稱。Lambda 會使用此 Rabbit MQ 的主機做為事件來源。僅允許一個 類型的物件`VIRTUAL_HOST`。
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)` 屬性。

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

### Amazon MQ 事件來源
<a name="sam-property-function-mq--examples--amazon-mq-event-source"></a>

以下是 Amazon MQ 代理程式`MQ`的事件來源類型範例。

#### YAML
<a name="sam-property-function-mq--examples--amazon-mq-event-source--yaml"></a>

```
Events:
  MQEvent:
    Type: MQ
    Properties:
      Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9
      Queues: List of queues
      SourceAccessConfigurations:
        - Type: BASIC_AUTH
          URI: arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName
      BatchSize: 200
      Enabled: true
```

# MSK
<a name="sam-property-function-msk"></a>

描述`MSK`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon MSK](https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html)。

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

若要使用結構描述登錄檔，您需要定義函數的特定 IAM 角色許可。如需所需組態的範例，請參閱[使用 IAM 角色完成設定](#sam-property-function-msk-example-complete)。

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

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

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

```
  [BatchSize](#sam-function-msk-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-msk-bisectbatchonfunctionerror): Boolean
  [ConsumerGroupId](#sam-function-msk-consumergroupid): String
  DestinationConfig: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)
  [Enabled](#sam-function-msk-enabled): Boolean
  [FilterCriteria](#sam-function-msk-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-msk-functionresponsetypes): List
  KmsKeyArn: String
  [MaximumBatchingWindowInSeconds](#sam-function-msk-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-msk-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-msk-maximumretryattempts): Integer
  [LoggingConfig](#sam-function-msk-loggingconfig): [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)
  [MetricsConfig](#sam-function-msk-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)
  [ProvisionedPollerConfig](#sam-function-msk-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [SchemaRegistryConfig](#sam-function-msk-schemaregistryconfig): [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html)
  SourceAccessConfigurations: [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)
  [StartingPosition](#sam-function-msk-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-msk-stream): String
  [Topics](#sam-function-msk-topics): List
```

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

 `BatchSize`   <a name="sam-function-msk-batchsize"></a>
Lambda 從串流或佇列中提取並傳送至函數的每個批次中的記錄數目上限。Lambda 會將批次中的所有記錄以單一呼叫形式傳送至函數，直到達到同步調用的承載限制 (6 MB)。  
*預設值*：100  
*有效範圍*：最小值為 1。最大值為 10，000。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。

 `BisectBatchOnFunctionError`   <a name="sam-function-msk-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `ConsumerGroupId`   <a name="sam-function-msk-consumergroupid"></a>
設定如何從 Kafka 主題讀取事件的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[AmazonManagedKafkaConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html)` 屬性。

 `DestinationConfig`   <a name="sam-function-msk-destinationconfig"></a>
組態物件，指定在 Lambda 處理過後事件的目標。  
使用此屬性可指定來自 Amazon MSK 事件來源的失敗調用目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)` 屬性。

 `Enabled`   <a name="sam-function-msk-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-msk-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-msk-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/kafka-retry-configurations.html)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-msk-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-msk-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-msk-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-msk-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `LoggingConfig`   <a name="sam-function-msk-loggingconfig"></a>
組態物件，指定事件來源映射的記錄組態。  
*類型*︰[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)` 屬性。

 `MetricsConfig`   <a name="sam-function-msk-metricsconfig"></a>
組態物件，指定事件來源映射的指標組態。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-msk-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 1 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-msk-example-provisionedpollerconfig)。  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

`SchemaRegistryConfig`  <a name="sam-function-msk-schemaregistryconfig"></a>
搭配 Kafka 事件來源使用結構描述登錄檔的組態。  
此功能`ProvisionedPollerConfig`需要設定。
*類型*： SchemaRegistryConfig  
*必要*：否  
*CloudFormation 相容性：*此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[AmazonManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-amazonmanagedkafkaeventsourceconfig)` 屬性。

 `SourceAccessConfigurations`   <a name="sam-function-msk-sourceaccessconfigurations"></a>
保護和定義事件來源的身分驗證協定、VPC 元件或虛擬主機。  
*有效值*：`CLIENT_CERTIFICATE_TLS_AUTH`  
*類型*：[SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 清單  
*必要*：否  
*CloudFormation 相容性：*此屬性是 `AWS::Lambda::EventSourceMapping` 資源的 [AmazonManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-lambda-eventsourcemapping-amazonmanagedkafkaeventsourceconfig) 屬性的一部分。

 `StartingPosition`   <a name="sam-function-msk-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-msk-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-msk-stream"></a>
資料串流或串流取用者的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `Topics`   <a name="sam-function-msk-topics"></a>
Kafka 主題名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Topics](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics)` 屬性。

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

### 使用 IAM 角色完成設定
<a name="sam-property-function-msk-example-complete"></a>

下列範例顯示完整的設定，包括使用結構描述登錄所需的 IAM 角色組態：

```
Parameters:
  PreCreatedSubnetOne:
    Type: String
  PreCreatedSubnetTwo:
    Type: String
  MskClusterName4:
    Type: String

Resources:
  MyLambdaExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17		 	 	 '
        Statement:
        - Action: [sts:AssumeRole]
          Effect: Allow
          Principal:
            Service: [lambda.amazonaws.com]
      Policies:
      - PolicyName: KafkaClusterPermissions
        PolicyDocument:
          Statement:
          - Action: [kafka:DescribeClusterV2, kafka:GetBootstrapBrokers]
            Effect: Allow
            Resource: 'arn:aws:kafka:us-east-1:123456789012:cluster/*'
      - PolicyName: KafkaAuthPolicy
        PolicyDocument:
          Statement:
          - Action: [secretsmanager:GetSecretValue, kms:Decrypt]
            Effect: "Allow"
            Resource: ['arn:aws:secretsmanager:us-west-2:123456789012:secret:kafkaSecret-******',
                        'arn:aws:kms:us-west-2:123456789012:key/keyId']
      - PolicyName: ENIPolicy
        PolicyDocument:
          Statement:
          - Action: [ec2:CreateNetworkInterface,
              ec2:DescribeNetworkInterfaces, ec2:DescribeVpcs, ec2:DeleteNetworkInterface,
              ec2:DescribeSubnets, ec2:DescribeSecurityGroups]
            Effect: Allow
            Resource: '*'
      - PolicyName: SchemaRegistryPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetRegistry]
            Effect: Allow
            Resource: 'arn:aws:glue:{region}:{account-id}:registry/{registry-name}'
      - PolicyName: SchemaVersionsPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetSchemaVersions]
            Effect: Allow
            Resource: '*'
      ManagedPolicyArns:
      - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Tags:
      - {Value: SAM, Key: lambda:createdBy}

  MyMskCluster:
    Type: AWS::MSK::Cluster
    Properties:
      BrokerNodeGroupInfo:
        ClientSubnets:
        - Ref: PreCreatedSubnetOne
        - Ref: PreCreatedSubnetTwo
        InstanceType: kafka.t3.small
        StorageInfo:
          EBSStorageInfo:
            VolumeSize: 1
      ClusterName:
        Ref: MskClusterName4
      KafkaVersion: 3.8.x
      NumberOfBrokerNodes: 2

  MyMskStreamProcessor:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs18.x
      Handler: index.handler
      CodeUri: ${codeuri}
      Role:
        Fn::GetAtt: [MyLambdaExecutionRole, Arn]
      Events:
        MyMskEvent:
          Type: MSK
          Properties:
            StartingPosition: LATEST
            Stream:
              Ref: MyMskCluster
            SourceAccessConfigurations:
            - Type: SASL_SCRAM_512_AUTH
              URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
            Topics:
            - SchemaRegistryTestTopic
            ProvisionedPollerConfig:
              MinimumPollers: 1
            SchemaRegistryConfig:
              AccessConfigs:
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
              SchemaValidationConfigs:
              - Attribute: KEY
              EventRecordFormat: JSON
              SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-msk-example-provisionedpollerconfig"></a>

```
ProvisionedPollerConfig:
  MinimumPollers: 1
  MaximumPollers: 200
```

### 現有叢集的 Amazon MSK 範例
<a name="sam-property-function-msk--examples--amazon-msk-example-for-existing-cluster"></a>

以下是已存在於 之 Amazon MSK 叢集`MSK`的事件來源類型範例 AWS 帳戶。

#### YAML
<a name="sam-property-function-msk--examples--amazon-msk-example-for-existing-cluster--yaml"></a>

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream: arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2
      Topics:
        - MyTopic
```

### 相同範本中宣告之叢集的 Amazon MSK 範例
<a name="sam-property-function-msk--examples--amazon-msk-example-for-cluster-declared-in-same-template"></a>

以下是在相同範本檔案中宣告之 Amazon MSK 叢集`MSK`的事件來源類型範例。

#### YAML
<a name="sam-property-function-msk--examples--amazon-msk-example-for-cluster-declared-in-same-template--yaml"></a>

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster   # This must be the name of an MSK cluster declared in the same template file
      Topics:
        - MyTopic
```

#### 具有結構描述登錄檔的 MSK 事件來源
<a name="sam-property-function-msk-example-schemaregistry"></a>

以下是使用結構描述登錄檔設定`MSK`的事件來源類型範例。

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster
      Topics:
        - SchemaRegistryTestTopic
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
```

#### 具有 Confluent 結構描述登錄檔的 MSK 事件來源
<a name="sam-property-function-msk-example-schemaregistry-confluent"></a>

以下是使用 Confluent 結構描述登錄檔設定`MSK`的事件來源類型範例。

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster
      Topics:
        - SchemaRegistryTestTopic
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: https://my-schema-registry.confluent.cloud
        AccessConfigs:
          - Type: BASIC_AUTH
            URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-secret
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
```

# S3
<a name="sam-property-function-s3"></a>

描述`S3`事件來源類型的物件。

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

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

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

```
  [Bucket](#sam-function-s3-bucket): String
  [Events](#sam-function-s3-events): String | List
  [Filter](#sam-function-s3-filter): [NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)
```

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

 `Bucket`   <a name="sam-function-s3-bucket"></a>
S3 儲存貯體名稱。此儲存貯體必須存在於相同的範本中。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::S3::Bucket` 資源的 `[BucketName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-name)` 屬性。這是 SAM 中的必要欄位。此欄位僅接受在此範本中建立之 S3 儲存貯體的參考

 `Events`   <a name="sam-function-s3-events"></a>
要叫用 Lambda 函數的 Amazon S3 儲存貯體事件。如需有效值的清單，請參閱 [Amazon S3 支援的事件類型](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types)。  
*類型*：字串 \$1 清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Event](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig-lambdaconfig.html#cfn-s3-bucket-notificationconfig-lambdaconfig-event)` 屬性。

 `Filter`   <a name="sam-function-s3-filter"></a>
篩選規則，決定哪些 Amazon S3 物件叫用 Lambda 函數。如需 Amazon S3 金鑰名稱篩選的相關資訊，請參閱[《Amazon Simple Storage Service 使用者指南》中的設定 Amazon S3 事件通知](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html)。 **  
*類型*：[NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Filter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)` 屬性。

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

### S3-Event
<a name="sam-property-function-s3--examples--s3-event"></a>

S3 事件的範例。

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

```
Events:
  S3Event:
    Type: S3
    Properties:
      Bucket:
        Ref: ImagesBucket     # This must be the name of an S3 bucket declared in the same template file
      Events: s3:ObjectCreated:*
      Filter:
        S3Key:
          Rules:
          - Name: prefix      # or "suffix"
            Value: value      # The value to search for in the S3 object key names
```

# 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
```

# ScheduleV2
<a name="sam-property-function-schedulev2"></a>

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

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

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

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

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

```
[DeadLetterConfig](#sam-function-schedulev2-deadletterconfig): DeadLetterConfig
[Description](#sam-function-schedulev2-description): String
[EndDate](#sam-function-schedulev2-enddate): String
[FlexibleTimeWindow](#sam-function-schedulev2-flexibletimewindow): FlexibleTimeWindow
[GroupName](#sam-function-schedulev2-groupname): String
[Input](#sam-function-schedulev2-input): String
[KmsKeyArn](#sam-function-schedulev2-kmskeyarn): String
[Name](#sam-function-schedulev2-name): String
OmitName: Boolean
[PermissionsBoundary](#sam-function-schedulev2-permissionsboundary): String
[RetryPolicy](#sam-function-schedulev2-retrypolicy): RetryPolicy
[RoleArn](#sam-function-schedulev2-rolearn): String
[ScheduleExpression](#sam-function-schedulev2-schedule): String
[ScheduleExpressionTimezone](#sam-function-schedulev2-scheduleexpressiontimezone): String
[StartDate](#sam-function-schedulev2-startdate): String
[State](#sam-function-schedulev2-state): String
```

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

 `DeadLetterConfig`   <a name="sam-function-schedulev2-deadletterconfig"></a>
設定 Amazon Simple Queue Service (Amazon SQS) 佇列，EventBridge 會在目標呼叫失敗後傳送事件。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《[EventBridge 排程器使用者指南》中的為 EventBridge 排程器設定無效字母佇列](https://docs.aws.amazon.com/scheduler/latest/UserGuide/configuring-schedule-dlq.html)。 *EventBridge *  
[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::Scheduler::Schedule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `Description`   <a name="sam-function-schedulev2-description"></a>
排程的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-description)` 屬性。

 `EndDate`   <a name="sam-function-schedulev2-enddate"></a>
UTC 日期，排程可在此日期之前叫用其目標。視排程的週期運算式而定，叫用可能會在您指定的 **EndDate** 當天或之前停止。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[EndDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-enddate)` 屬性。

 `FlexibleTimeWindow`   <a name="sam-function-schedulev2-flexibletimewindow"></a>
允許在其中叫用排程的時段組態。  
*類型*：[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-flexibletimewindow)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-flexibletimewindow)` 屬性。

 `GroupName`   <a name="sam-function-schedulev2-groupname"></a>
要與此排程建立關聯的排程群組名稱。如果未定義，則會使用預設群組。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[GroupName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname)` 屬性。

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

 `KmsKeyArn`   <a name="sam-function-schedulev2-kmskeyarn"></a>
KMS 金鑰的 ARN，將用於加密客戶資料。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-kmskeyarn)` 屬性。

 `Name`   <a name="sam-function-schedulev2-name"></a>
排程的名稱。如果您未指定名稱， 會以 格式 AWS SAM 產生名稱`Function-Logical-IDEvent-Source-Name`，並使用該 ID 做為排程名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-name)` 屬性。

`OmitName`  <a name="sam-function-schedulev2-omitname"></a>
根據預設， AWS SAM 會產生並使用 *<Function-logical-ID><event-source-name>* 格式的排程名稱。將此屬性設定為 `true`，讓 CloudFormation 產生唯一的實體 ID，並改為將該 ID 用於排程名稱。  
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 的。

 `PermissionsBoundary`   <a name="sam-function-schedulev2-permissionsboundary"></a>
用來設定角色許可邊界的政策 ARN。  
如果`PermissionsBoundary`已定義 ， AWS SAM 會將相同的邊界套用至排程器排程的目標 IAM 角色。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)` 屬性。

 `RetryPolicy`   <a name="sam-function-schedulev2-retrypolicy"></a>
包含重試政策設定相關資訊的 **RetryPolicy** 物件。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)` 屬性。

 `RoleArn`   <a name="sam-function-schedulev2-rolearn"></a>
調用排程時EventBridge 排程器用於目標的 IAM 角色 ARN。  
*類型*：[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)` 屬性。

 `ScheduleExpression`   <a name="sam-function-schedulev2-scheduleexpression"></a>
排程表達式，可決定排程器排程事件執行的時間和頻率。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpression)` 屬性。

 `ScheduleExpressionTimezone`   <a name="sam-function-schedulev2-scheduleexpressiontimezone"></a>
計算排程運算式所使用的時區。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpressionTimezone](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpressiontimezone)` 屬性。

 `StartDate`   <a name="sam-function-schedulev2-startdate"></a>
排程開始調用目標的日期，以 UTC 為單位。視排程的週期運算式而定，叫用可能會在您指定的 **StartDate** 當天或之後發生。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[StartDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-startdate)` 屬性。

 `State`   <a name="sam-function-schedulev2-state"></a>
排程器排程的狀態。  
*接受的值：* `DISABLED | ENABLED`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-state)` 屬性。

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

### 定義 ScheduleV2 資源的基本範例
<a name="sam-property-function-schedulev2--examples--example1"></a>

```
Resources:
  Function:
    Properties:
      ...
      Events:
        ScheduleEvent:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: "rate(1 minute)"
        ComplexScheduleEvent:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: rate(1 minute)
            FlexibleTimeWindow:
              Mode: FLEXIBLE
              MaximumWindowInMinutes: 5
            StartDate: '2022-12-28T12:00:00.000Z'
            EndDate: '2023-01-28T12:00:00.000Z'
            ScheduleExpressionTimezone: UTC
            RetryPolicy:
              MaximumRetryAttempts: 5
              MaximumEventAgeInSeconds: 300
            DeadLetterConfig:
              Type: SQS
```

**注意**  
ScheduleV2 產生的實體 ID 不包含堆疊名稱。

# SelfManagedKafka
<a name="sam-property-function-selfmanagedkafka"></a>

描述`SelfManagedKafka`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[使用 AWS Lambda 搭配自我管理的 Apache Kafka](https://docs.aws.amazon.com/lambda/latest/dg/with-kafka.html)。

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

若要使用結構描述登錄檔，您需要定義函數的特定 IAM 角色許可。如需所需組態的範例，請參閱[使用 IAM 角色完成設定](sam-property-function-msk.md#sam-property-function-msk-example-complete)。

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

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

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

```
  [BatchSize](#sam-function-selfmanagedkafka-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-selfmanagedkafka-bisectbatchonfunctionerror): Boolean
  [ConsumerGroupId](#sam-function-selfmanagedkafka-consumergroupid): String
  DestinationConfig: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)
  [Enabled](#sam-function-selfmanagedkafka-enabled): Boolean
  [FilterCriteria](#sam-function-selfmanagedkafka-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [KafkaBootstrapServers](#sam-function-selfmanagedkafka-kafkabootstrapservers): List
  [FunctionResponseTypes](#sam-function-selfmanagedkafka-functionresponsetypes): List
  KmsKeyArn: String
  [LoggingConfig](#sam-function-selfmanagedkafka-loggingconfig): LoggingConfig
  [MaximumRecordAgeInSeconds](#sam-function-selfmanagedkafka-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-selfmanagedkafka-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-selfmanagedkafka-metricsconfig): MetricsConfig
  [ProvisionedPollerConfig](#sam-function-selfmanagedkafka-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [SchemaRegistryConfig](#sam-function-selfmanagedkafka-schemaregistryconfig): [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html)
  [SourceAccessConfigurations](#sam-function-selfmanagedkafka-sourceaccessconfigurations): [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)
  StartingPosition: String
  StartingPositionTimestamp: Double
  [Topics](#sam-function-selfmanagedkafka-topics): List
```

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

 `BatchSize`   <a name="sam-function-selfmanagedkafka-batchsize"></a>
Lambda 從串流提取並傳送至函數的每個批次中的記錄數目上限。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `BisectBatchOnFunctionError`   <a name="sam-function-selfmanagedkafka-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `ConsumerGroupId`   <a name="sam-function-selfmanagedkafka-consumergroupid"></a>
設定如何從 Kafka 主題讀取事件的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性。

 `DestinationConfig`   <a name="sam-function-selfmanagedkafka-destinationconfig"></a>
組態物件，指定在 Lambda 處理過後事件的目標。  
使用此屬性可指定從自我管理 Kafka 事件來源呼叫失敗的目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-selfmanagedkafka-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-selfmanagedkafka-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-filtercriteria)` 屬性。

 `KafkaBootstrapServers`   <a name="sam-function-selfmanagedkafka-kafkabootstrapservers"></a>
Kafka 代理程式的引導伺服器清單。包含連接埠，例如 `broker.example.com:xxxx`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FunctionResponseTypes`   <a name="sam-function-selfmanagedkafka-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/kafka-retry-configurations.html)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-selfmanagedkafka-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `LoggingConfig`   <a name="sam-function-selfmanagedkafka-loggingconfig"></a>
事件來源的記錄組態。  
*類型*︰[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-loggingconfig)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-selfmanagedkafka-maximumrecordageinseconds"></a>
Lambda 傳送至函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MetricsConfig`   <a name="sam-function-selfmanagedkafka-metricsconfig"></a>
事件來源的指標組態。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-selfmanagedkafka-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-selfmanagedkafka-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 1 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-selfmanagedkafka-example-provisionedpollerconfig)  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

`SchemaRegistryConfig`  <a name="sam-function-selfmanagedkafka-schemaregistryconfig"></a>
搭配自我管理 Kafka 事件來源使用結構描述登錄檔的組態。  
此功能`ProvisionedPollerConfig`需要設定。
*類型*： [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig)  
*必要*：否  
*CloudFormation 相容性：*此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性。

 `SourceAccessConfigurations`   <a name="sam-function-selfmanagedkafka-sourceaccessconfigurations"></a>
保護和定義事件來源的身分驗證協定、VPC 元件或虛擬主機。  
*有效值*：`BASIC_AUTH | CLIENT_CERTIFICATE_TLS_AUTH | SASL_SCRAM_256_AUTH | SASL_SCRAM_512_AUTH | SERVER_ROOT_CA_CERTIFICATE`  
*類型*：[SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration) 清單  
*必要*：是  
*CloudFormation 相容性：*此屬性是 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性的一部分。

 `StartingPosition`   <a name="sam-function-selfmanagedkafka-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-selfmanagedkafka-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Topics`   <a name="sam-function-selfmanagedkafka-topics"></a>
Kafka 主題名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Topics](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics)` 屬性。

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

### 使用 IAM 角色完成設定
<a name="sam-property-function-selfmanagedkafka-example-complete"></a>

下列範例顯示完整的設定，包括使用結構描述登錄所需的 IAM 角色組態：

```
Parameters:
  PreCreatedSubnetOne:
    Type: String
  PreCreatedSubnetTwo:
    Type: String

Resources:
  MyLambdaExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17		 	 	 '
        Statement:
        - Action: [sts:AssumeRole]
          Effect: Allow
          Principal:
            Service: [lambda.amazonaws.com]
      Policies:
      - PolicyName: KafkaAuthPolicy
        PolicyDocument:
          Statement:
          - Action: [secretsmanager:GetSecretValue, kms:Decrypt]
            Effect: "Allow"
            Resource: ['arn:aws:secretsmanager:us-west-2:123456789012:secret:kafkaSecret-******',
                        'arn:aws:kms:us-west-2:123456789012:key/keyId']
      - PolicyName: ENIPolicy
        PolicyDocument:
          Statement:
          - Action: [ec2:CreateNetworkInterface,
              ec2:DescribeNetworkInterfaces, ec2:DescribeVpcs, ec2:DeleteNetworkInterface,
              ec2:DescribeSubnets, ec2:DescribeSecurityGroups]
            Effect: Allow
            Resource: '*'
      - PolicyName: SchemaRegistryPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetRegistry]
            Effect: Allow
            Resource: 'arn:aws:glue:{region}:{account-id}:registry/{registry-name}'
      - PolicyName: SchemaVersionsPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetSchemaVersions]
            Effect: Allow
            Resource: '*'
      ManagedPolicyArns:
      - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Tags:
      - {Value: SAM, Key: lambda:createdBy}

  MyKafkaProcessor:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs18.x
      Handler: index.handler
      CodeUri: ${codeuri}
      Role:
        Fn::GetAtt: [MyLambdaExecutionRole, Arn]
      Events:
        SelfManagedKafkaEvent:
          Type: SelfManagedKafka
          Properties:
            KafkaBootstrapServers:
              - my-kafka-broker-1:9092
              - my-kafka-broker-2:9092
            Topics:
              - SchemaRegistryTestTopic
            StartingPosition: LATEST
            SourceAccessConfigurations:
              - Type: VPC_SUBNET
                URI: subnet:subnet-12345678
              - Type: VPC_SECURITY_GROUP
                URI: security_group:sg-12345678
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
            ProvisionedPollerConfig:
              MinimumPollers: 1
            SchemaRegistryConfig:
              AccessConfigs:
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
              SchemaValidationConfigs:
              - Attribute: KEY
              EventRecordFormat: JSON
              SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-selfmanagedkafka-example-provisionedpollerconfig"></a>

```
ProvisionedPollerConfig:
  MinimumPollers: 1
  MaximumPollers: 200
```

### 自我管理的 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka--examples--self-managed-kafka-event-source"></a>

以下是`SelfManagedKafka`事件來源類型的範例。

#### YAML
<a name="sam-property-function-selfmanagedkafka--examples--self-managed-kafka-event-source--yaml"></a>

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      BatchSize: 1000
      Enabled: true
      KafkaBootstrapServers:
        - abc.xyz.com:xxxx
      SourceAccessConfigurations:
        -  Type: BASIC_AUTH
           URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
      Topics:
        - MyKafkaTopic
```

### 具有 AWS Glue 結構描述登錄檔的自我管理 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka-example-schemaregistry"></a>

以下是使用 AWS Glue 結構描述登錄檔設定`SelfManagedKafka`的事件來源類型範例。

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      KafkaBootstrapServers:
        - abc.xyz.com:9092
      Topics:
        - SchemaRegistryTestTopic
      StartingPosition: LATEST
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
      SourceAccessConfigurations:
        - Type: VPC_SUBNET
          URI: subnet:subnet-12345678
        - Type: VPC_SECURITY_GROUP
          URI: security_group:sg-12345678
```

### 具有 Confluent Schema Registry 的自我管理 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka-example-schemaregistry-confluent"></a>

以下是使用 Confluent Schema Registry 設定`SelfManagedKafka`的事件來源類型範例。

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      KafkaBootstrapServers:
        - abc.xyz.com:9092
      Topics:
        - SchemaRegistryTestTopic
      StartingPosition: LATEST
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: https://my-schema-registry.confluent.cloud
        AccessConfigs:
          - Type: BASIC_AUTH
            URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-secret
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
      SourceAccessConfigurations:
        - Type: VPC_SUBNET
          URI: subnet:subnet-12345678
        - Type: VPC_SECURITY_GROUP
          URI: security_group:sg-12345678
        - Type: BASIC_AUTH
          URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:kafka-secret
```

# SNS
<a name="sam-property-function-sns"></a>

描述`SNS`事件來源類型的物件。

設定此事件類型時，SAM 會產生[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html)資源

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

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

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

```
  [FilterPolicy](#sam-function-sns-filterpolicy): [SnsFilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)
  FilterPolicyScope: String
  RedrivePolicy: Json
  [Region](#sam-function-sns-region): String
  [SqsSubscription](#sam-function-sns-sqssubscription): Boolean | SqsSubscriptionObject
  [Topic](#sam-function-sns-topic): String
```

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

 `FilterPolicy`   <a name="sam-function-sns-filterpolicy"></a>
指派給訂閱的篩選條件政策 JSON。如需詳細資訊，請參閱《Amazon Simple Notification Service API 參考》中的 [GetSubscriptionAttributes](https://docs.aws.amazon.com/sns/latest/api/API_GetSubscriptionAttributes.html)。  
*類型*：[SnsFilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[FilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)` 屬性。

 `FilterPolicyScope`   <a name="sam-function-sns-filterpolicyscope"></a>
此屬性可讓您使用下列其中一個字串值類型來選擇篩選範圍：  
+ `MessageAttributes` – 篩選條件會套用至訊息屬性。
+ `MessageBody` – 篩選條件會套用至訊息內文。
*類型：*字串  
*必要*：否  
*預設*：`MessageAttributes`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 ` [ FilterPolicyScope](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicyscope)` 屬性。

 `RedrivePolicy`   <a name="sam-function-sns-redrivepolicy"></a>
如果指定，則會將無法傳遞的訊息傳送到指定的 Amazon SQS 無效信件佇列。由於用戶端錯誤 (例如當訂閱的端點無法連線時) 或伺服器錯誤 (例如提供訂閱端點的服務無法使用) 而無法傳遞的訊息，會保留在無效信件佇列，以供進一步分析或重新處理。  
如需再驅動政策和無效字母佇列的詳細資訊，請參閱[《Amazon Simple Queue Service 開發人員指南》中的 Amazon SQS 無效字母佇列](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html)。 **  
*類型*：Json  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[ RedrivePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-redrivepolicy)` 屬性。

 `Region`   <a name="sam-function-sns-region"></a>
針對跨區域訂閱，為主題所在的區域。  
如果未指定區域，CloudFormation 會使用發起人的區域做為預設值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-region)` 屬性。

 `SqsSubscription`   <a name="sam-function-sns-sqssubscription"></a>
將此屬性設定為 true，或指定 `SqsSubscriptionObject` 在 SQS 佇列中啟用批次 SNS 主題通知。將此屬性設定為`true`建立新的 SQS 佇列，而指定 `SqsSubscriptionObject`會使用現有的 SQS 佇列。  
*類型*：布林值 \$1 [SqsSubscriptionObject](sam-property-function-sqssubscriptionobject.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Topic`   <a name="sam-function-sns-topic"></a>
要訂閱的主題 ARN。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[TopicArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#topicarn)` 屬性。

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

### SNS 事件來源範例
<a name="sam-property-function-sns--examples--sns-event-source-example"></a>

SNS 事件來源範例

#### YAML
<a name="sam-property-function-sns--examples--sns-event-source-example--yaml"></a>

```
Events:
  SNSEvent:
    Type: SNS
    Properties:
      Topic: arn:aws:sns:us-east-1:123456789012:my_topic
      SqsSubscription: true
      FilterPolicy:
        store:
          - example_corp
        price_usd:
          - numeric:
              - ">="
              - 100
```

# SqsSubscriptionObject
<a name="sam-property-function-sqssubscriptionobject"></a>

指定 SNS 事件的現有 SQS 佇列選項

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

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

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

```
  [BatchSize](#sam-function-sqssubscriptionobject-batchsize): String
  [Enabled](#sam-function-sqssubscriptionobject-enabled): Boolean
  [QueueArn](#sam-function-sqssubscriptionobject-queuearn): String
  [QueuePolicyLogicalId](#sam-function-sqssubscriptionobject-queuepolicylogicalid): String
  [QueueUrl](#sam-function-sqssubscriptionobject-queueurl): String
```

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

 `BatchSize`   <a name="sam-function-sqssubscriptionobject-batchsize"></a>
單一批次中針對 SQS 佇列擷取的項目數量上限。  
*類型：*字串  
*必要*：否  
*預設值*：10  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Enabled`   <a name="sam-function-sqssubscriptionobject-enabled"></a>
停用 SQS 事件來源映射以暫停輪詢和調用。  
*類型*：布林值  
*必要*：否  
*預設*：True  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `QueueArn`   <a name="sam-function-sqssubscriptionobject-queuearn"></a>
指定現有的 SQS 佇列 arn。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `QueuePolicyLogicalId`   <a name="sam-function-sqssubscriptionobject-queuepolicylogicalid"></a>
為 [AWS::SQS::QueuePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-policy.html) 資源提供自訂 logicalId 名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `QueueUrl`   <a name="sam-function-sqssubscriptionobject-queueurl"></a>
指定與 `QueueArn` 屬性相關聯的佇列 URL。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

### SNS 事件的現有 SQS
<a name="sam-property-function-sqssubscriptionobject--examples--existing-sqs-for-sns-event"></a>

將現有的 SQS 佇列新增至 SNS 主題的範例。

#### YAML
<a name="sam-property-function-sqssubscriptionobject--examples--existing-sqs-for-sns-event--yaml"></a>

```
QueuePolicyLogicalId: CustomQueuePolicyLogicalId
QueueArn:
  Fn::GetAtt: MyCustomQueue.Arn
QueueUrl:
  Ref: MyCustomQueue
BatchSize: 5
```

# SQS
<a name="sam-property-function-sqs"></a>

描述`SQS`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html)。

設定此事件類型時，SAM 會產生[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html)資源

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

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

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

```
  [BatchSize](#sam-function-sqs-batchsize): Integer
  [Enabled](#sam-function-sqs-enabled): Boolean
  [FilterCriteria](#sam-function-sqs-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-sqs-functionresponsetypes): List
  KmsKeyArn: String
  [MaximumBatchingWindowInSeconds](#sam-function-sqs-maximumbatchingwindowinseconds): Integer
  [MetricsConfig](#sam-function-sqs-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ProvisionedPollerConfig](#sam-function-sqs-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [Queue](#sam-function-sqs-queue): String
  ScalingConfig: [ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)
```

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

 `BatchSize`   <a name="sam-function-sqs-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：10  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `Enabled`   <a name="sam-function-sqs-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-sqs-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-sqs-functionresponsetypes"></a>
 目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting)。  
 *有效值*：`ReportBatchItemFailures`  
 *類型：*清單   
 *必要*：否   
 *CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-sqs-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-sqs-maximumbatchingwindowinseconds"></a>
叫用函數之前收集記錄的時間上限，以秒為單位。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MetricsConfig`   <a name="sam-function-sqs-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](sam-property-function-dynamodb.md#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-sqs-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 2 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-sqs-example-provisionedpollerconfig)。  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

 `Queue`   <a name="sam-function-sqs-queue"></a>
佇列的 ARN。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `ScalingConfig`   <a name="sam-function-sqs-scalingconfig"></a>
SQS 輪詢器的擴展組態，以控制調用速率並設定並行調用上限。  
*Type (類型)*：`[ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)`  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)` 屬性。

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

### MetricsConfig 事件
<a name="sam-property-function-sqs-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### 基本 SQS 事件
<a name="sam-property-function-sqs--examples--sqs-event"></a>

```
Events:
  SQSEvent:
    Type: SQS
    Properties:
      Queue: arn:aws:sqs:us-west-2:012345678901:my-queue
      BatchSize: 10
      Enabled: false
      FilterCriteria:
        Filters:
          - Pattern: '{"key": ["val1", "val2"]}'
```

### 為您的 SQS 佇列設定部分批次報告
<a name="sam-property-function-sqs--examples--sqs-partial-batch"></a>

```
Events:
  SQSEvent:
    Type: SQS
    Properties:
      Enabled: true
      FunctionResponseTypes:
        - ReportBatchItemFailures
      Queue: !GetAtt MySqsQueue.Arn
      BatchSize: 10
```

### 具有已設定擴展之 SQS 事件的 Lambda 函數
<a name="sam-property-function-sqs--examples--sqs-event-scaling"></a>

```
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    ...
    Events:
      MySQSEvent:
        Type: SQS
        Properties:
          ...
          ScalingConfig:
            MaximumConcurrency: 10
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-sqs-example-provisionedpollerconfig"></a>

```
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    Handler: index.handler
    Runtime: nodejs18.x
    Timeout: 30
    Events:
      SQSEvent:
        Type: SQS
        Properties:
          Queue: !GetAtt MyQueue.Arn
          BatchSize: 10
          Enabled: True
          ProvisionedPollerConfig:
            MaximumPollers: 300
            MinimumPollers: 10
```

# FunctionCode
<a name="sam-property-function-functioncode"></a>

Lambda 函數的[部署套裝](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)服務。

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

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

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

```
  [Bucket](#sam-function-functioncode-bucket): String
  [Key](#sam-function-functioncode-key): String
  [Version](#sam-function-functioncode-version): String
```

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

 `Bucket`   <a name="sam-function-functioncode-bucket"></a>
與函數位於相同 AWS 區域中的 Amazon S3 儲存貯體。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `Code` 資料類型的 `[S3Bucket](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3bucket)` 屬性。

 `Key`   <a name="sam-function-functioncode-key"></a>
部署套件的 Amazon S3 金鑰。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `Code` 資料類型的 `[S3Key](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key)` 屬性。

 `Version`   <a name="sam-function-functioncode-version"></a>
對於版本控制的物件，要使用的部署套件物件版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` `Code` 資料類型的 `[S3ObjectVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectversion)` 屬性。

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

### FunctionCode
<a name="sam-property-function-functioncode--examples--functioncode"></a>

`CodeUri`：函數程式碼範例

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

```
CodeUri:
  Bucket: sam-s3-demo-bucket-name
  Key: mykey-name
  Version: 121212
```

# FunctionUrlConfig
<a name="sam-property-function-functionurlconfig"></a>

使用指定的組態參數建立 AWS Lambda 函數 URL。Lambda 函數 URL 是 HTTPS 端點，可用來叫用函數。

根據預設，您建立的函數 URL 會使用 Lambda 函數的 `$LATEST`版本。如果您`AutoPublishAlias`為 Lambda 函數指定 ，端點會連線至指定的函數別名。

如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*[》中的 Lambda 函數 URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html)。

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

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

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

```
[AuthType](#sam-function-functionurlconfig-authtype): String
[Cors](#sam-function-functionurlconfig-cors): [Cors](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-url-cors.html)
[InvokeMode](#sam-function-functionurlconfig-invokemode): String
```

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

 `AuthType`   <a name="sam-function-functionurlconfig-authtype"></a>
函數 URL 的授權類型。若要使用 AWS Identity and Access Management (IAM) 來授權請求，請將 設定為 `AWS_IAM`。針對開放存取，請將 設定為 `NONE`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Url` 資源的 `[AuthType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-url.html#cfn-lambda-url-authtype)` 屬性。

 `Cors`   <a name="sam-function-functionurlconfig-cors"></a>
函數 URL 的跨來源資源共享 (CORS) 設定。  
*類型*：[Cors](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-url-cors.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Url` 資源的 `[Cors](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-url-cors.html)` 屬性。

 `InvokeMode`  <a name="sam-function-functionurlconfig-invokemode"></a>
將叫用函數 URL 的模式。若要讓您的函數在呼叫完成後傳回回應，請將 設定為 `BUFFERED`。若要讓您的函數串流回應，請將 設定為 `RESPONSE_STREAM`。預設值為 `BUFFERED`。  
*有效值*：`BUFFERED` 或 `RESPONSE_STREAM`  
*類型：*字串  
*必要*：否  
*AWS CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Url` 資源的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-url.html#cfn-lambda-url-invokemode](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-url.html#cfn-lambda-url-invokemode) 屬性。

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

### 函數 URL
<a name="sam-property-function-functionurlconfig--examples--function-url"></a>

下列範例會使用函數 URL 建立 Lambda 函數。函數 URL 使用 IAM 授權。

#### YAML
<a name="sam-property-function-functionurlconfig--examples--function-url--yaml"></a>

```
HelloWorldFunction:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: hello_world/
    Handler: index.handler
    Runtime: nodejs20.x
    FunctionUrlConfig:
      AuthType: AWS_IAM
      InvokeMode: RESPONSE_STREAM

Outputs:
  MyFunctionUrlEndpoint:
      Description: "My Lambda Function URL Endpoint"
      Value:
        Fn::GetAtt: HelloWorldFunctionUrl.FunctionUrl
```

# CapacityProviderConfig
<a name="sam-property-function-capacityproviderconfig"></a>

設定將附加發佈版本函數的容量提供者。這可讓函數在由 Lambda 管理的客戶擁有 EC2 執行個體上執行。

**注意**  
此組態會決定函數的運算類型，且需要在第一個函數部署期間指定。在建立函數資源之後，就無法新增或移除它。

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

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

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

```
[Arn](#sam-function-capacityproviderconfig-arn): String
[ExecutionEnvironmentMemoryGiBPerVCpu](#sam-function-capacityproviderconfig-executionenvironmentmemorygibpervcpu): Float
[PerExecutionEnvironmentMaxConcurrency](#sam-function-capacityproviderconfig-perexecutionenvironmentmaxconcurrency): Integer
```

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

 `Arn`   <a name="sam-function-capacityproviderconfig-arn"></a>
用於此函數之容量提供者的 ARN。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 SAM 是唯一的。

 `ExecutionEnvironmentMemoryGiBPerVCpu`   <a name="sam-function-capacityproviderconfig-executionenvironmentmemorygibpervcpu"></a>
每個執行環境的記憶體 （以 GiB 為單位） 與 vCPU 的比率。  
每個 CPU 的記憶體比率不得超過函數的總記憶體 2048MB。支援的memory-to-CPU 比率為每個 CPU 2GB, 4GB 或 8GB。
*類型*：Float  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[ExecutionEnvironmentMemoryGiBPerVCpu](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-lambdamanagedinstancescapacityproviderconfig)` 屬性。

 `PerExecutionEnvironmentMaxConcurrency`   <a name="sam-function-capacityproviderconfig-perexecutionenvironmentmaxconcurrency"></a>
每個執行環境 （沙盒） 的並行執行數目上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[PerExecutionEnvironmentMaxConcurrency](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-lambdamanagedinstancescapacityproviderconfig)` 屬性。

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

### 容量提供者組態
<a name="sam-property-function-capacityproviderconfig-examples-basic"></a>

下列範例顯示參考容量提供者資源的容量提供者組態。

```
CapacityProviderConfig:
  Arn: !GetAtt MyCapacityProvider.Arn
  ExecutionEnvironmentMemoryGiBPerVCpu: 4.0
  PerExecutionEnvironmentMaxConcurrency: 100
```

# FunctionScalingConfig
<a name="sam-property-function-functionscalingconfig"></a>

設定 Lambda 函數版本的擴展行為，控制可建立的執行環境 （沙盒） 數量。此組態同時適用於 \$1LATEST.PUBLISHED 和數值函數版本。

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

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

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

```
[MinExecutionEnvironments](#sam-function-functionscalingconfig-minexecutionenvironments): Integer
[MaxExecutionEnvironments](#sam-function-functionscalingconfig-maxexecutionenvironments): Integer
```

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

 `MinExecutionEnvironments`   <a name="sam-function-functionscalingconfig-minexecutionenvironments"></a>
要為函數版本維護的執行環境數目下限。  
*類型*：整數  
*必要*：否  
*預設*：`3`  
*下限*：`0`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[MinExecutionEnvironments](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionscalingconfig-minexecutionenvironments)` 屬性。

 `MaxExecutionEnvironments`   <a name="sam-function-functionscalingconfig-maxexecutionenvironments"></a>
可針對函數版本建立的執行環境數目上限。  
*類型*：整數  
*必要*：否  
*預設*：`3`  
*下限*：`0`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::Function` 資源的 `[MaxExecutionEnvironments](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionscalingconfig-maxexecutionenvironments)` 屬性。

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

### 函數擴展組態
<a name="sam-property-function-functionscalingconfig-examples-basic"></a>

下列範例顯示具有最小和最大執行環境的函數擴展組態。

```
FunctionScalingConfig:
  MinExecutionEnvironments: 5
  MaxExecutionEnvironments: 100
```

# AWS::Serverless::GraphQLApi
<a name="sam-resource-graphqlapi"></a>

使用 AWS Serverless Application Model (AWS SAM) `AWS::Serverless::GraphQLApi` 資源類型為您的無伺服器應用程式建立和設定 AWS AppSync GraphQL API。

若要進一步了解 AWS AppSync，請參閱《 *AWS AppSync 開發人員指南*》中的[什麼是 AWS AppSync？](https://docs.aws.amazon.com/appsync/latest/devguide/what-is-appsync.html)。

## 語法
<a name="sam-resource-graphqlapi-syntax"></a>

### YAML
<a name="sam-resource-graphqlapi-syntax-yaml"></a>

```
LogicalId:
  Type: AWS::Serverless::GraphQLApi
  Properties:
    ApiKeys: ApiKeys
    Auth: Auth
    Cache: [AWS::AppSync::ApiCache](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apicache.html)
    DataSources: DataSource
    DomainName: [AWS::AppSync::DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-domainname.html)
    Functions: Function
    Logging: [LogConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-logconfig.html)
    Name: String
    Resolvers: Resolver
    SchemaInline: String
    SchemaUri: String
    Tags:
    - [Tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)
    XrayEnabled: Boolean
```

## Properties
<a name="sam-resource-graphqlapi-properties"></a>

`ApiKeys`  <a name="sam-graphqlapi-apikeys"></a>
建立唯一金鑰，可用於執行需要 API 金鑰GraphQL的操作。  
*類型*：[ApiKeys](sam-property-graphqlapi-apikeys.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Auth`  <a name="sam-graphqlapi-auth"></a>
設定 GraphQL API 的身分驗證。  
*類型*：[Auth](sam-property-graphqlapi-auth.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Cache`  <a name="sam-graphqlapi-cache"></a>
`CreateApiCache` 操作的輸入。  
*類型*：[AWS::AppSync::ApiCache](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apicache.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 [AWS::AppSync::ApiCache](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apicache.html) 資源。

`DataSources`  <a name="sam-graphqlapi-datasources"></a>
在 中建立 函數的資料來源 AWS AppSync 以連線至 。 AWS SAM 支援 Amazon DynamoDB 和 AWS Lambda 資料來源。  
*類型*：[DataSource](sam-property-graphqlapi-datasource.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`DomainName`  <a name="sam-graphqlapi-domainname"></a>
您 GraphQL API 的自訂網域名稱。  
*類型*：[AWS::AppSync::DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-domainname.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 [AWS::AppSync::DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-domainname.html) resource. AWS SAM automatically 產生 [AWS::AppSync::DomainNameApiAssociation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-domainnameapiassociation.html) 資源。

`Functions`  <a name="sam-graphqlapi-functions"></a>
在 GraphQL APIs中設定函數以執行特定操作。  
*類型*：[Function](sam-property-graphqlapi-function.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Logging`  <a name="sam-graphqlapi-logging"></a>
設定 GraphQL API 的 Amazon CloudWatch 記錄。  
如果您未指定此屬性， AWS SAM 將產生`CloudWatchLogsRoleArn`並設定下列值：  
+ `ExcludeVerboseContent: true`
+ `FieldLogLevel: ALL`
若要選擇退出記錄，請指定下列項目：  

```
Logging: false
```
*類型*：[LogConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-logconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[LogConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-logconfig)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-logicalid"></a>
API 的唯一名稱GraphQL。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-name)` 屬性。

`Name`  <a name="sam-graphqlapi-name"></a>
API 的名稱GraphQL。指定此屬性以覆寫`LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-name)` 屬性。

`Resolvers`  <a name="sam-graphqlapi-resolvers"></a>
為您的 GraphQL API 欄位設定解析程式。 AWS SAM 支援[JavaScript管道解析程式](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-overview-js.html#anatomy-of-a-pipeline-resolver-js)。  
*類型*：[解析程式](sam-property-graphqlapi-resolver.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`SchemaInline`  <a name="sam-graphqlapi-schemainline"></a>
格式結構GraphQL描述的文字表示SDL。  
*類型：*字串  
*必要*：有條件限制。您必須指定 `SchemaInline`或 `SchemaUri`。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLSchema` 資源的 `[Definition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlschema.html#cfn-appsync-graphqlschema-definition)` 屬性。

`SchemaUri`  <a name="sam-graphqlapi-schemauri"></a>
結構描述的 Amazon Simple Storage Service (Amazon S3) 儲存貯體 URI 或本機資料夾的路徑。  
如果您指定本機資料夾的路徑， CloudFormation 需要先將檔案上傳至 Amazon S3，才能部署。您可以使用 AWS SAM CLI來促進此程序。如需詳細資訊，請參閱[如何在部署時 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
*類型：*字串  
*必要*：有條件限制。您必須指定 `SchemaInline`或 `SchemaUri`。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLSchema` 資源的 `[DefinitionS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlschema.html#cfn-appsync-graphqlschema-definitions3location)` 屬性。

`Tags`  <a name="sam-graphqlapi-tags"></a>
此 GraphQL API 的標籤 （鍵/值對）。使用標籤來識別和分類資源。  
*類型*：[標籤](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[Tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-tags)` 屬性。

`XrayEnabled`  <a name="sam-graphqlapi-xrayenabled"></a>
指出是否要為此資源使用 [AWS X-Ray 追蹤](https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html)。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[XrayEnabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-xrayenabled)` 屬性。

## 傳回值
<a name="sam-resource-graphqlapi-return-values"></a>

如需傳回值的清單，請參閱[CloudFormation 《 使用者指南](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#aws-resource-appsync-graphqlapi-return-values.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#aws-resource-appsync-graphqlapi-return-values.html)》中的 。

## 範例
<a name="sam-resource-graphqlapi-examples"></a>

### GraphQL API 搭配 DynamoDB 資料來源
<a name="sam-resource-graphqlapi-examples-example1"></a>

在此範例中，我們會建立使用 DynamoDB 資料表做為資料來源的 GraphQL API。

**schema.graphql**

```
schema {
  query: Query
  mutation: Mutation
}

type Query {
  getPost(id: String!): Post
}

type Mutation {
  addPost(author: String!, title: String!, content: String!): Post!
}

type Post {
  id: String!
  author: String
  title: String
  content: String
  ups: Int!
  downs: Int!
  version: Int!
}
```

**template.yaml**

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  DynamoDBPostsTable:
    Type: AWS::Serverless::SimpleTable

  MyGraphQLAPI:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      SchemaUri: ./sam_graphql_api/schema.graphql
      Auth:
        Type: AWS_IAM
      DataSources:
        DynamoDb:
          PostsDataSource:
            TableName: !Ref DynamoDBPostsTable
            TableArn: !GetAtt DynamoDBPostsTable.Arn
      Functions:
        preprocessPostItem:
          Runtime:
            Name: APPSYNC_JS
            Version: 1.0.0
          DataSource: NONE
          CodeUri: ./sam_graphql_api/preprocessPostItem.js
        createPostItem:
          Runtime:
            Name: APPSYNC_JS
            Version: "1.0.0"
          DataSource: PostsDataSource
          CodeUri: ./sam_graphql_api/createPostItem.js
        getPostFromTable:
          Runtime:
            Name: APPSYNC_JS
            Version: "1.0.0"
          DataSource: PostsDataSource
          CodeUri: ./sam_graphql_api/getPostFromTable.js
      Resolvers:
        Mutation:
          addPost:
            Runtime:
              Name: APPSYNC_JS
              Version: "1.0.0"
            Pipeline:
            - preprocessPostItem
            - createPostItem
        Query:
          getPost:
            CodeUri: ./sam_graphql_api/getPost.js
            Runtime:
              Name: APPSYNC_JS
              Version: "1.0.0"
            Pipeline:
            - getPostFromTable
```

**createPostItem.js**

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  const { key, values } = ctx.prev.result;
  return {
    operation: "PutItem",
    key: util.dynamodb.toMapValues(key),
    attributeValues: util.dynamodb.toMapValues(values),
  };
}

export function response(ctx) {
  return ctx.result;
}
```

**getPostFromTable.js**

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  return dynamoDBGetItemRequest({ id: ctx.args.id });
}

export function response(ctx) {
  return ctx.result;
}

/**
 * A helper function to get a DynamoDB item
 */
function dynamoDBGetItemRequest(key) {
  return {
    operation: "GetItem",
    key: util.dynamodb.toMapValues(key),
  };
}
```

**preprocessPostItem.js**

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  const id = util.autoId();
  const { ...values } = ctx.args;
  values.ups = 1;
  values.downs = 0;
  values.version = 1;
  return { payload: { key: { id }, values: values } };
}

export function response(ctx) {
  return ctx.result;
}
```

以下是我們的解析程式程式碼：

**getPost.js**

```
export function request(ctx) {
  return {};
}

export function response(ctx) {
  return ctx.prev.result;
}
```

### GraphQL 具有 Lambda 函數做為資料來源的 API
<a name="sam-resource-graphqlapi-examples-example2"></a>

在此範例中，我們會建立使用 Lambda 函數做為資料來源的 GraphQL API。

**template.yaml**

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs20.x
      CodeUri: ./lambda

  MyGraphQLAPI:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      Name: MyApi
      SchemaUri: ./gql/schema.gql
      Auth:
        Type: API_KEY
      ApiKeys:
        MyApiKey:
          Description: my api key
      DataSources:
        Lambda:
          MyLambdaDataSource:
            FunctionArn: !GetAtt MyLambdaFunction.Arn
      Functions:
        lambdaInvoker:
          Runtime:
            Name: APPSYNC_JS
            Version: 1.0.0
          DataSource: MyLambdaDataSource
          CodeUri: ./gql/invoker.js
      Resolvers:
        Mutation:
          addPost:
            Runtime:
              Name: APPSYNC_JS
              Version: 1.0.0
            Pipeline:
            - lambdaInvoker
        Query:
          getPost:
            Runtime:
              Name: APPSYNC_JS
              Version: 1.0.0
            Pipeline:
            - lambdaInvoker

Outputs:
  MyGraphQLAPI:
    Description: AppSync API
    Value: !GetAtt MyGraphQLAPI.GraphQLUrl
  MyGraphQLAPIMyApiKey:
    Description: API Key for authentication
    Value: !GetAtt MyGraphQLAPIMyApiKey.ApiKey
```

**schema.graphql**

```
schema {
  query: Query
  mutation: Mutation
}
type Query {
  getPost(id: ID!): Post
}
type Mutation {
  addPost(id: ID!, author: String!, title: String, content: String): Post!
}
type Post {
  id: ID!
  author: String!
  title: String
  content: String
  ups: Int
  downs: Int
}
```

以下是我們的 函數：

**lambda/index.js**

```
exports.handler = async (event) => {
  console.log("Received event {}", JSON.stringify(event, 3));

  const posts = {
    1: {
      id: "1",
      title: "First book",
      author: "Author1",
      content: "Book 1 has this content",
      ups: "100",
      downs: "10",
    },
  };

  console.log("Got an Invoke Request.");
  let result;
  switch (event.field) {
    case "getPost":
      return posts[event.arguments.id];
    case "addPost":
      // return the arguments back
      return event.arguments;
    default:
      throw new Error("Unknown field, unable to resolve " + event.field);
  }
};
```

**invoker.js**

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  const { source, args } = ctx;
  return {
    operation: "Invoke",
    payload: { field: ctx.info.fieldName, arguments: args, source },
  };
}

export function response(ctx) {
  return ctx.result;
}
```

# ApiKeys
<a name="sam-property-graphqlapi-apikeys"></a>

建立唯一金鑰，可用於執行需要 API 金鑰GraphQL的操作。

## 語法
<a name="sam-property-graphqlapi-apikeys-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-apikeys-syntax-yaml"></a>

```
LogicalId:
  ApiKeyId: String
  Description: String
  ExpiresOn: Double
```

## Properties
<a name="sam-property-graphqlapi-apikeys-properties"></a>

`ApiKeyId`  <a name="sam-graphqlapi-apikeys-apikeyid"></a>
API 金鑰的唯一名稱。指定 以覆寫 `LogicalId`值。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::ApiKey` 資源的 `[ApiKeyId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apikey.html#cfn-appsync-apikey-apikeyid)` 屬性。

`Description`  <a name="sam-graphqlapi-apikeys-description"></a>
描述您的 API 金鑰。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::ApiKey` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apikey.html#cfn-appsync-apikey-description)` 屬性。

`ExpiresOn`  <a name="sam-graphqlapi-apikeys-expireson"></a>
API 金鑰的到期時間。日期以自 epoch 以來的秒數表示，四捨五入至最接近的整點。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::ApiKey` 資源的 `[Expires](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apikey.html#cfn-appsync-apikey-expires)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-apikeys-logicalid"></a>
API 金鑰的唯一名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::ApiKey` 資源的 `[ApiKeyId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-apikey.html#cfn-appsync-apikey-apikeyid)` 屬性。

# Auth
<a name="sam-property-graphqlapi-auth"></a>

設定 GraphQL API 的授權。

## 語法
<a name="sam-property-graphqlapi-auth-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-auth-syntax-yaml"></a>

```
Additional:
- AuthProvider
LambdaAuthorizer: [LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html)
OpenIDConnect: [OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-openidconnectconfig.html)
Type: String
UserPool: [UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-userpoolconfig.html)
```

## Properties
<a name="sam-property-graphqlapi-auth-properties"></a>

`Additional`  <a name="sam-graphqlapi-auth-additional"></a>
API 的其他授權類型清單GraphQL。  
*類型*：[AuthProvider ](sam-property-graphqlapi-auth-authprovider.md)的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

`LambdaAuthorizer`  <a name="sam-graphqlapi-auth-lambdaauthorizer"></a>
為您的 Lambda 函數授權方指定選用的授權組態。當 指定`Type`為 時，您可以設定此選用屬性`AWS_LAMBDA`。  
*類型*：[LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-lambdaauthorizerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[ LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html)` 屬性。

`OpenIDConnect`  <a name="sam-graphqlapi-auth-openidconnect"></a>
為您的OpenID Connect合規服務指定選用的授權組態。當 `Type` 指定為 時，您可以設定此選用屬性`OPENID_CONNECT`。  
*類型*：[OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-openidconnectconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[ OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-openidconnectconfig.html)` 屬性。

`Type`  <a name="sam-graphqlapi-auth-type"></a>
應用程式和 API AWS AppSync GraphQL 之間的預設授權類型。  
如需允許值的清單和說明，請參閱《 *AWS AppSync 開發人員指南*》中的[授權和身分驗證](https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html)。  
當您指定 Lambda 授權方 (`AWS_LAMBDA`) 時， 會 AWS SAM 建立 AWS Identity and Access Management (IAM) 政策，以在 GraphQL API 和 Lambda 函數之間佈建許可。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[AuthenticationType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-authenticationtype)` 屬性。

`UserPool`  <a name="sam-graphqlapi-auth-userpool"></a>
指定使用 Amazon Cognito 使用者集區的選用授權組態。當 `Type` 指定為 時，您可以設定此選用屬性`AMAZON_COGNITO_USER_POOLS`。  
*類型*：[UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-userpoolconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::GraphQLApi` 資源的 `[ UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-userpoolconfig.html)` 屬性。

## 範例
<a name="sam-property-graphqlapi-auth-examples"></a>

### 設定預設和其他授權類型
<a name="sam-property-graphqlapi-auth-examples-example1"></a>

在此範例中，我們從將 Lambda 授權方設定為 GraphQL API 的預設授權類型開始。

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyGraphQLAPI:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      Auth:
        Type: AWS_LAMBDA
        LambdaAuthorizer:
          AuthorizerUri: !GetAtt Authorizer1.Arn
          AuthorizerResultTtlInSeconds: 10
          IdentityValidationExpression: hello
```

接下來，我們將以下內容新增至 AWS SAM 範本，為 GraphQL API 設定其他授權類型：

```
        Additional:
        - Type: AWS_IAM
        - Type: API_KEY
        - Type: OPENID_CONNECT
          OpenIDConnect:
            AuthTTL: 10
            ClientId: myId
            IatTTL: 10
            Issuer: prod
```

這會產生下列 AWS SAM 範本：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyGraphQLAPI:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      Auth:
        Type: AWS_LAMBDA
        LambdaAuthorizer:
          AuthorizerUri: !GetAtt Authorizer1.Arn
          AuthorizerResultTtlInSeconds: 10
          IdentityValidationExpression: hello
        Additional:
        - Type: AWS_IAM
        - Type: API_KEY
        - Type: OPENID_CONNECT
          OpenIDConnect:
            AuthTTL: 10
            ClientId: myId
            IatTTL: 10
            Issuer: prod
```

# AuthProvider
<a name="sam-property-graphqlapi-auth-authprovider"></a>

其他 GraphQL API 授權類型的選用授權組態。

## 語法
<a name="sam-property-graphqlapi-auth-authprovider-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-auth-authprovider-syntax-yaml"></a>

```
LambdaAuthorizer: [LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html)
OpenIDConnect: [OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-openidconnectconfig.html)
Type: String
UserPool: [UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-userpoolconfig.html)
```

## Properties
<a name="sam-property-graphqlapi-auth-authprovider-properties"></a>

`LambdaAuthorizer`  <a name="sam-graphqlapi-auth-authprovider-lambdaauthorizer"></a>
為您的 AWS Lambda 函數授權方指定選用的授權組態。當 `Type` 指定為 時，您可以設定此選用屬性`AWS_LAMBDA`。  
*類型*：[LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-lambdaauthorizerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::GraphQLApi``[ AdditionalAuthenticationProvider](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html)`物件的 `[ LambdaAuthorizerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html)` 屬性。

`OpenIDConnect`  <a name="sam-graphqlapi-auth-authprovider-openidconnect"></a>
為您的OpenID Connect合規服務指定選用的授權組態。當 `Type` 指定為 時，您可以設定此選用屬性`OPENID_CONNECT`。  
*類型*：[OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-openidconnectconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::GraphQLApi``[ AdditionalAuthenticationProvider](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html)`物件的 `[ OpenIDConnectConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-openidconnectconfig.html)` 屬性。

`Type`  <a name="sam-graphqlapi-auth-authprovider-type"></a>
應用程式和 API AWS AppSync GraphQL 之間的預設授權類型。  
如需允許值的清單和說明，請參閱《 *AWS AppSync 開發人員指南*》中的[授權和身分驗證](https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html)。  
當您指定 Lambda 授權方 (`AWS_LAMBDA`) 時， 會 AWS SAM 建立 AWS Identity and Access Management (IAM) 政策，以在 GraphQL API 和 Lambda 函數之間佈建許可。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::GraphQLApi``[ AdditionalAuthenticationProvider](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html)`物件的 `[ AuthenticationType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html#cfn-appsync-graphqlapi-additionalauthenticationprovider-authenticationtype)` 屬性。

`UserPool`  <a name="sam-graphqlapi-auth-authprovider-userpool"></a>
指定使用 Amazon Cognito 使用者集區的選用授權組態。當 `Type` 指定為 時，您可以設定此選用屬性`AMAZON_COGNITO_USER_POOLS`。  
*類型*：[UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-userpoolconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::GraphQLApi``[ AdditionalAuthenticationProvider](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html)`物件的 `[ UserPoolConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-userpoolconfig.html)` 屬性。

# 資料來源
<a name="sam-property-graphqlapi-datasource"></a>

設定 GraphQL API 解析程式可連線的資料來源。您可以使用 AWS Serverless Application Model (AWS SAM) 範本來設定與下列資料來源的連線：
+ Amazon DynamoDB
+ AWS Lambda

若要進一步了解資料來源，請參閱《 *AWS AppSync 開發人員指南*》中的[連接資料來源](https://docs.aws.amazon.com/appsync/latest/devguide/attaching-a-data-source.html)。

## 語法
<a name="sam-property-graphqlapi-datasource-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-datasource-syntax-yaml"></a>

```
DynamoDb: DynamoDb
Lambda: Lambda
```

## Properties
<a name="sam-property-graphqlapi-datasource-properties"></a>

`DynamoDb`  <a name="sam-graphqlapi-datasource-dynamodb"></a>
將 DynamoDB 資料表設定為 GraphQL API 解析程式的資料來源。  
*類型*：[DynamoDb](sam-property-graphqlapi-datasource-dynamodb.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Lambda`  <a name="sam-graphqlapi-datasource-lambda"></a>
將 Lambda 函數設定為 GraphQL API 解析程式的資料來源。  
*類型*：[Lambda](sam-property-graphqlapi-datasource-lambda.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

# DynamoDb
<a name="sam-property-graphqlapi-datasource-dynamodb"></a>

將 Amazon DynamoDB 資料表設定為 GraphQL API 解析程式的資料來源。

## 語法
<a name="sam-property-graphqlapi-datasource-dynamodb-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-datasource-dynamodb-syntax-yaml"></a>

```
LogicalId:
  DeltaSync: [DeltaSyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-deltasyncconfig.html)
  Description: String
  Name: String
  Permissions: List
  Region: String
  ServiceRoleArn: String
  TableArn: String
  TableName: String
  UseCallerCredentials: Boolean
  Versioned: Boolean
```

## Properties
<a name="sam-property-graphqlapi-datasource-dynamodb-properties"></a>

`DeltaSync`  <a name="sam-graphqlapi-datasource-dynamodb-deltasync"></a>
描述差異同步組態。  
*類型*：[DeltaSyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-deltasyncconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource DynamoDBConfig` 物件的 `[DeltaSyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-dynamodbconfig.html#cfn-appsync-datasource-dynamodbconfig-deltasyncconfig)` 屬性。

`Description`  <a name="sam-graphqlapi-datasource-dynamodb-description"></a>
資料來源的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-description)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-datasource-dynamodb-logicalid"></a>
資料來源的唯一名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-name)` 屬性。

`Name`  <a name="sam-graphqlapi-datasource-dynamodb-name"></a>
資料來源的名稱。指定此屬性以覆寫`LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-name)` 屬性。

`Permissions`  <a name="sam-graphqlapi-datasource-dynamodb-permissions"></a>
使用 佈建資料來源的許可[AWS SAM 連接器](managing-permissions-connectors.md)。您可以在清單中提供下列任何值：  
+ `Read` – 允許解析程式讀取資料來源。
+ `Write` – 允許解析程式寫入資料來源。
AWS SAM 使用在部署時轉換`AWS::Serverless::Connector`的資源來佈建您的許可。若要了解產生的資源，請參閱 [CloudFormation 當您指定 時產生的資源 AWS::Serverless::Connector](sam-specification-generated-resources-connector.md)。  
您可以指定 `Permissions` 或 `ServiceRoleArn`，但不能同時指定兩者。如果兩者皆未指定， AWS SAM 將產生預設值 `Read`和 `Write`。若要撤銷對資料來源的存取，請從 AWS SAM 範本中移除 DynamoDB 物件。
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。它類似於 `AWS::Serverless::Connector` 資源的 `Permissions` 屬性。

`Region`  <a name="sam-graphqlapi-datasource-dynamodb-region"></a>
DynamoDB 資料表 AWS 區域 的 。如果您未指定， AWS SAM 請使用 `[AWS::Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-region)`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource DynamoDBConfig` 物件的 `[AwsRegion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-dynamodbconfig.html#cfn-appsync-datasource-dynamodbconfig-awsregion)` 屬性。

`ServiceRoleArn`  <a name="sam-graphqlapi-datasource-dynamodb-servicerolearn"></a>
資料來源的 AWS Identity and Access Management (IAM) 服務角色 ARN。系統會在存取資料來源時取得此角色。  
您可以指定 `Permissions` 或 `ServiceRoleArn`，但不能同時指定兩者。  
*類型：*字串  
*必要*：否。如果未指定，則 AWS SAM 套用 的預設值`Permissions`。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[ServiceRoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-servicerolearn)` 屬性。

`TableArn`  <a name="sam-graphqlapi-datasource-dynamodb-tablearn"></a>
DynamoDB 資料表的 ARN。  
*類型：*字串  
*必要*：有條件限制。如果您未指定 `ServiceRoleArn`，`TableArn`則需要 。  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`TableName`  <a name="sam-graphqlapi-datasource-dynamodb-tablename"></a>
資料表名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::DataSource DynamoDBConfig`物件的 `[TableName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-dynamodbconfig.html#cfn-appsync-datasource-dynamodbconfig-tablename)` 屬性。

`UseCallerCredentials`  <a name="sam-graphqlapi-datasource-dynamodb-usecallercredentials"></a>
設定為 `true`以搭配此資料來源使用 IAM。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::DataSource DynamoDBConfig`物件的 `[UseCallerCredentials](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-dynamodbconfig.html#cfn-appsync-datasource-dynamodbconfig-usecallercredentials)` 屬性。

`Versioned`  <a name="sam-graphqlapi-datasource-dynamodb-versioned"></a>
設定為 `true` 以使用此資料來源來使用[衝突偵測、衝突解決和同步](https://docs.aws.amazon.com/appsync/latest/devguide/conflict-detection-and-sync.html)。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::DataSource DynamoDBConfig`物件的 `[Versioned](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-dynamodbconfig.html#cfn-appsync-datasource-dynamodbconfig-versioned)` 屬性。

# Lambda
<a name="sam-property-graphqlapi-datasource-lambda"></a>

將 AWS Lambda 函數設定為 GraphQL API 解析程式的資料來源。

## 語法
<a name="sam-property-graphqlapi-datasource-lambda-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-datasource-lambda-syntax-yaml"></a>

```
LogicalId:
  Description: String
  FunctionArn: String
  Name: String
  ServiceRoleArn: String
```

## Properties
<a name="sam-property-graphqlapi-datasource-lambda-properties"></a>

`Description`  <a name="sam-graphqlapi-datasource-lambda-description"></a>
資料來源的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-description)` 屬性。

`FunctionArn`  <a name="sam-graphqlapi-datasource-lambda-functionarn"></a>
Lambda 函數的 ARN。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::DataSource LambdaConfig`物件的 `[LambdaFunctionArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-lambdaconfig.html#cfn-appsync-datasource-lambdaconfig-lambdafunctionarn)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-datasource-lambda-logicalid"></a>
資料來源的唯一名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-name)` 屬性。

`Name`  <a name="sam-graphqlapi-datasource-lambda-name"></a>
資料來源的名稱。指定此屬性以覆寫`LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-name)` 屬性。

`ServiceRoleArn`  <a name="sam-graphqlapi-datasource-lambda-servicerolearn"></a>
資料來源的 AWS Identity and Access Management (IAM) 服務角色 ARN。系統會在存取資料來源時取得此角色。  
若要撤銷對資料來源的存取，請從 AWS SAM 範本中移除 Lambda 物件。
*類型：*字串  
*必要*：否。如果未指定， AWS SAM 將使用 佈建`Write`許可[AWS SAM 連接器](managing-permissions-connectors.md)。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::DataSource` 資源的 `[ServiceRoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-servicerolearn)` 屬性。

# 函式
<a name="sam-property-graphqlapi-function"></a>

在 GraphQL APIs中設定函數以執行特定操作。

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

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

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

```
LogicalId:
  CodeUri: String
  DataSource: String
  Description: String
  Id: String
  InlineCode: String
  MaxBatchSize: Integer
  Name: String
  Runtime: Runtime
  Sync: [SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-syncconfig.html)
```

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

`CodeUri`  <a name="sam-graphqlapi-function-codeuri"></a>
函數程式碼的 Amazon Simple Storage Service (Amazon S3) URI 或本機資料夾的路徑。  
如果您指定本機資料夾的路徑， CloudFormation 需要先將檔案上傳至 Amazon S3，才能部署。您可以使用 AWS SAM CLI來促進此程序。如需詳細資訊，請參閱[如何在部署時 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[CodeS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-codes3location)` 屬性。

`DataSource`  <a name="sam-graphqlapi-function-datasource"></a>
此函數將連接的資料來源名稱。  
+ 若要參考`AWS::Serverless::GraphQLApi`資源中的資料來源，請指定其邏輯 ID。
+ 若要參考`AWS::Serverless::GraphQLApi`資源外部的資料來源，請使用 `Fn::GetAtt` 內部函數提供其`Name`屬性。例如 `!GetAtt MyLambdaDataSource.Name`。
+ 若要參考來自不同堆疊的資料來源，請使用 `[Fn::ImportValue](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)`。
如果指定 的變化， `[NONE | None | none]` AWS SAM 將產生 `AWS::AppSync::DataSource` `[Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-type)` 物件`None`的值。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[DataSourceName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-datasourcename)` 屬性。

`Description`  <a name="sam-graphqlapi-function-description"></a>
函數的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-description)` 屬性。

`Id`  <a name="sam-graphqlapi-function-id"></a>
位於`AWS::Serverless::GraphQLApi`資源外部之函數的函數 ID。  
+ 若要在相同 AWS SAM 範本中參考函數，請使用 `Fn::GetAtt` 內部函數。例如 `Id: !GetAtt createPostItemFunc.FunctionId`。
+ 若要參考來自不同堆疊的函數，請使用 `[Fn::ImportValue](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)`。
使用 時`Id`，不允許所有其他屬性。 AWS SAM 會自動傳遞參考函數的函數 ID。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`InlineCode`  <a name="sam-graphqlapi-function-inlinecode"></a>
包含請求和回應函數的函數程式碼。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-code)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-function-logicalid"></a>
函數的唯一名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name)` 屬性。

`MaxBatchSize`  <a name="sam-graphqlapi-function-maxbatchsize"></a>
解析程式請求輸入的數量上限，輸入將傳送到 `BatchInvoke` 操作中的單一 AWS Lambda 函數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 [MaxBatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-maxbatchsize) 屬性。

`Name`  <a name="sam-graphqlapi-function-name"></a>
函數的名稱。指定 以覆寫 `LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name)` 屬性。

`Runtime`  <a name="sam-graphqlapi-function-runtime"></a>
描述 AWS AppSync 管道解析程式或 AWS AppSync 函數使用的執行時間。指定要使用的執行階段名稱和版本。  
*類型*：[執行期](sam-property-graphqlapi-function-runtime.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。它類似於 `AWS::AppSync::FunctionConfiguration` 資源的 `[Runtime](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-runtime)` 屬性。

`Sync`  <a name="sam-graphqlapi-function-sync"></a>
描述函數的 Sync 組態。  
指定叫用函數時要使用的衝突偵測策略和解決策略。  
*類型*：[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-syncconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-syncconfig)` 屬性。

# 執行時期
<a name="sam-property-graphqlapi-function-runtime"></a>

管道解析程式或函數的執行時間。指定要使用的名稱和版本。

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

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

### YAML
<a name="sam-property-graphqlapi-function-runtime-syntax-yaml"></a>

```
Name: String
Version: String
```

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

`Name`  <a name="sam-graphqlapi-function-runtime-name"></a>
要使用的執行時間名稱。目前，唯一允許的值為 `APPSYNC_JS`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::FunctionConfiguration AppSyncRuntime`物件的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-appsyncruntime.html#cfn-appsync-functionconfiguration-appsyncruntime-name)` 屬性。

`Version`  <a name="sam-graphqlapi-function-runtime-version"></a>
要使用的執行時間版本。目前唯一允許的版本為 `1.0.0`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::FunctionConfiguration AppSyncRuntime`物件的 `[RuntimeVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-appsyncruntime.html#cfn-appsync-functionconfiguration-appsyncruntime-runtimeversion)` 屬性。

# 解析程式
<a name="sam-property-graphqlapi-resolver"></a>

針對 GraphQL API 的欄位設定解析程式。 AWS Serverless Application Model (AWS SAM) 支援 [JavaScript 管道解析程式](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-overview-js.html)。

## 語法
<a name="sam-property-graphqlapi-resolver-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-resolver-syntax-yaml"></a>

```
OperationType:
  LogicalId:
    Caching: [CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-cachingconfig.html)
    CodeUri: String
    FieldName: String
    InlineCode: String 
    MaxBatchSize: Integer
    Pipeline: List
    Runtime: Runtime
    Sync: [SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-syncconfig.html)
```

## Properties
<a name="sam-property-graphqlapi-resolver-properties"></a>

`Caching`  <a name="sam-graphqlapi-resolver-caching"></a>
已啟用快取之解析程式的快取組態。  
*類型*：[CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-cachingconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-cachingconfig)` 屬性。

`CodeUri`  <a name="sam-graphqlapi-resolver-codeuri"></a>
解析程式函數程式碼的 Amazon Simple Storage Service (Amazon S3) URI 或本機資料夾的路徑。  
如果您指定本機資料夾的路徑， CloudFormation 需要先將檔案上傳到 Amazon S3，才能部署。您可以使用 AWS SAM CLI來促進此程序。如需詳細資訊，請參閱[如何在部署時 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
如果未提供 `CodeUri`或 `InlineCode` ， AWS SAM 會產生 `InlineCode`，將請求重新導向至第一個管道函數，並接收來自最後一個管道函數的回應。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[CodeS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-codes3location)` 屬性。

`FieldName`  <a name="sam-graphqlapi-resolver-fieldname"></a>
解析程式的名稱。指定此屬性以覆寫`LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[FieldName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-fieldname)` 屬性。

`InlineCode`  <a name="sam-graphqlapi-resolver-inlinecode"></a>
包含請求和回應函數的解析程式程式碼。  
如果未提供 `CodeUri`或 `InlineCode` ， AWS SAM 會產生 `InlineCode`，將請求重新導向至第一個管道函數，並接收來自最後一個管道函數的回應。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-code)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-resolver-logicalid"></a>
解析程式的唯一名稱。在GraphQL結構描述中，您的解析程式名稱應該與其所使用的欄位名稱相符。針對 使用相同的欄位名稱`LogicalId`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`MaxBatchSize`  <a name="sam-graphqlapi-resolver-maxbatchsize"></a>
解析程式請求輸入的數量上限，輸入將傳送到 `BatchInvoke` 操作中的單一 AWS Lambda 函數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[MaxBatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-maxbatchsize)` 屬性。

`OperationType`  <a name="sam-graphqlapi-resolver-operationtype"></a>
與您的解析程式相關聯的GraphQL操作類型。例如，`Query`、`Mutation` 或 `Subscription`。您可以在單一 `LogicalId`中透過 巢狀化多個解析程式`OperationType`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[TypeName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-typename)` 屬性。

`Pipeline`  <a name="sam-graphqlapi-resolver-pipeline"></a>
與解析程式連結的函數。依清單中的邏輯 ID 指定函數。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。它類似於 `AWS::AppSync::Resolver` 資源的 `[PipelineConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-pipelineconfig)` 屬性。

`Runtime`  <a name="sam-graphqlapi-resolver-runtime"></a>
管道解析程式或函數的執行時間。指定要使用的名稱和版本。  
*類型*：[執行時間](sam-property-graphqlapi-resolver-runtime.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。它類似於 `AWS::AppSync::Resolver` 資源的 `[Runtime](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-runtime)` 屬性。

`Sync`  <a name="sam-graphqlapi-resolver-sync"></a>
描述解析程式的同步組態。  
指定叫用解析程式時，要使用的衝突偵測策略和解決方案策略。  
*類型*：[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-syncconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::Resolver` 資源的 `[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-syncconfig)` 屬性。

## 範例
<a name="sam-property-graphqlapi-resolver-examples"></a>

### 使用 AWS SAM 產生的解析程式函數程式碼，並將欄位儲存為變數
<a name="sam-property-graphqlapi-resolver-examples-example1"></a>

以下是我們範例的GraphQL結構描述：

```
schema {
  query: Query
  mutation: Mutation
}

type Query {
  getPost(id: ID!): Post
}

type Mutation {
  addPost(author: String!, title: String!, content: String!): Post!
}

type Post {
  id: ID!
  author: String
  title: String
  content: String
}
```

以下是我們 AWS SAM 範本的程式碼片段：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyGraphQLApi:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      ...
      Functions:
        preprocessPostItem:
          ...
        createPostItem:
          ...
      Resolvers:
        Mutation:
          addPost:
            Runtime:
              Name: APPSYNC_JS
              Version: 1.0.0
            Pipeline:
            - preprocessPostItem
            - createPostItem
```

在我們的 AWS SAM 範本中，我們不會指定 `CodeUri`或 `InlineCode`。在部署時， AWS SAM 會自動為解析程式產生下列內嵌程式碼：

```
export function request(ctx) {
  return {};
}

export function response(ctx) {
  return ctx.prev.result;
}
```

此預設解析程式程式碼會將請求重新導向至第一個管道函數，並接收來自最後一個管道函數的回應。

在第一個管道函數中，我們可以使用提供的`args`欄位來剖析請求物件並建立變數。然後，我們可以在函數中使用這些變數。以下是我們的 `preprocessPostItem` 函數範例：

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  const author = ctx.args.author;
  const title = ctx.args.title;
  const content = ctx.args.content;
  
  // Use variables to process data
  
}

export function response(ctx) {
  return ctx.result;
}
```

# 執行時期
<a name="sam-property-graphqlapi-resolver-runtime"></a>

管道解析程式或函數的執行時間。指定要使用的名稱和版本。

## 語法
<a name="sam-property-graphqlapi-resolver-runtime-syntax"></a>

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

### YAML
<a name="sam-property-graphqlapi-resolver-runtime-syntax-yaml"></a>

```
Name: String
Version: String
```

## Properties
<a name="sam-property-graphqlapi-resolver-runtime-properties"></a>

`Name`  <a name="sam-graphqlapi-resolver-runtime-name"></a>
要使用的執行時間名稱。目前，唯一允許的值為 `APPSYNC_JS`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::Resolver AppSyncRuntime`物件的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-appsyncruntime.html#cfn-appsync-resolver-appsyncruntime-name)` 屬性。

`Version`  <a name="sam-graphqlapi-resolver-runtime-version"></a>
要使用的執行時間版本。目前唯一允許的版本為 `1.0.0`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::Resolver AppSyncRuntime`物件的 `[RuntimeVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-appsyncruntime.html#cfn-appsync-resolver-appsyncruntime-runtimeversion)` 屬性。

# AWS::Serverless::HttpApi
<a name="sam-resource-httpapi"></a>

建立 Amazon API Gateway HTTP API，這可讓您建立比 REST API 更低延遲和成本的 RESTful APIs。 APIs 如需詳細資訊，請參閱[APIs開發人員指南》中的使用 HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) *API*。

我們建議您使用 CloudFormation 勾點或 IAM 政策來驗證 API Gateway 資源是否已連接授權方，以控制對它們的存取。

如需使用 CloudFormation 勾點的詳細資訊，請參閱 *CloudFormation CLI 使用者指南*中的[註冊勾點](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/registering-hook-python.html)和 [apigw-enforce-authorizer](https://github.com/aws-cloudformation/aws-cloudformation-samples/tree/main/hooks/python-hooks/apigw-enforce-authorizer/) GitHub 儲存庫。

如需使用 IAM 政策的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的要求 API 路由具有授權](https://docs.aws.amazon.com/apigateway/latest/developerguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-require-authorization)。 **

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-httpapi-syntax"></a>

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

### YAML
<a name="sam-resource-httpapi-syntax.yaml"></a>

```
Type: AWS::Serverless::HttpApi
Properties:
  [AccessLogSettings](#sam-httpapi-accesslogsettings): [AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)
  [Auth](#sam-httpapi-auth): HttpApiAuth
  [CorsConfiguration](#sam-httpapi-corsconfiguration): String | HttpApiCorsConfiguration
  [DefaultRouteSettings](#sam-httpapi-defaultroutesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [DefinitionBody](#sam-httpapi-definitionbody): JSON
  [DefinitionUri](#sam-httpapi-definitionuri): String | HttpApiDefinition
  [Description](#sam-httpapi-description): String
  [DisableExecuteApiEndpoint](#sam-httpapi-disableexecuteapiendpoint): Boolean
  [Domain](#sam-httpapi-domain): HttpApiDomainConfiguration
  [FailOnWarnings](#sam-httpapi-failonwarnings): Boolean
  Name: String
  PropagateTags: Boolean
  [RouteSettings](#sam-httpapi-routesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [StageName](#sam-httpapi-stagename): String
  [StageVariables](#sam-httpapi-stagevariables): [Json](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)
  [Tags](#sam-httpapi-tags): Map
```

## Properties
<a name="sam-resource-httpapi-properties"></a>

 `AccessLogSettings`   <a name="sam-httpapi-accesslogsettings"></a>
階段中存取記錄的設定。  
*類型*：[AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[AccessLogSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings)` 屬性。

 `Auth`   <a name="sam-httpapi-auth"></a>
設定控制 API Gateway HTTP API 存取的授權。  
如需詳細資訊，請參閱《*API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
*類型*：[HttpApiAuth](sam-property-httpapi-httpapiauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `CorsConfiguration`   <a name="sam-httpapi-corsconfiguration"></a>
管理所有 API Gateway HTTP APIs 的跨來源資源共用 (CORS)。指定要允許做為字串的網域，或指定`HttpApiCorsConfiguration`物件。請注意，CORS 需要 AWS SAM 修改您的 OpenAPI 定義，因此 CORS 只有在指定 `DefinitionBody` 屬性時才有效。  
如需詳細資訊，請參閱[《 API Gateway 開發人員指南》中的設定 HTTP API 的 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。 **  
如果 `CorsConfiguration` 在 OpenAPI 定義和屬性層級同時設定 ，則 AWS SAM 會合併兩個組態來源，屬性優先。如果此屬性設定為 `true`，則允許所有原始伺服器。
*類型*：字串 \$1 [HttpApiCorsConfiguration](sam-property-httpapi-httpapicorsconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `DefaultRouteSettings`   <a name="sam-httpapi-defaultroutesettings"></a>
此 HTTP API 的預設路由設定。除非由特定路由的 `RouteSettings` 屬性覆寫，否則這些設定適用於所有路由。  
*類型*：[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)` 屬性。

 `DefinitionBody`   <a name="sam-httpapi-definitionbody"></a>
描述 HTTP API 的 OpenAPI 定義。如果您未指定 `DefinitionUri`或 `DefinitionBody`， 會根據範本組態`DefinitionBody`為您 AWS SAM 產生 。  
*類型*：JSON  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGatewayV2::Api` 資源的 `[Body](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-body)` 屬性。如果提供特定屬性， AWS SAM 您可以在傳遞至 `DefinitionBody`之前，將內容插入或修改 CloudFormation。對應`AWS::Serverless::Function`資源`EventSource`的屬性包括 `Auth`和 HttpApi 類型的 。

 `DefinitionUri`   <a name="sam-httpapi-definitionuri"></a>
定義 HTTP API 之 OpenAPI 定義的 Amazon Simple Storage Service (Amazon S3) URI、本機檔案路徑或位置物件。此屬性參考的 Amazon S3 物件必須是有效的 OpenAPI 定義檔案。如果您未指定 `DefinitionUri`或`DefinitionBody`已指定 ， 會根據範本組態`DefinitionBody`為您 AWS SAM 產生 。  
如果您提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換定義。  
您使用 參考的外部 OpenApi 定義檔案中不支援內部函數`DefinitionUri`。若要將 OpenApi 定義匯入範本，請使用 `DefinitionBody` 屬性搭配[包含轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/create-reusable-transform-function-snippets-and-add-to-your-template-with-aws-include-transform.html)。  
*類型*：字串 \$1 [HttpApiDefinition](sam-property-httpapi-httpapidefinition.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGatewayV2::Api` 資源的 `[BodyS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-bodys3location)` 屬性。巢狀 Amazon S3 屬性的名稱不同。

 `Description`   <a name="sam-httpapi-description"></a>
HTTP API 資源的描述。  
當您指定 時`Description`， AWS SAM 將透過設定 `description` 欄位來修改 HTTP API 資源的 OpenApi 定義。下列案例將導致錯誤：  
+ `DefinitionBody` 屬性是在開啟 API 定義中以 `description` 欄位集指定 – 這會導致 AWS SAM 無法解析`description`的欄位衝突。
+ 屬性`DefinitionUri`已指定 – AWS SAM 不會修改從 Amazon S3 擷取的 Open API 定義。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `DisableExecuteApiEndpoint`   <a name="sam-httpapi-disableexecuteapiendpoint"></a>
指定用戶端是否可以使用預設`execute-api`端點 叫用 HTTP API`https://{api_id}.execute-api.{region}.amazonaws.com`。根據預設，用戶端可以使用預設 端點叫用您的 API。若要要求用戶端僅使用自訂網域名稱來叫用 API，請停用預設端點。  
若要使用此屬性，您必須指定 `DefinitionBody` 屬性而非 `DefinitionUri` 屬性，或在 OpenAPI 定義`x-amazon-apigateway-endpoint-configuration``disableExecuteApiEndpoint`中使用 定義。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGatewayV2::Api` 資源的 `[ DisableExecuteApiEndpoint](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-disableexecuteapiendpoint)` 屬性。它會直接傳遞至 `[ x-amazon-apigateway-endpoint-configuration](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html)`延伸模組的 `disableExecuteApiEndpoint` 屬性，該延伸模組會新增至 `AWS::ApiGatewayV2::Api` 資源的 ` [ Body](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-body)` 屬性。

 `Domain`   <a name="sam-httpapi-domain"></a>
設定此 API Gateway HTTP API 的自訂網域。  
*類型*：[HttpApiDomainConfiguration](sam-property-httpapi-httpapidomainconfiguration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FailOnWarnings`   <a name="sam-httpapi-failonwarnings"></a>
指定在遇到警告時是否要轉返 HTTP API 建立 (`true`) 與否 (`false`)。預設值為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Api` 資源的 `[FailOnWarnings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-failonwarnings)` 屬性。

`Name`  <a name="sam-httpapi-name"></a>
HTTP API 資源的名稱。  
當您指定 時`Name`， AWS SAM 將透過設定 `title` 欄位來修改 HTTP API 資源的 OpenAPI 定義。下列案例將導致錯誤：  
+ `DefinitionBody` 屬性是在開啟 API 定義中以 `title` 欄位集指定 – 這會導致 AWS SAM 無法解析`title`的欄位衝突。
+ 屬性`DefinitionUri`已指定 – AWS SAM 不會修改從 Amazon S3 擷取的 Open API 定義。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

`PropagateTags`  <a name="sam-httpapi-propagatetags"></a>
指出是否要將標籤從 `Tags` 屬性傳遞至您[AWS::Serverless::HttpApi](sam-specification-generated-resources-httpapi.md)產生的資源。指定 `True` 在產生的資源中傳播標籤。  
*類型*：布林值  
*必要*：否  
*預設*：`False`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RouteSettings`   <a name="sam-httpapi-routesettings"></a>
此 HTTP API 每個路由的路由設定。如需詳細資訊，請參閱[APIs》中的使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)。 **  
*類型*：[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)` 屬性。

 `StageName`   <a name="sam-httpapi-stagename"></a>
API 階段的名稱。如果未指定名稱， AWS SAM 會使用來自 API Gateway 的 `$default`階段。  
*類型：*字串  
*必要*：否  
*預設*：\$1default  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[StageName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagename)` 屬性。

 `StageVariables`   <a name="sam-httpapi-stagevariables"></a>
定義階段變數的映射。變數名稱可以包含英數字元和底線字元。這些值必須符合 【A-Za-z0-9-.\$1\$1：/？\$1&=，】＋。  
*類型*：[Json](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[StageVariables](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables)` 屬性。

 `Tags`   <a name="sam-httpapi-tags"></a>
映射 （字串到字串），指定要新增至此 API Gateway 階段的標籤。金鑰長度可以是 1 到 128 個 Unicode 字元，且不能包含字首 `aws:`。您可以使用以下任何字元：Unicode 字母、數字、空格、`_`、`.`、`/`、`=`、`+` 和 `-` 的組合。值長度可以是 1 到 256 個 Unicode 字元。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*其他備註*： `Tags` 屬性需要 AWS SAM 修改您的 OpenAPI 定義，因此只有在指定 `DefinitionBody` 屬性時才會新增標籤 - 如果指定 `DefinitionUri` 屬性，則不會新增標籤。 AWS SAM 自動新增`httpapi:createdBy:SAM`標籤。標籤也會新增至`AWS::ApiGatewayV2::Stage`資源和資源 `AWS::ApiGatewayV2::DomainName`（如果`DomainName`已指定）。

## 傳回值
<a name="sam-resource-httpapi-return-values"></a>

### Ref
<a name="sam-resource-httpapi-return-values-ref"></a>

當您將此資源的邏輯 ID 傳遞至內部 `Ref`函數時， 便會`Ref`傳回基礎`AWS::ApiGatewayV2::Api`資源的 API ID，例如 `a1bcdef2gh`。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

## 範例
<a name="sam-resource-httpapi--examples"></a>

### 簡單 HttpApi
<a name="sam-resource-httpapi--examples--simple-httpapi"></a>

下列範例顯示設定由 Lambda 函數支援的 HTTP API 端點所需的最低需求。此範例使用 AWS SAM 建立的預設 HTTP API。

#### YAML
<a name="sam-resource-httpapi--examples--simple-httpapi--yaml"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS SAM template with a simple API definition
Resources:
  ApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: HttpApi
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
            return {'body': 'Hello World!', 'statusCode': 200}
      Runtime: python3.7
Transform: AWS::Serverless-2016-10-31
```

### 具有 Auth 的 HttpApi
<a name="sam-resource-httpapi--examples--httpapi-with-auth"></a>

下列範例示範如何在 HTTP API 端點上設定授權。

#### YAML
<a name="sam-resource-httpapi--examples--httpapi-with-auth--yaml"></a>

```
Properties:
  FailOnWarnings: true
  Auth:
    DefaultAuthorizer: OAuth2
    Authorizers:
      OAuth2:
        AuthorizationScopes:
          - scope4
        JwtConfiguration:
          issuer: "https://www.example.com/v1/connect/oauth2"
          audience:
            - MyApi
        IdentitySource: "$request.querystring.param"
```

### 具有 OpenAPI 定義的 HttpApi
<a name="sam-resource-httpapi--examples--httpapi-with-openapi-definition"></a>

下列範例示範如何將 OpenAPI 定義新增至範本。

請注意， 會為參考此 HTTP API 的 HttpApi 事件 AWS SAM 填入任何遺失的 Lambda 整合。 AWS SAM 也會新增 HttpApi 事件參考的任何遺失路徑。

#### YAML
<a name="sam-resource-httpapi--examples--httpapi-with-openapi-definition--yaml"></a>

```
Properties:
  FailOnWarnings: true
  DefinitionBody:
    info:
      version: '1.0'
      title:
        Ref: AWS::StackName
    paths:
      "/":
        get:
          security:
          - OpenIdAuth:
            - scope1
            - scope2
          responses: {}
    openapi: 3.0.1
    securitySchemes:
      OpenIdAuth:
        type: openIdConnect
        x-amazon-apigateway-authorizer:
          identitySource: "$request.querystring.param"
          type: jwt
          jwtConfiguration:
            audience:
            - MyApi
            issuer: https://www.example.com/v1/connect/oidc
          openIdConnectUrl: https://www.example.com/v1/connect/oidc/.well-known/openid-configuration
```

### 具有組態設定的 HttpApi
<a name="sam-resource-httpapi--examples--httpapi-with-configuration-settings"></a>

下列範例示範如何將 HTTP API 和階段組態新增至範本。

#### YAML
<a name="sam-resource-httpapi--examples--httpapi-with-configuration-settings--yaml"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
  StageName:
    Type: String
    Default: Prod
    
Resources:
  HttpApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
          def handler(event, context):
              import json
              return {
                  "statusCode": 200,
                  "body": json.dumps(event),
              }
      Handler: index.handler
      Runtime: python3.7
      Events:
        ExplicitApi: # warning: creates a public endpoint
          Type: HttpApi
          Properties:
            ApiId: !Ref HttpApi
            Method: GET
            Path: /path
            TimeoutInMillis: 15000
            PayloadFormatVersion: "2.0"
            RouteSettings:
              ThrottlingBurstLimit: 600

  HttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      StageName: !Ref StageName
      Tags:
        Tag: Value
      AccessLogSettings:
        DestinationArn: !GetAtt AccessLogs.Arn
        Format: $context.requestId
      DefaultRouteSettings:
        ThrottlingBurstLimit: 200
      RouteSettings:
        "GET /path":
          ThrottlingBurstLimit: 500 # overridden in HttpApi Event
      StageVariables:
        StageVar: Value
      FailOnWarnings: true

  AccessLogs:
    Type: AWS::Logs::LogGroup

Outputs:
  HttpApiUrl:
    Description: URL of your API endpoint
    Value:
      Fn::Sub: 'https://${HttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/${StageName}/'
  HttpApiId:
    Description: Api id of HttpApi
    Value:
      Ref: HttpApi
```

# HttpApiAuth
<a name="sam-property-httpapi-httpapiauth"></a>

設定授權以控制對 Amazon API Gateway HTTP API 的存取。

如需設定 HTTP APIs 存取權的詳細資訊，請參閱[《 API Gateway 開發人員指南》中的在 API Gateway 中控制和管理 HTTP API 的存取權](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-access-control.html)。 **

## 語法
<a name="sam-property-httpapi-httpapiauth-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-httpapiauth-syntax.yaml"></a>

```
  [Authorizers](#sam-httpapi-httpapiauth-authorizers): OAuth2Authorizer | LambdaAuthorizer
  [DefaultAuthorizer](#sam-httpapi-httpapiauth-defaultauthorizer): String
  [EnableIamAuthorizer](#sam-httpapi-httpapiauth-enableiamauthorizer): Boolean
```

## Properties
<a name="sam-property-httpapi-httpapiauth-properties"></a>

 `Authorizers`   <a name="sam-httpapi-httpapiauth-authorizers"></a>
用於控制 API Gateway API 存取的授權方。  
*類型*：[OAuth2Authorizer](sam-property-httpapi-oauth2authorizer.md) \$1 [LambdaAuthorizer](sam-property-httpapi-lambdaauthorizer.md)  
*必要*：否  
*預設*：無  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*其他備註*：將授權方 AWS SAM 新增至 OpenAPI 定義。

 `DefaultAuthorizer`   <a name="sam-httpapi-httpapiauth-defaultauthorizer"></a>
指定用於授權 API Gateway API 呼叫的預設授權方。如果 `EnableIamAuthorizer` 設定為 ，您可以將 指定`AWS_IAM`為預設授權方`true`。否則，請指定您在 中定義的授權方`Authorizers`。  
*類型：*字串  
*必要*：否  
*預設*：無  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `EnableIamAuthorizer`   <a name="sam-httpapi-httpapiauth-enableiamauthorizer"></a>
指定是否使用 API 路由的 IAM 授權。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-httpapi-httpapiauth--examples"></a>

### OAuth 2.0 授權方
<a name="sam-property-httpapi-httpapiauth--examples--oauth-2.0-authorizer"></a>

OAuth 2.0 授權方範例

#### YAML
<a name="sam-property-httpapi-httpapiauth--examples--oauth-2.0-authorizer--yaml"></a>

```
Auth:
  Authorizers:
    OAuth2Authorizer:
      AuthorizationScopes:
        - scope1
        - scope2
      JwtConfiguration:
        issuer: "https://www.example.com/v1/connect/oauth2"
        audience:
          - MyApi
      IdentitySource: "$request.querystring.param"
  DefaultAuthorizer: OAuth2Authorizer
```

### IAM 授權方
<a name="sam-property-httpapi-httpapiauth--examples--iam-authorizer"></a>

IAM 授權方範例

#### YAML
<a name="sam-property-httpapi-httpapiauth--examples--iam-authorizer--yaml"></a>

```
Auth:
  EnableIamAuthorizer: true
  DefaultAuthorizer: AWS_IAM
```

# LambdaAuthorizer
<a name="sam-property-httpapi-lambdaauthorizer"></a>

設定 Lambda 授權方，以使用 AWS Lambda 函數控制對 Amazon API Gateway HTTP API 的存取。

如需詳細資訊和範例，請參閱[APIs》中的使用 HTTP API 的授權 AWS Lambda 方](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html)。 **

## 語法
<a name="sam-property-httpapi-lambdaauthorizer-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-lambdaauthorizer-syntax.yaml"></a>

```
  [AuthorizerPayloadFormatVersion](#sam-httpapi-lambdaauthorizer-authorizerpayloadformatversion): String
  EnableFunctionDefaultPermissions: Boolean
  [EnableSimpleResponses](#sam-httpapi-lambdaauthorizer-enablesimpleresponses): Boolean
  [FunctionArn](#sam-httpapi-lambdaauthorizer-functionarn): String
  [FunctionInvokeRole](#sam-httpapi-lambdaauthorizer-functioninvokerole): String
  [Identity](#sam-httpapi-lambdaauthorizer-identity): LambdaAuthorizationIdentity
```

## Properties
<a name="sam-property-httpapi-lambdaauthorizer-properties"></a>

 `AuthorizerPayloadFormatVersion`   <a name="sam-httpapi-lambdaauthorizer-authorizerpayloadformatversion"></a>
指定傳送至 HTTP API Lambda 授權方的承載格式。HTTP API Lambda 授權方的必要項目。  
這會在 OpenAPI 定義的 `authorizerPayloadFormatVersion`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
*有效值*：`1.0` 或 `2.0`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `EnableFunctionDefaultPermissions`   <a name="sam-httpapi-lambdaauthorizer-enablefunctiondefaultpermissions"></a>
根據預設，不會授予 HTTP API 資源叫用 Lambda 授權方的許可。將此屬性指定為 `true`，以在 HTTP API 資源和 Lambda 授權方之間自動建立許可。  
*類型*：布林值  
*必要*：否  
*預設值*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

 `EnableSimpleResponses`   <a name="sam-httpapi-lambdaauthorizer-enablesimpleresponses"></a>
指定 Lambda 授權方是否以簡單格式傳回回應。根據預設，Lambda 授權方必須傳回 AWS Identity and Access Management (IAM) 政策。如果啟用，Lambda 授權方會傳回布林值，而不是 IAM 政策。  
這會在 OpenAPI 定義的 `enableSimpleResponses`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FunctionArn`   <a name="sam-httpapi-lambdaauthorizer-functionarn"></a>
提供 API 授權的 Lambda 函數的 Amazon Resource Name (ARN)。  
這會在 OpenAPI 定義的 `authorizerUri`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FunctionInvokeRole`   <a name="sam-httpapi-lambdaauthorizer-functioninvokerole"></a>
IAM 角色的 ARN，具有 API Gateway 叫用授權方函數所需的登入資料。如果函數的資源型政策未授予 API Gateway `lambda:InvokeFunction`許可，請指定此參數。  
這會在 OpenAPI 定義的 `authorizerCredentials`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
如需詳細資訊，請參閱《 *API Gateway 開發人員指南*》中的[建立 Lambda 授權方](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html#http-api-lambda-authorizer.example-create)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Identity`   <a name="sam-httpapi-lambdaauthorizer-identity"></a>
在 授權方的傳入請求`IdentitySource`中指定 。  
這會在 OpenAPI 定義的 `identitySource`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
*類型*：[LambdaAuthorizationIdentity](sam-property-httpapi-lambdaauthorizationidentity.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-httpapi-lambdaauthorizer--examples"></a>

### LambdaAuthorizer
<a name="sam-property-httpapi-lambdaauthorizer--examples--lambdaauthorizer"></a>

LambdaAuthorizer 範例

#### YAML
<a name="sam-property-httpapi-lambdaauthorizer--examples--lambdaauthorizer--yaml"></a>

```
Auth:
  Authorizers:
    MyLambdaAuthorizer:
      AuthorizerPayloadFormatVersion: 2.0
      FunctionArn:
        Fn::GetAtt:
          - MyAuthFunction
          - Arn
      FunctionInvokeRole:
        Fn::GetAtt:
          - LambdaAuthInvokeRole
          - Arn
      Identity:
        Headers:
          - Authorization
```

# LambdaAuthorizationIdentity
<a name="sam-property-httpapi-lambdaauthorizationidentity"></a>

使用 屬性可用於在 Lambda 授權方的傳入請求中指定 IdentitySource。如需身分來源的詳細資訊，請參閱 *API Gateway 開發人員指南*中的[身分來源](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html#http-api-lambda-authorizer.identity-sources)。

## 語法
<a name="sam-property-httpapi-lambdaauthorizationidentity-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-lambdaauthorizationidentity-syntax.yaml"></a>

```
  [Context](#sam-httpapi-lambdaauthorizationidentity-context): List
  [Headers](#sam-httpapi-lambdaauthorizationidentity-headers): List
  [QueryStrings](#sam-httpapi-lambdaauthorizationidentity-querystrings): List
  [ReauthorizeEvery](#sam-httpapi-lambdaauthorizationidentity-reauthorizeevery): Integer
  [StageVariables](#sam-httpapi-lambdaauthorizationidentity-stagevariables): List
```

## Properties
<a name="sam-property-httpapi-lambdaauthorizationidentity-properties"></a>

 `Context`   <a name="sam-httpapi-lambdaauthorizationidentity-context"></a>
將指定的內容字串轉換為格式為 的映射表達式清單`$context.contextString`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Headers`   <a name="sam-httpapi-lambdaauthorizationidentity-headers"></a>
將標頭轉換為格式為 的映射表達式清單`$request.header.name`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `QueryStrings`   <a name="sam-httpapi-lambdaauthorizationidentity-querystrings"></a>
將指定的查詢字串轉換為格式為 的映射表達式清單`$request.querystring.queryString`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ReauthorizeEvery`   <a name="sam-httpapi-lambdaauthorizationidentity-reauthorizeevery"></a>
存活期 (TTL) 期間 (秒)，指定 API Gateway 快取授權方結果的時間。如果您指定的值大於 0，則 API Gateway 會快取授權方回應。值的上限為 3600 (1 小時)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `StageVariables`   <a name="sam-httpapi-lambdaauthorizationidentity-stagevariables"></a>
將指定的階段變數轉換為格式為 的映射表達式清單`$stageVariables.stageVariable`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-httpapi-lambdaauthorizationidentity--examples"></a>

### LambdaRequestIdentity
<a name="sam-property-httpapi-lambdaauthorizationidentity--examples--lambdarequestidentity"></a>

Lambda 請求身分範例

#### YAML
<a name="sam-property-httpapi-lambdaauthorizationidentity--examples--lambdarequestidentity--yaml"></a>

```
Identity:
  QueryStrings:
    - auth
  Headers:
    - Authorization
  StageVariables:
    - VARIABLE
  Context:
    - authcontext
  ReauthorizeEvery: 100
```

# OAuth2Authorizer
<a name="sam-property-httpapi-oauth2authorizer"></a>

OAuth 2.0 授權方的定義，也稱為 JSON Web Token (JWT) 授權方。

如需詳細資訊，請參閱《*API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。

## 語法
<a name="sam-property-httpapi-oauth2authorizer-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-oauth2authorizer-syntax.yaml"></a>

```
  [AuthorizationScopes](#sam-httpapi-oauth2authorizer-authorizationscopes): List
  [IdentitySource](#sam-httpapi-oauth2authorizer-identitysource): String
  [JwtConfiguration](#sam-httpapi-oauth2authorizer-jwtconfiguration): Map
```

## Properties
<a name="sam-property-httpapi-oauth2authorizer-properties"></a>

 `AuthorizationScopes`   <a name="sam-httpapi-oauth2authorizer-authorizationscopes"></a>
此授權方的授權範圍清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IdentitySource`   <a name="sam-httpapi-oauth2authorizer-identitysource"></a>
此授權方的身分來源表達式。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `JwtConfiguration`   <a name="sam-httpapi-oauth2authorizer-jwtconfiguration"></a>
此授權方的 JWT 組態。  
這會在 OpenAPI 定義的 `jwtConfiguration`區段`x-amazon-apigateway-authorizer`中傳遞至 的 `securitySchemes`區段。  
屬性 `issuer`和 不區分`audience`大小寫，可用於小寫，如 OpenAPI 或大寫`Issuer``Audience`和 [ AWS::ApiGatewayV2::Authorizer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-authorizer-jwtconfiguration.html)。
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-httpapi-oauth2authorizer--examples"></a>

### OAuth 2.0 授權方
<a name="sam-property-httpapi-oauth2authorizer--examples--oauth-2.0-authorizer"></a>

OAuth 2.0 授權方範例

#### YAML
<a name="sam-property-httpapi-oauth2authorizer--examples--oauth-2.0-authorizer--yaml"></a>

```
Auth:
  Authorizers:
    OAuth2Authorizer:
      AuthorizationScopes:
        - scope1
      JwtConfiguration:
        issuer: "https://www.example.com/v1/connect/oauth2"
        audience:
          - MyApi
      IdentitySource: "$request.querystring.param"
  DefaultAuthorizer: OAuth2Authorizer
```

# HttpApiCorsConfiguration
<a name="sam-property-httpapi-httpapicorsconfiguration"></a>

管理 HTTP APIs 的跨來源資源共用 (CORS)。指定要允許做為字串的網域，或指定具有其他 Cors 組態的字典。注意：Cors 需要 SAM 修改您的 OpenAPI 定義，因此它僅適用於 `DefinitionBody` 屬性中定義的內嵌 OpenApi。

如需 CORS 的詳細資訊，請參閱 *API Gateway 開發人員指南*中的[設定 HTTP API 的 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。

注意：如果在 OpenAPI 和屬性層級同時設定 HttpApiCorsConfiguration， 會將它們與優先的屬性 AWS SAM 合併。

## 語法
<a name="sam-property-httpapi-httpapicorsconfiguration-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-httpapicorsconfiguration-syntax.yaml"></a>

```
  [AllowCredentials](#sam-httpapi-httpapicorsconfiguration-allowcredentials): Boolean
  [AllowHeaders](#sam-httpapi-httpapicorsconfiguration-allowheaders): List
  [AllowMethods](#sam-httpapi-httpapicorsconfiguration-allowmethods): List
  [AllowOrigins](#sam-httpapi-httpapicorsconfiguration-alloworigins): List
  [ExposeHeaders](#sam-httpapi-httpapicorsconfiguration-exposeheaders): List
  [MaxAge](#sam-httpapi-httpapicorsconfiguration-maxage): Integer
```

## Properties
<a name="sam-property-httpapi-httpapicorsconfiguration-properties"></a>

 `AllowCredentials`   <a name="sam-httpapi-httpapicorsconfiguration-allowcredentials"></a>
指定 CORS 請求中是否包含憑證。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AllowHeaders`   <a name="sam-httpapi-httpapicorsconfiguration-allowheaders"></a>
代表允許標頭的集合。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AllowMethods`   <a name="sam-httpapi-httpapicorsconfiguration-allowmethods"></a>
代表允許的 HTTP 方法集合。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AllowOrigins`   <a name="sam-httpapi-httpapicorsconfiguration-alloworigins"></a>
代表允許的來源集合。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ExposeHeaders`   <a name="sam-httpapi-httpapicorsconfiguration-exposeheaders"></a>
代表公開標頭的集合。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `MaxAge`   <a name="sam-httpapi-httpapicorsconfiguration-maxage"></a>
瀏覽器應快取預檢請求結果的秒數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-httpapi-httpapicorsconfiguration--examples"></a>

### HttpApiCorsConfiguration
<a name="sam-property-httpapi-httpapicorsconfiguration--examples--httpapicorsconfiguration"></a>

HTTP API Cors 組態範例。

#### YAML
<a name="sam-property-httpapi-httpapicorsconfiguration--examples--httpapicorsconfiguration--yaml"></a>

```
CorsConfiguration:
  AllowOrigins:
    - "https://example.com"
  AllowHeaders:
    - x-apigateway-header
  AllowMethods:
    - GET
  MaxAge: 600
  AllowCredentials: true
```

# HttpApiDefinition
<a name="sam-property-httpapi-httpapidefinition"></a>

定義 API 的 OpenAPI 文件。

## 語法
<a name="sam-property-httpapi-httpapidefinition-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-httpapidefinition-syntax.yaml"></a>

```
  [Bucket](#sam-httpapi-httpapidefinition-bucket): String
  [Key](#sam-httpapi-httpapidefinition-key): String
  [Version](#sam-httpapi-httpapidefinition-version): String
```

## Properties
<a name="sam-property-httpapi-httpapidefinition-properties"></a>

 `Bucket`   <a name="sam-httpapi-httpapidefinition-bucket"></a>
存放 OpenAPI 檔案的 Amazon S3 儲存貯體名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Api` `BodyS3Location` 資料類型的 `[Bucket](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-bucket)` 屬性。

 `Key`   <a name="sam-httpapi-httpapidefinition-key"></a>
OpenAPI 檔案的 Amazon S3 金鑰。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Api` `BodyS3Location` 資料類型的 `[Key](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-key)` 屬性。

 `Version`   <a name="sam-httpapi-httpapidefinition-version"></a>
對於版本控制的物件，則為 OpenAPI 檔案的版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Api` `BodyS3Location` 資料類型的 `[Version](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-version)` 屬性。

## 範例
<a name="sam-property-httpapi-httpapidefinition--examples"></a>

### 定義 Uri 範例
<a name="sam-property-httpapi-httpapidefinition--examples--definition-uri-example"></a>

API 定義範例

#### YAML
<a name="sam-property-httpapi-httpapidefinition--examples--definition-uri-example--yaml"></a>

```
DefinitionUri:
  Bucket: sam-s3-demo-bucket-name
  Key: mykey-name
  Version: 121212
```

# HttpApiDomainConfiguration
<a name="sam-property-httpapi-httpapidomainconfiguration"></a>

設定 API 的自訂網域。

## 語法
<a name="sam-property-httpapi-httpapidomainconfiguration-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-httpapidomainconfiguration-syntax.yaml"></a>

```
  [BasePath](#sam-httpapi-httpapidomainconfiguration-basepath): List
  [CertificateArn](#sam-httpapi-httpapidomainconfiguration-certificatearn): String
  [DomainName](#sam-httpapi-httpapidomainconfiguration-domainname): String
  [EndpointConfiguration](#sam-httpapi-httpapidomainconfiguration-endpointconfiguration): String
  [MutualTlsAuthentication](#sam-httpapi-httpapidomainconfiguration-mutualtlsauthentication): [MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-mutualtlsauthentication)
  [OwnershipVerificationCertificateArn](#sam-httpapi-httpapidomainconfiguration-ownershipverificationcertificatearn): String
  [Route53](#sam-httpapi-httpapidomainconfiguration-route53): Route53Configuration
  [SecurityPolicy](#sam-httpapi-httpapidomainconfiguration-securitypolicy): String
```

## Properties
<a name="sam-property-httpapi-httpapidomainconfiguration-properties"></a>

 `BasePath`   <a name="sam-httpapi-httpapidomainconfiguration-basepath"></a>
要使用 Amazon API Gateway 網域名稱設定的基本路徑清單。  
*類型：*清單  
*必要*：否  
*預設*：/  
*CloudFormation 相容性*：此屬性類似於 `AWS::ApiGatewayV2::ApiMapping` 資源的 `[ApiMappingKey](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apimappingkey)` 屬性。 會 AWS SAM 建立多個 `AWS::ApiGatewayV2::ApiMapping` 資源，每個在此屬性中指定的值各一個。

 `CertificateArn`   <a name="sam-httpapi-httpapidomainconfiguration-certificatearn"></a>
此網域名稱端點受 AWS 管憑證的 Amazon Resource Name (ARN)。 AWS Certificate Manager 是唯一支援的來源。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway2::DomainName DomainNameConfiguration` 資源的 `[CertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-certificatearn)` 屬性。

 `DomainName`   <a name="sam-httpapi-httpapidomainconfiguration-domainname"></a>
API Gateway API 的自訂網域名稱。不支援大寫字母。  
AWS SAM 會在設定此屬性時產生 `AWS::ApiGatewayV2::DomainName` 資源。如需此案例的資訊，請參閱 [已指定 DomainName 屬性](sam-specification-generated-resources-httpapi.md#sam-specification-generated-resources-httpapi-domain-name)。如需所產生 CloudFormation 資源的資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGateway2::DomainName` 資源的 `[DomainName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainname)` 屬性。

 `EndpointConfiguration`   <a name="sam-httpapi-httpapidomainconfiguration-endpointconfiguration"></a>
定義要映射到自訂網域的 API Gateway 端點類型。此屬性的值會決定`CertificateArn`屬性的映射方式 CloudFormation。  
HTTP APIs 的唯一有效值是 `REGIONAL`。  
*類型：*字串  
*必要*：否  
*預設*：`REGIONAL`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `MutualTlsAuthentication`   <a name="sam-httpapi-httpapidomainconfiguration-mutualtlsauthentication"></a>
自訂網域名稱的交互傳輸層安全 (TLS) 身分驗證組態。  
*類型*：[MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-mutualtlsauthentication)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::DomainName` 資源的 `[MutualTlsAuthentication](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-mutualtlsauthentication)` 屬性。

 `OwnershipVerificationCertificateArn`   <a name="sam-httpapi-httpapidomainconfiguration-ownershipverificationcertificatearn"></a>
ACM 核發之公有憑證的 ARN，用於驗證您的自訂網域的擁有權。只有在您設定交互 TLS 並指定 的 ACM 匯入或私有 CA 憑證 ARN 時才需要`CertificateArn`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::DomainName` `DomainNameConfiguration` 資料類型的 `[OwnershipVerificationCertificateArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-ownershipverificationcertificatearn)` 屬性。

 `Route53`   <a name="sam-httpapi-httpapidomainconfiguration-route53"></a>
定義 Amazon Route 53 組態。  
*類型*：[Route53Configuration](sam-property-httpapi-route53configuration.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SecurityPolicy`   <a name="sam-httpapi-httpapidomainconfiguration-securitypolicy"></a>
此網域名稱之安全政策的 TLS 版本。  
HTTP APIs 的唯一有效值是 `TLS_1_2`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::DomainName` `DomainNameConfiguration` 資料類型的 `[SecurityPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-securitypolicy)` 屬性。

## 範例
<a name="sam-property-httpapi-httpapidomainconfiguration--examples"></a>

### DomainName
<a name="sam-property-httpapi-httpapidomainconfiguration--examples--domainname"></a>

DomainName 範例

#### YAML
<a name="sam-property-httpapi-httpapidomainconfiguration--examples--domainname--yaml"></a>

```
Domain:
  DomainName: www.example.com
  CertificateArn: arn-example
  EndpointConfiguration: REGIONAL
  Route53:
    HostedZoneId: Z1PA6795UKMFR9
  BasePath:
    - foo
    - bar
```

# Route53Configuration
<a name="sam-property-httpapi-route53configuration"></a>

設定 API 的 Route53 記錄集。

## 語法
<a name="sam-property-httpapi-route53configuration-syntax"></a>

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

### YAML
<a name="sam-property-httpapi-route53configuration-syntax.yaml"></a>

```
  [DistributionDomainName](#sam-httpapi-route53configuration-distributiondomainname): String
  [EvaluateTargetHealth](#sam-httpapi-route53configuration-evaluatetargethealth): Boolean
  [HostedZoneId](#sam-httpapi-route53configuration-hostedzoneid): String
  [HostedZoneName](#sam-httpapi-route53configuration-hostedzonename): String
  [IpV6](#sam-httpapi-route53configuration-ipv6): Boolean
  Region: String
  SetIdentifier: String
```

## Properties
<a name="sam-property-httpapi-route53configuration-properties"></a>

 `DistributionDomainName`   <a name="sam-httpapi-route53configuration-distributiondomainname"></a>
設定 API 自訂網域名稱的自訂分佈。  
*類型：*字串  
*必要*：否  
*預設*：使用 API Gateway 分佈。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup AliasTarget` 資源的 `[DNSName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget-1.html#cfn-route53-aliastarget-dnshostname)` 屬性。  
*其他備註*：[CloudFront 分佈](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html)的網域名稱。

 `EvaluateTargetHealth`   <a name="sam-httpapi-route53configuration-evaluatetargethealth"></a>
當 EvaluateTargetHealth 為 true 時，別名記錄會繼承參考 AWS 資源的運作狀態，例如 Elastic Load Balancing 負載平衡器或託管區域中的其他記錄。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup AliasTarget` 資源的 `[EvaluateTargetHealth](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html#cfn-route53-aliastarget-evaluatetargethealth)` 屬性。  
*其他備註*：當別名目標為 CloudFront 分佈時，您無法將 EvaluateTargetHealth 設定為 true。

 `HostedZoneId`   <a name="sam-httpapi-route53configuration-hostedzoneid"></a>
託管區域的 ID，您要在其中建立記錄。  
請指定 `HostedZoneName` 或 `HostedZoneId` 其中之一。若有多個託管區域的網域名稱相同，則您必須使用 `HostedZoneId` 以明確指定託管區域。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup RecordSet` 資源的 `[HostedZoneId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzoneid)` 屬性。

 `HostedZoneName`   <a name="sam-httpapi-route53configuration-hostedzonename"></a>
您要在其中建立記錄的託管區域名稱。您必須包含結尾點 (例如 `www.example.com.`) 作為 `HostedZoneName` 的一部分。  
請指定 `HostedZoneName` 或 `HostedZoneId` 其中之一。若有多個託管區域的網域名稱相同，則您必須使用 `HostedZoneId` 以明確指定託管區域。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup RecordSet` 資源的 `[HostedZoneName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-hostedzonename)` 屬性。

 `IpV6`   <a name="sam-httpapi-route53configuration-ipv6"></a>
設定此屬性時， 會 AWS SAM 建立`AWS::Route53::RecordSet`資源，並將提供的 HostedZone `AAAA`的 [Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset.html#cfn-route53-recordset-type) 設定為 。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`Region`  <a name="sam-httpapi-route53configuration-region"></a>
*僅限延遲型資源記錄集：*您建立資源的 Amazon EC2 區域，這是此資源記錄集指向的資源。資源通常是 AWS 資源，例如 EC2 執行個體或 ELB 負載平衡器，並且根據記錄類型由 IP 地址或 DNS 網域名稱參考。  
當 Amazon Route 53 收到網域名稱和類型的 DNS 查詢，而您已建立其延遲資源記錄集時，Route 53 會選取最低延遲介於最終使用者與相關聯 Amazon EC2 區域之間的延遲資源記錄集。Route 53 接著會傳回與所選資源記錄集相關聯的值。  
注意下列事項：  
+ 每個延遲資源記錄集只能指定一個 `ResourceRecord`。
+ 每個 Amazon EC2 區域都只能建立一個延遲資源記錄集。
+ 您不必為所有的 Amazon EC2 區域建立延遲資源記錄集。Route 53 會從您建立延遲資源記錄集的區域中，選擇具有最佳延遲的區域。
+ 您無法建立和延遲資源記錄集的 `Name` 和 `Type` 元素具有相同值的非延遲資源記錄集。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup``RecordSet`資料類型的 `[ Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-region)` 屬性。

`SetIdentifier`  <a name="sam-httpapi-route53configuration-setidentifier"></a>
*沒有簡單路由政策的資源記錄集：*在具有相同名稱和類型組合的多個資源記錄集中用以區隔的識別碼，例如，多個加權資源記錄集名為 acme.example.com 且類型為 A。在一組具有相同名稱和類型的資源記錄集中，每個資源記錄集的 `SetIdentifier` 值都必須是唯一的。  
如需路由政策的資訊，請參閱《*Amazon Route 53 開發人員指南*》中的[選擇路由政策](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Route53::RecordSetGroup``RecordSet`資料類型的 `[ SetIdentifier](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordset-1.html#cfn-route53-recordset-setidentifier)` 屬性。

## 範例
<a name="sam-property-httpapi-route53configuration--examples"></a>

### Route 53 組態範例
<a name="sam-property-httpapi-route53configuration--examples--route-53-configuration-example"></a>

此範例說明如何設定 Route 53。

#### YAML
<a name="sam-property-httpapi-route53configuration--examples--route-53-configuration-example--yaml"></a>

```
Domain:
  DomainName: www.example.com
  CertificateArn: arn-example
  EndpointConfiguration: EDGE
  Route53:
    HostedZoneId: Z1PA6795UKMFR9
    EvaluateTargetHealth: true
    DistributionDomainName: xyz
```

# AWS::Serverless::LayerVersion
<a name="sam-resource-layerversion"></a>

建立 Lambda LayerVersion，其中包含 Lambda 函數所需的程式庫或執行時間程式碼。

[AWS::Serverless::LayerVersion](#sam-resource-layerversion) 資源也支援 `Metadata` 資源屬性，因此您可以指示 AWS SAM 建置應用程式中包含的層。如需建置層的詳細資訊，請參閱 [在 中建置 Lambda 層 AWS SAM](building-layers.md)。

**重要注意事項**：由於 [UpdateReplacePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html) 資源屬性在 中發行 CloudFormation， [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html)（建議） 提供與 相同的優點[AWS::Serverless::LayerVersion](#sam-resource-layerversion)。

轉換 Serverless LayerVersion 時，SAM 也會轉換資源的邏輯 ID，以便在更新資源時CloudFormation 不會自動刪除舊的 LayerVersions。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-layerversion-syntax"></a>

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

### YAML
<a name="sam-resource-layerversion-syntax.yaml"></a>

```
Type: AWS::Serverless::LayerVersion
Properties:
  [CompatibleArchitectures](#sam-layerversion-compatiblearchitectures): List
  [CompatibleRuntimes](#sam-layerversion-compatibleruntimes): List
  [ContentUri](#sam-layerversion-contenturi): String | LayerContent
  [Description](#sam-layerversion-description): String
  [LayerName](#sam-layerversion-layername): String
  [LicenseInfo](#sam-layerversion-licenseinfo): String
  [PublishLambdaVersion](#sam-layerversion-PublishLambdaVersion): Boolean
  [RetentionPolicy](#sam-layerversion-retentionpolicy): String
```

## Properties
<a name="sam-resource-layerversion-properties"></a>

 `CompatibleArchitectures`   <a name="sam-layerversion-compatiblearchitectures"></a>
指定 layer 版本的支援指令集架構。  
如需此屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [Lambda 指令集架構](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html)。  
*有效值*：`x86_64`、`arm64`  
*類型：*清單  
*必要*：否  
*預設*：`x86_64`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` 資源的 `[CompatibleArchitectures](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-compatiblearchitectures)` 屬性。

 `CompatibleRuntimes`   <a name="sam-layerversion-compatibleruntimes"></a>
與此 LayerVersion 相容的執行時間清單。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` 資源的 `[CompatibleRuntimes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-compatibleruntimes)` 屬性。

 `ContentUri`   <a name="sam-layerversion-contenturi"></a>
Amazon S3 Uri、本機資料夾的路徑，或 layer 程式碼的 LayerContent 物件。  
如果提供 Amazon S3 Uri 或 LayerContent 物件，則參考的 Amazon S3 物件必須是包含 [Lambda 層](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)內容的有效 ZIP 封存。  
如果提供本機資料夾的路徑，則要正確轉換內容，範本必須經過包含 的工作流程，[sam build](sam-cli-command-reference-sam-build.md)後面接著 [sam deploy](sam-cli-command-reference-sam-deploy.md)或 [sam package](sam-cli-command-reference-sam-package.md)。根據預設，相對路徑會根據 AWS SAM 範本的位置進行解析。  
*類型*：字串 \$1 [LayerContent](sam-property-layerversion-layercontent.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::LayerVersion` 資源的 `[Content](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-content)` 屬性。巢狀 Amazon S3 屬性的名稱不同。

 `Description`   <a name="sam-layerversion-description"></a>
此 layer 的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-description)` 屬性。

 `LayerName`   <a name="sam-layerversion-layername"></a>
layer 的名稱或 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：否  
*預設*：資源邏輯 ID  
*CloudFormation 相容性*：此屬性類似於 `AWS::Lambda::LayerVersion` 資源的 `[LayerName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-layername)` 屬性。如果您未指定名稱，資源的邏輯 ID 將用作名稱。

 `LicenseInfo`   <a name="sam-layerversion-licenseinfo"></a>
此 LayerVersion 的授權相關資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` 資源的 `[LicenseInfo](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-licenseinfo)` 屬性。

 `PublishLambdaVersion`   <a name="sam-layerversion-PublishLambdaVersion"></a>
選擇加入屬性，可在參考`LayerVersion`資源發生變更時建立新的 Lambda 版本。在連線的 Lambda 函數`AutoPublishAliasAllProperties`中使用 `AutoPublishAlias`和 啟用時，將會針對對`LayerVersion`資源所做的每個變更建立新的 Lambda 版本。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RetentionPolicy`   <a name="sam-layerversion-retentionpolicy"></a>
此屬性會指定刪除資源時`LayerVersion`，是否保留或刪除舊版本的 。如果您在更新或取代資源`LayerVersion`時需要保留舊版 ，則必須啟用 `UpdateReplacePolicy` 屬性。如需執行此操作的資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的 [`UpdateReplacePolicy` 屬性](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html)。  
*有效值*：`Retain` 或 `Delete`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。  
*其他備註*：當您指定 時`Retain`， 會將 [支援的資源屬性 AWS SAM](sam-specification-resource-attributes.md) 的 `DeletionPolicy: Retain` AWS SAM 新增至轉換`AWS::Lambda::LayerVersion`的資源。

## 傳回值
<a name="sam-resource-layerversion-return-values"></a>

### Ref
<a name="sam-resource-layerversion-return-values-ref"></a>

當將此資源的邏輯 ID 提供給`Ref`內部 函數時，它會傳回基礎 Lambda LayerVersion 的資源 ARN。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

## 範例
<a name="sam-resource-layerversion--examples"></a>

### LayerVersionExample
<a name="sam-resource-layerversion--examples--layerversionexample"></a>

LayerVersion 的範例

#### YAML
<a name="sam-resource-layerversion--examples--layerversionexample--yaml"></a>

```
Properties:
  LayerName: MyLayer
  Description: Layer description
  ContentUri: 's3://sam-s3-demo-bucket/my-layer.zip'
  CompatibleRuntimes:
    - nodejs10.x
    - nodejs12.x
  LicenseInfo: 'Available under the MIT-0 license.'
  RetentionPolicy: Retain
```

# LayerContent
<a name="sam-property-layerversion-layercontent"></a>

包含 [Lambda 層](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)內容的 ZIP 封存。

## 語法
<a name="sam-property-layerversion-layercontent-syntax"></a>

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

### YAML
<a name="sam-property-layerversion-layercontent-syntax.yaml"></a>

```
  [Bucket](#sam-layerversion-layercontent-bucket): String
  [Key](#sam-layerversion-layercontent-key): String
  [Version](#sam-layerversion-layercontent-version): String
```

## Properties
<a name="sam-property-layerversion-layercontent-properties"></a>

 `Bucket`   <a name="sam-layerversion-layercontent-bucket"></a>
層封存的 Amazon S3 儲存貯體。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` `Content` 資料類型的 `[S3Bucket](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3bucket)` 屬性。

 `Key`   <a name="sam-layerversion-layercontent-key"></a>
層封存的 Amazon S3 金鑰。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` `Content` 資料類型的 `[S3Key](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3key)` 屬性。

 `Version`   <a name="sam-layerversion-layercontent-version"></a>
對於版本控制的物件，要使用的層封存物件版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::LayerVersion` `Content` 資料類型的 `[S3ObjectVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectversion)` 屬性。

## 範例
<a name="sam-property-layerversion-layercontent--examples"></a>

### LayerContent
<a name="sam-property-layerversion-layercontent--examples--layercontent"></a>

Layer 內容範例

#### YAML
<a name="sam-property-layerversion-layercontent--examples--layercontent--yaml"></a>

```
LayerContent:
  Bucket: amzn-s3-demo-bucket-name
  Key: mykey-name
  Version: 121212
```

# AWS::Serverless::SimpleTable
<a name="sam-resource-simpletable"></a>

使用單一屬性主索引鍵建立 DynamoDB 資料表。當只需要透過主索引鍵存取資料時，此功能非常有用。

如需更進階的功能，請使用 中的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html) 資源 CloudFormation。這些資源可用於 AWS SAM。它們是全方位的，並提供進一步的自訂，包括 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-keyschema.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-keyschema.html)和 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-resourcepolicy.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-resourcepolicy.html) 自訂。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-simpletable-syntax"></a>

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

### YAML
<a name="sam-resource-simpletable-syntax.yaml"></a>

```
Type: AWS::Serverless::SimpleTable
Properties:
  PointInTimeRecoverySpecification: [PointInTimeRecoverySpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-pointintimerecoveryspecification.html)
  [PrimaryKey](#sam-simpletable-primarykey): PrimaryKeyObject
  [ProvisionedThroughput](#sam-simpletable-provisionedthroughput): ProvisionedThroughputObject
  [SSESpecification](#sam-simpletable-ssespecification): [SSESpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-ssespecification.html)
  [TableName](#sam-simpletable-tablename): String
  [Tags](#sam-simpletable-tags): Map
```

## Properties
<a name="sam-resource-simpletable-properties"></a>

 `PointInTimeRecoverySpecification`   <a name="sam-simpletable-pointintimerecoveryspecification"></a>
用於啟用時間點復原恢復的設定。  
*類型*：[PointInTimeRecoverySpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-pointintimerecoveryspecification.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` 資源的 `[PointInTimeRecoverySpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-pointintimerecoveryspecification.html)` 屬性。

 `PrimaryKey`   <a name="sam-simpletable-primarykey"></a>
要用作資料表主索引鍵的屬性名稱和類型。如果未提供，主索引鍵將是值`String`為 的 `id`。  
建立此資源後，無法修改此屬性的值。
*類型*：[PrimaryKeyObject](sam-property-simpletable-primarykeyobject.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ProvisionedThroughput`   <a name="sam-simpletable-provisionedthroughput"></a>
讀取和寫入輸送量佈建資訊。  
如果`ProvisionedThroughput`未指定 ，`BillingMode`則會指定為 `PAY_PER_REQUEST`。  
*類型*：[ProvisionedThroughputObject](sam-property-simpletable-provisionedthroughputobject.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` 資源的 `[ProvisionedThroughput](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-provisionedthroughput.html)` 屬性。

 `SSESpecification`   <a name="sam-simpletable-ssespecification"></a>
指定此屬性來啟用伺服器端加密。  
*類型*：[SSESpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-ssespecification.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` 資源的 `[SSESpecification](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-ssespecification.html)` 屬性。

 `TableName`   <a name="sam-simpletable-tablename"></a>
DynamoDB 資料表的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` 資源的 `[TableName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tablename)` 屬性。

 `Tags`   <a name="sam-simpletable-tags"></a>
映射 （字串到字串），指定要新增至此 SimpleTable 的標籤。如需標籤有效金鑰和值的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[資源標籤](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html)。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::DynamoDB::Table` 資源的 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tags)` 屬性。SAM 中的標籤屬性包含 Key：Value 對；在 CloudFormation 中包含標籤物件清單。

## 傳回值
<a name="sam-resource-simpletable-return-values"></a>

### Ref
<a name="sam-resource-simpletable-return-values-ref"></a>

當將此資源的邏輯 ID 提供給 Ref 內部函數時，它會傳回基礎 DynamoDB 資料表的資源名稱。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

## 範例
<a name="sam-resource-simpletable--examples"></a>

### SimpleTableExample
<a name="sam-resource-simpletable--examples--simpletableexample"></a>

SimpleTable 的範例

#### YAML
<a name="sam-resource-simpletable--examples--simpletableexample--yaml"></a>

```
Properties:
  TableName: my-table
  PrimaryKey:
    Name: MyPrimaryKey
    Type: String
  ProvisionedThroughput:
    ReadCapacityUnits: 5
    WriteCapacityUnits: 5
  Tags:
    Department: Engineering
    AppType: Serverless
```

# PrimaryKeyObject
<a name="sam-property-simpletable-primarykeyobject"></a>

描述主索引鍵屬性的物件。

## 語法
<a name="sam-property-simpletable-primarykeyobject-syntax"></a>

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

### YAML
<a name="sam-property-simpletable-primarykeyobject-syntax.yaml"></a>

```
  [Name](#sam-simpletable-primarykeyobject-name): String
  [Type](#sam-simpletable-primarykeyobject-type): String
```

## Properties
<a name="sam-property-simpletable-primarykeyobject-properties"></a>

 `Name`   <a name="sam-simpletable-primarykeyobject-name"></a>
主索引鍵的屬性名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` `AttributeDefinition` 資料類型的 `[AttributeName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-attributedef.html#cfn-dynamodb-attributedef-attributename)` 屬性。  
*其他備註*：此屬性也會傳遞至 `AWS::DynamoDB::Table KeySchema`資料類型的 [AttributeName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-keyschema.html#aws-properties-dynamodb-keyschema-attributename) 屬性。

 `Type`   <a name="sam-simpletable-primarykeyobject-type"></a>
主索引鍵的資料類型。  
*有效值*：`String`、`Number`、 `Binary`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` `AttributeDefinition` 資料類型的 `[AttributeType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-attributedef.html#cfn-dynamodb-attributedef-attributename-attributetype)` 屬性。

## 範例
<a name="sam-property-simpletable-primarykeyobject--examples"></a>

### PrimaryKey
<a name="sam-property-simpletable-primarykeyobject--examples--primarykey"></a>

主索引鍵範例。

#### YAML
<a name="sam-property-simpletable-primarykeyobject--examples--primarykey--yaml"></a>

```
Properties:
  PrimaryKey:
    Name: MyPrimaryKey
    Type: String
```

# ProvisionedThroughputObject
<a name="sam-property-simpletable-provisionedthroughputobject"></a>

描述佈建輸送量屬性的物件。

## 語法
<a name="sam-property-simpletable-provisionedthroughputobject-syntax"></a>

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

### YAML
<a name="w2aac13c22c41c19b5b5"></a>

```
  [ReadCapacityUnits](#sam-simpletable-provisionedthroughputobject-readcapacityunits): Integer
  [WriteCapacityUnits](#sam-simpletable-provisionedthroughputobject-writecapacityunits): Integer
```

## Properties
<a name="sam-property-simpletable-provisionedthroughputobject-properties"></a>

 `ReadCapacityUnits`   <a name="sam-simpletable-provisionedthroughputobject-readcapacityunits"></a>
DynamoDB 傳回 `ThrottlingException` 之前，每秒消耗的強制一致性讀取數目上限。  
*類型*：整數  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` `ProvisionedThroughput` 資料類型的 `[ReadCapacityUnits](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-provisionedthroughput.html#aws-properties-dynamodb-table-provisionedthroughput-properties)` 屬性。

 `WriteCapacityUnits`   <a name="sam-simpletable-provisionedthroughputobject-writecapacityunits"></a>
DynamoDB 傳回 `ThrottlingException` 之前，每秒消耗的寫入數目上限。  
*類型*：整數  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::DynamoDB::Table` `ProvisionedThroughput` 資料類型的 `[WriteCapacityUnits](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-provisionedthroughput.html#aws-properties-dynamodb-table-provisionedthroughput-properties)` 屬性。

## 範例
<a name="sam-property-simpletable-provisionedthroughputobject--examples"></a>

### ProvisionedThroughput
<a name="sam-property-simpletable-provisionedthroughputobject--examples--provisionedthroughput"></a>

佈建輸送量範例。

#### YAML
<a name="sam-property-simpletable-provisionedthroughputobject--examples--provisionedthroughput--yaml"></a>

```
Properties:
   ProvisionedThroughput:
     ReadCapacityUnits: 5
     WriteCapacityUnits: 5
```

# AWS::Serverless::StateMachine
<a name="sam-resource-statemachine"></a>

建立 AWS Step Functions 狀態機器，您可以使用它來協調 AWS Lambda 函數和其他 AWS 資源，以形成複雜且強大的工作流程。

如需 Step Functions 的詳細資訊，請參閱《[AWS Step Functions 開發人員指南](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)》。

**注意**  
當您部署到 時 AWS CloudFormation， 會將您的 AWS SAM 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

## 語法
<a name="sam-resource-statemachine-syntax"></a>

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

### YAML
<a name="sam-resource-statemachine-syntax.yaml"></a>

```
Type: AWS::Serverless::StateMachine
Properties:
  AutoPublishAlias: String
  UseAliasAsEventTarget: Boolean
  [Definition](#sam-statemachine-definition): Map
  [DefinitionSubstitutions](#sam-statemachine-definitionsubstitutions): Map
  [DefinitionUri](#sam-statemachine-definitionuri): String | [S3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)
  DeploymentPreference: [DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachinealias-deploymentpreference.html)
  [Events](#sam-statemachine-events): EventSource
  [Logging](#sam-statemachine-logging): [LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)
  [Name](#sam-statemachine-name): String
  [PermissionsBoundary](#sam-statemachine-permissionsboundary): String
  [Policies](#sam-statemachine-policies): String | List | Map
  PropagateTags: Boolean
  [RolePath](#sam-statemachine-rolepath): String
  [Role](#sam-statemachine-role): String
  [Tags](#sam-statemachine-tags): Map
  [Tracing](#sam-statemachine-tracing): [TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)
  [Type](#sam-statemachine-type): String
```

## Properties
<a name="sam-resource-statemachine-properties"></a>

 `AutoPublishAlias`   <a name="sam-statemachine-autopublishalias"></a>
狀態機器別名的名稱。若要進一步了解如何使用 Step Functions 狀態機器別名，請參閱《 *AWS Step Functions 開發人員指南*》中的[使用版本和別名管理持續部署](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html)。  
使用 `DeploymentPreference`設定別名的部署偏好設定。如果您未指定 `DeploymentPreference`， AWS SAM 會設定流量一次轉移到較新的狀態機器版本。  
AWS SAM `Retain` 根據預設， 會將版本的 `DeletionPolicy`和 `UpdateReplacePolicy` 設為 。舊版不會自動刪除。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachineAlias` 資源的 ` [ Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-name)` 屬性。

 `UseAliasAsEventTarget`   <a name="sam-statemachine-usealiasaseventtarget"></a>
指出是否將使用 `AutoPublishAlias` 屬性建立的別名傳遞至以 [Events](#sam-statemachine-events) 定義的事件來源目標。  
指定 `True`以使用別名做為事件的目標。  
*類型*：布林值  
*必要*：否  
*預設*：`False`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Definition`   <a name="sam-statemachine-definition"></a>
狀態機器定義是一個物件，其中物件的格式與您的 AWS SAM 範本檔案格式相符，例如 JSON 或 YAML。狀態機器定義遵循 [Amazon 狀態語言](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html)。  
如需內嵌狀態機器定義的範例，請參閱 [範例](#sam-resource-statemachine--examples)。  
您必須提供 `Definition`或 `DefinitionUri`。  
*類型*：映射  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `DefinitionSubstitutions`   <a name="sam-statemachine-definitionsubstitutions"></a>
string-to-string映射，指定狀態機器定義中預留位置變數的映射。這可讓您將執行時間取得的值 （例如，從內部函數） 注入狀態機器定義。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::StepFunctions::StateMachine` 資源的 `[DefinitionSubstitutions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitionsubstitutions)` 屬性。如果在內嵌狀態機器定義中指定任何內部函數， 會將項目 AWS SAM 新增至此屬性，以將其插入狀態機器定義。

 `DefinitionUri`   <a name="sam-statemachine-definitionuri"></a>
Amazon Simple Storage Service (Amazon S3) URI 或以 [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) 撰寫之狀態機器定義的本機檔案路徑。  
如果您提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換定義。若要這樣做，您必須使用 0.52.0 版或更新版本的 AWS SAM CLI。  
您必須提供 `Definition`或 `DefinitionUri`。  
*類型*：字串 \$1 [S3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[DefinitionS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)` 屬性。

 `DeploymentPreference`   <a name="sam-statemachine-deploymentpreference"></a>
啟用和設定漸進式狀態機器部署的設定。若要進一步了解 Step Functions 逐步部署，請參閱《 *AWS Step Functions 開發人員指南*》中的[使用版本和別名管理持續部署](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html)。  
在設定此屬性`AutoPublishAlias`之前，請指定 。您的`DeploymentPreference`設定將套用至以 指定的別名`AutoPublishAlias`。  
當您指定 時`DeploymentPreference`， 會自動 AWS SAM 產生`StateMachineVersionArn`子屬性值。  
*類型*：[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachinealias-deploymentpreference.html)  
*必要*：否  
*CloudFormation compatibility*： AWS SAM 產生`StateMachineVersionArn`屬性值並將其連接至 `AWS::StepFunctions::StateMachineAlias` 資源的 `[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-deploymentpreference)` 屬性`DeploymentPreference`，並將其傳遞`DeploymentPreference`至 。

 `Events`   <a name="sam-statemachine-events"></a>
指定觸發此狀態機器的事件。事件由類型和一組屬性組成，這些屬性取決於類型。  
*類型*︰[EventSource](sam-property-statemachine-statemachineeventsource.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Logging`   <a name="sam-statemachine-logging"></a>
定義記錄哪些執行歷史記錄事件及其記錄位置。  
*類型*：[LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)` 屬性。

 `Name`   <a name="sam-statemachine-name"></a>
狀態機器的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[StateMachineName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-statemachinename)` 屬性。

 `PermissionsBoundary`   <a name="sam-statemachine-permissionsboundary"></a>
用於此狀態機器執行角色的許可界限 ARN。此屬性只有在為您產生角色時才有效。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)` 屬性。

 `Policies`   <a name="sam-statemachine-policies"></a>
此狀態機器的許可政策。政策會附加至狀態機器的預設 AWS Identity and Access Management (IAM) 執行角色。  
此屬性接受單一值或值清單。允許數值包括：  
+ [AWS SAM 政策範本](serverless-policy-templates.md).
+ [AWS 受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)或[客戶受管政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#customer-managed-policies)ARN的 。
+ 下列[清單中](https://github.com/aws/serverless-application-model/blob/develop/samtranslator/internal/data/aws_managed_policies.json)受 AWS 管政策的名稱。
+ 在 中格式化YAML為映射的[內嵌 IAM 政策](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#inline-policies)。
如果您設定 `Role` 屬性，則會忽略此屬性。
*類型*：字串 \$1 清單 \$1 映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

`PropagateTags`  <a name="sam-statemachine-propagatetags"></a>
指出是否要將標籤從 `Tags` 屬性傳遞至您[AWS::Serverless::StateMachine](sam-specification-generated-resources-statemachine.md)產生的資源。指定 `True` 在產生的資源中傳播標籤。  
*類型*：布林值  
*必要*：否  
*預設*：`False`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Role`   <a name="sam-statemachine-role"></a>
做為此狀態機器執行角色的 IAM 角色 ARN。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[ RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-rolearn)` 屬性。

 `RolePath`   <a name="sam-statemachine-rolepath"></a>
狀態機器 IAM 執行角色的路徑。  
為您產生角色時，請使用此屬性。使用 `Role` 屬性指定角色時，請勿使用 。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[Path](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-path)` 屬性。

 `Tags`   <a name="sam-statemachine-tags"></a>
string-to-string映射，指定新增至狀態機器和對應執行角色的標籤。如需標籤有效索引鍵和值的資訊，請參閱 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html) 資源的[標籤](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)屬性。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)` `AWS::StepFunctions::StateMachine` resource. AWS SAM automatically 新增`stateMachine:createdBy:SAM`標籤至此資源，以及為其產生的預設角色。

 `Tracing`   <a name="sam-statemachine-tracing"></a>
選取是否 AWS X-Ray 已啟用狀態機器。如需搭配 Step Functions 使用 X-Ray 的詳細資訊，請參閱《 *AWS Step Functions 開發人員指南*》中的 [AWS X-Ray 和 Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-xray-tracing.html)。  
*類型*：[TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)` 屬性。

 `Type`   <a name="sam-statemachine-type"></a>
狀態機器的類型。  
*有效值*：`STANDARD` 或 `EXPRESS`  
*類型：*字串  
*必要*：否  
*預設*：`STANDARD`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::StepFunctions::StateMachine` 資源的 `[StateMachineType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-statemachinetype)` 屬性。

## 傳回值
<a name="sam-resource-statemachine-return-values"></a>

### Ref
<a name="sam-resource-statemachine-return-values-ref"></a>

當您將此資源的邏輯 ID 提供給 Ref 內部函數時，Ref 會傳回基礎`AWS::StepFunctions::StateMachine`資源的 Amazon Resource Name (ARN)。

如需使用 `Ref`函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)》中的 。

### Fn::GetAtt
<a name="sam-resource-statemachine-return-values-fn--getatt"></a>

`Fn::GetAtt` 會傳回此類型之指定屬性的值。以下為可用屬性及傳回值的範例。

如需使用 的詳細資訊`Fn::GetAtt`，請參閱*AWS CloudFormation 《 使用者指南*[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)》中的 。

`Name`  <a name="Name-fn::getatt"></a>
傳回狀態機器的名稱，例如 `HelloWorld-StateMachine`。

## 範例
<a name="sam-resource-statemachine--examples"></a>

### 狀態機器定義檔案
<a name="sam-resource-statemachine--examples--state-machine-definition-file"></a>

以下是內嵌狀態機器定義的範例，允許 lambda 函數叫用狀態機器。請注意，此範例預期 `Role` 屬性會設定適當的政策以允許呼叫。`my_state_machine.asl.json` 檔案必須以 [Amazon States 語言](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html)撰寫。

在此範例中，`DefinitionSubstitution`項目允許狀態機器在 AWS SAM 範本檔案中包含宣告的資源。

#### YAML
<a name="sam-resource-statemachine--examples--state-machine-definition-file--yaml"></a>

```
MySampleStateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    DefinitionUri: statemachine/my_state_machine.asl.json
    Role: arn:aws:iam::123456123456:role/service-role/my-sample-role
    Tracing:
      Enabled: true
    DefinitionSubstitutions:
      MyFunctionArn: !GetAtt MyFunction.Arn
      MyDDBTable: !Ref TransactionTable
```

### 內嵌狀態機器定義
<a name="sam-resource-statemachine--examples--inline-state-machine-definition"></a>

以下是內嵌狀態機器定義的範例。

在此範例中， AWS SAM 範本檔案是以 YAML 撰寫，因此狀態機器定義也以 YAML 表示。若要以 JSON 宣告內嵌狀態機器定義，請以 JSON 撰寫 AWS SAM 範本檔案。

#### YAML
<a name="sam-resource-statemachine--examples--inline-state-machine-definition--yaml"></a>

```
MySampleStateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    Definition:
      StartAt: MyLambdaState
      States:
        MyLambdaState:
          Type: Task
          Resource: arn:aws:lambda:us-east-1:123456123456:function:my-sample-lambda-app
          End: true
    Role: arn:aws:iam::123456123456:role/service-role/my-sample-role
    Tracing:
      Enabled: true
```

# EventSource
<a name="sam-property-statemachine-statemachineeventsource"></a>

描述觸發狀態機器之事件來源的物件。每個事件都包含一個類型和一組取決於該類型的屬性。如需每個事件來源屬性的詳細資訊，請參閱與該類型對應的子主題。

## 語法
<a name="sam-property-statemachine-statemachineeventsource-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachineeventsource-syntax.yaml"></a>

```
  [Properties](#sam-statemachine-statemachineeventsource-properties): Schedule | ScheduleV2 | CloudWatchEvent | EventBridgeRule | Api
  [Type](#sam-statemachine-statemachineeventsource-type): String
```

## Properties
<a name="sam-property-statemachine-statemachineeventsource-properties"></a>

 `Properties`   <a name="sam-statemachine-statemachineeventsource-properties"></a>
描述此事件映射屬性的物件。屬性集必須符合定義的 `Type`。  
*類型*：[排程](sam-property-statemachine-statemachineschedule.md) \$1 [ScheduleV2](sam-property-statemachine-statemachineschedulev2.md) \$1 [CloudWatchEvent](sam-property-statemachine-statemachinecloudwatchevent.md) \$1 [EventBridgeRule](sam-property-statemachine-statemachineeventbridgerule.md) \$1 [Api](sam-property-statemachine-statemachineapi.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-statemachine-statemachineeventsource-type"></a>
事件類型。  
*有效值*：`Api`、`Schedule`、`ScheduleV2`、`CloudWatchEvent`、 `EventBridgeRule`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-statemachine-statemachineeventsource--examples"></a>

### API
<a name="sam-property-statemachine-statemachineeventsource--examples--api"></a>

以下是 `API`類型事件的範例。

#### YAML
<a name="sam-property-statemachine-statemachineeventsource--examples--api--yaml"></a>

```
ApiEvent:
  Type: Api
  Properties:
    Method: get
    Path: /group/{user}
    RestApiId: 
      Ref: MyApi
```

# Api
<a name="sam-property-statemachine-statemachineapi"></a>

描述`Api`事件來源類型的物件。如果已定義[AWS::Serverless::Api](sam-resource-api.md)資源，路徑和方法值必須對應至 API OpenAPI 定義中的 操作。

## 語法
<a name="sam-property-statemachine-statemachineapi-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachineapi-syntax.yaml"></a>

```
  [Auth](#sam-statemachine-statemachineapi-auth): ApiStateMachineAuth
  [Method](#sam-statemachine-statemachineapi-method): String
  [Path](#sam-statemachine-statemachineapi-path): String
  [RestApiId](#sam-statemachine-statemachineapi-restapiid): String
  UnescapeMappingTemplate: Boolean
```

## Properties
<a name="sam-property-statemachine-statemachineapi-properties"></a>

 `Auth`   <a name="sam-statemachine-statemachineapi-auth"></a>
此 API、路徑和方法的授權組態。  
當未指定 `DefaultAuthorizer` 時，使用此屬性覆寫個別路徑的 API `DefaultAuthorizer`設定，或覆寫預設設定`ApiKeyRequired`。  
*類型*：[ApiStateMachineAuth](sam-property-statemachine-apistatemachineauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-statemachine-statemachineapi-method"></a>
叫用此函數的 HTTP 方法。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Path`   <a name="sam-statemachine-statemachineapi-path"></a>
叫用此函數的 URI 路徑。值必須以 開頭`/`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RestApiId`   <a name="sam-statemachine-statemachineapi-restapiid"></a>
`RestApi` 資源的識別符，其中必須包含具有指定路徑和方法的操作。一般而言，這會設定為參考此範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
如果您未定義此屬性， 會使用產生的`OpenApi`文件 AWS SAM 建立預設[AWS::Serverless::Api](sam-resource-api.md)資源。該資源包含由相同範本中未指定 之`Api`事件定義的所有路徑和方法的聯集`RestApiId`。  
此屬性無法參考在另一個範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `UnescapeMappingTemplate`   <a name="sam-statemachine-statemachineapi-unescapemappingtemplate"></a>
在傳遞給狀態機器的輸入上，將 取代`\'`為 `'`來取消單引號。當您的輸入包含單引號時，請使用 。  
如果設定為 `False`且您的輸入包含單引號，則會發生錯誤。
*類型*：布林值  
*必要*：否  
*預設值*：False  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

## 範例
<a name="sam-property-statemachine-statemachineapi--examples"></a>

### ApiEvent
<a name="sam-property-statemachine-statemachineapi--examples--apievent"></a>

以下是 `Api`類型事件的範例。

#### YAML
<a name="sam-property-statemachine-statemachineapi--examples--apievent--yaml"></a>

```
Events:
  ApiEvent:
    Type: Api
    Properties:
      Path: /path
      Method: get
```

# ApiStateMachineAuth
<a name="sam-property-statemachine-apistatemachineauth"></a>

為特定 API、路徑和方法設定事件層級的授權。

## 語法
<a name="sam-property-statemachine-apistatemachineauth-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-apistatemachineauth-syntax.yaml"></a>

```
  [ApiKeyRequired](#sam-statemachine-apistatemachineauth-apikeyrequired): Boolean
  [AuthorizationScopes](#sam-statemachine-apistatemachineauth-authorizationscopes): List
  [Authorizer](#sam-statemachine-apistatemachineauth-authorizer): String
  [ResourcePolicy](#sam-statemachine-apistatemachineauth-resourcepolicy): ResourcePolicyStatement
```

## Properties
<a name="sam-property-statemachine-apistatemachineauth-properties"></a>

 `ApiKeyRequired`   <a name="sam-statemachine-apistatemachineauth-apikeyrequired"></a>
此 API、路徑和方法需要 API 金鑰。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AuthorizationScopes`   <a name="sam-statemachine-apistatemachineauth-authorizationscopes"></a>
要套用至此 API、路徑和方法的授權範圍。  
如果您已指定 `DefaultAuthorizer` 屬性套用的任何範圍，您指定的範圍將會覆寫它。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Authorizer`   <a name="sam-statemachine-apistatemachineauth-authorizer"></a>
特定狀態機器`Authorizer`的 。  
如果您已指定 API 的全域授權方，並想要將此狀態機器設為公有，請將 `Authorizer`設定為 以覆寫全域授權方`NONE`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ResourcePolicy`   <a name="sam-statemachine-apistatemachineauth-resourcepolicy"></a>
設定此 API 和路徑的資源政策。  
*類型*：[ResourcePolicyStatement](sam-property-statemachine-resourcepolicystatement.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-statemachine-apistatemachineauth--examples"></a>

### StateMachine-Auth
<a name="sam-property-statemachine-apistatemachineauth--examples--statemachine-auth"></a>

下列範例會在狀態機器層級指定授權。

#### YAML
<a name="sam-property-statemachine-apistatemachineauth--examples--statemachine-auth--yaml"></a>

```
Auth:
  ApiKeyRequired: true
  Authorizer: NONE
```

# ResourcePolicyStatement
<a name="sam-property-statemachine-resourcepolicystatement"></a>

為 API 的所有方法和路徑設定資源政策。如需資源政策的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API Gateway 資源政策控制對 API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies.html)。 **

## 語法
<a name="sam-property-statemachine-resourcepolicystatement-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-resourcepolicystatement-syntax.yaml"></a>

```
  [AwsAccountBlacklist](#sam-statemachine-resourcepolicystatement-awsaccountblacklist): List
  [AwsAccountWhitelist](#sam-statemachine-resourcepolicystatement-awsaccountwhitelist): List
  [CustomStatements](#sam-statemachine-resourcepolicystatement-customstatements): List
  [IntrinsicVpcBlacklist](#sam-statemachine-resourcepolicystatement-intrinsicvpcblacklist): List
  [IntrinsicVpcWhitelist](#sam-statemachine-resourcepolicystatement-intrinsicvpcwhitelist): List
  [IntrinsicVpceBlacklist](#sam-statemachine-resourcepolicystatement-intrinsicvpceblacklist): List
  [IntrinsicVpceWhitelist](#sam-statemachine-resourcepolicystatement-intrinsicvpcewhitelist): List
  [IpRangeBlacklist](#sam-statemachine-resourcepolicystatement-iprangeblacklist): List
  [IpRangeWhitelist](#sam-statemachine-resourcepolicystatement-iprangewhitelist): List
  [SourceVpcBlacklist](#sam-statemachine-resourcepolicystatement-sourcevpcblacklist): List
  [SourceVpcWhitelist](#sam-statemachine-resourcepolicystatement-sourcevpcwhitelist): List
```

## Properties
<a name="sam-property-statemachine-resourcepolicystatement-properties"></a>

 `AwsAccountBlacklist`   <a name="sam-statemachine-resourcepolicystatement-awsaccountblacklist"></a>
要封鎖 AWS 的帳戶。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AwsAccountWhitelist`   <a name="sam-statemachine-resourcepolicystatement-awsaccountwhitelist"></a>
要允許 AWS 的帳戶。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `CustomStatements`   <a name="sam-statemachine-resourcepolicystatement-customstatements"></a>
要套用至此 API 的自訂資源政策陳述式清單。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IntrinsicVpcBlacklist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcblacklist"></a>
要封鎖的虛擬私有雲端 (VPCs) 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpcWhitelist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcwhitelist"></a>
要允許的 VPCs 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceBlacklist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpceblacklist"></a>
要封鎖的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceWhitelist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcewhitelist"></a>
要允許的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeBlacklist`   <a name="sam-statemachine-resourcepolicystatement-iprangeblacklist"></a>
要封鎖的 IP 地址或地址範圍。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeWhitelist`   <a name="sam-statemachine-resourcepolicystatement-iprangewhitelist"></a>
要允許的 IP 地址或地址範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SourceVpcBlacklist`   <a name="sam-statemachine-resourcepolicystatement-sourcevpcblacklist"></a>
要封鎖的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceVpcWhitelist`   <a name="sam-statemachine-resourcepolicystatement-sourcevpcwhitelist"></a>
要允許的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-statemachine-resourcepolicystatement--examples"></a>

### 資源政策範例
<a name="sam-property-statemachine-resourcepolicystatement--examples--resource-policy-example"></a>

下列範例會封鎖兩個 IP 地址和來源 VPC，並允許 AWS 帳戶。

#### YAML
<a name="sam-property-statemachine-resourcepolicystatement--examples--resource-policy-example--yaml"></a>

```
Auth:
  ResourcePolicy:
    CustomStatements: [{
                         "Effect": "Allow",
                         "Principal": "*",
                         "Action": "execute-api:Invoke",
                         "Resource": "execute-api:/Prod/GET/pets",
                         "Condition": {
                           "IpAddress": {
                             "aws:SourceIp": "1.2.3.4"
                           }
                         }
                       }]
    IpRangeBlacklist:
      - "10.20.30.40"
      - "1.2.3.4"
    SourceVpcBlacklist:
      - "vpce-1a2b3c4d"
    AwsAccountWhitelist:
      - "111122223333"
    IntrinsicVpcBlacklist:
      - "{{resolve:ssm:SomeVPCReference:1}}" 
      - !Ref MyVPC
    IntrinsicVpceWhitelist:
      - "{{resolve:ssm:SomeVPCEReference:1}}" 
      - !Ref MyVPCE
```

# CloudWatchEvent
<a name="sam-property-statemachine-statemachinecloudwatchevent"></a>

描述`CloudWatchEvent`事件來源類型的物件。

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) 資源。

**重要注意事項**： [EventBridgeRule](sam-property-statemachine-statemachineeventbridgerule.md)是要使用的慣用事件來源類型，而不是 `CloudWatchEvent`。 `EventBridgeRule` 和 `CloudWatchEvent`會使用相同的基礎服務、API CloudFormation 和資源。不過， AWS SAM 只會將新功能的支援新增至 `EventBridgeRule`。

## 語法
<a name="sam-property-statemachine-statemachinecloudwatchevent-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachinecloudwatchevent-syntax.yaml"></a>

```
  [EventBusName](#sam-statemachine-statemachinecloudwatchevent-eventbusname): String
  [Input](#sam-statemachine-statemachinecloudwatchevent-input): String
  [InputPath](#sam-statemachine-statemachinecloudwatchevent-inputpath): String
  [Pattern](#sam-statemachine-statemachinecloudwatchevent-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
```

## Properties
<a name="sam-property-statemachine-statemachinecloudwatchevent-properties"></a>

 `EventBusName`   <a name="sam-statemachine-statemachinecloudwatchevent-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachinecloudwatchevent-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)` 屬性。

 `InputPath`   <a name="sam-statemachine-statemachinecloudwatchevent-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

 `Pattern`   <a name="sam-statemachine-statemachinecloudwatchevent-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples"></a>

### CloudWatchEvent
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples--cloudwatchevent"></a>

以下是`CloudWatchEvent`事件來源類型的範例。

#### YAML
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples--cloudwatchevent--yaml"></a>

```
CWEvent:
  Type: CloudWatchEvent
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - running
```

# EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule"></a>

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

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) 資源。

## 語法
<a name="sam-property-statemachine-statemachineeventbridgerule-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachineeventbridgerule-syntax.yaml"></a>

```
  DeadLetterConfig: DeadLetterConfig
  EventBusName: String
  Input: String
  InputPath: String
  InputTransformer: [InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)
  Pattern: [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  RetryPolicy: [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)
  RuleName: String
  State: String
  Target: Target
```

## Properties
<a name="sam-property-statemachine-statemachineeventbridgerule-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineeventbridgerule-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)。  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinedeadletterconfig.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 建立無效字母佇列。

 `EventBusName`   <a name="sam-statemachine-statemachineeventbridgerule-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachineeventbridgerule-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)` 屬性。

 `InputPath`   <a name="sam-statemachine-statemachineeventbridgerule-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

`InputTransformer`  <a name="sam-statemachine-statemachineeventbridgerule-inputtransformer"></a>
此設定能讓您以特定事件資料為基礎，向目標提供自訂輸入。您可從事件擷取一或多組鍵/值對，然後使用該資料將自訂輸入傳送至目標。如需詳細資訊，請參閱[《Amazon EventBridge 使用者指南》中的 Amazon EventBridge 輸入轉換](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。 * EventBridge *  
*類型*：[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputtransformer)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule``Target`資料類型的 `[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html) ` 屬性。

 `Pattern`   <a name="sam-statemachine-statemachineeventbridgerule-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineeventbridgerule-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)` 屬性。

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

`State`  <a name="sam-statemachine-statemachineeventbridgerule-state"></a>
規則的狀態。  
*有效值*：`[ DISABLED | ENABLED ]`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。

 `Target`   <a name="sam-statemachine-statemachineeventbridgerule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-statemachine-statemachinetarget.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-statemachine-statemachineeventbridgerule--examples"></a>

### EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule"></a>

以下是`EventBridgeRule`事件來源類型的範例。

#### YAML
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule--yaml"></a>

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - terminated
```

# DeadLetterConfig
<a name="sam-property-statemachine-statemachinedeadletterconfig"></a>

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

## 語法
<a name="sam-property-statemachine-statemachinedeadletterconfig-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachinedeadletterconfig-syntax.yaml"></a>

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

## Properties
<a name="sam-property-statemachine-statemachinedeadletterconfig-properties"></a>

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

 `Type`   <a name="sam-statemachine-statemachinedeadletterconfig-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-statemachine-statemachinedeadletterconfig--examples"></a>

### DeadLetterConfig
<a name="sam-property-statemachine-statemachinedeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-statemachine-statemachinedeadletterconfig--examples--deadletterconfig--yaml"></a>

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

# Target
<a name="sam-property-statemachine-statemachinetarget"></a>

設定觸發規則時 EventBridge 叫用 AWS 的資源。

## 語法
<a name="sam-property-statemachine-statemachinetarget-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachinetarget-syntax.yaml"></a>

```
  [Id](#sam-statemachine-statemachinetarget-id): String
```

## Properties
<a name="sam-property-statemachine-statemachinetarget-properties"></a>

 `Id`   <a name="sam-statemachine-statemachinetarget-id"></a>
目標的邏輯 ID。  
的值`Id`可以包含英數字元、句點 (`.`)、連字號 (`-`) 和底線 ()`_`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[Id](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-id)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinetarget--examples"></a>

### Target
<a name="sam-property-statemachine-statemachinetarget--examples--target"></a>

#### YAML
<a name="sam-property-statemachine-statemachinetarget--examples--target--yaml"></a>

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Target:
      Id: MyTarget
```

# Schedule
<a name="sam-property-statemachine-statemachineschedule"></a>

描述`Schedule`事件來源類型的物件，這會將您的狀態機器設定為依排程觸發之 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) 資源。

## 語法
<a name="sam-property-statemachine-statemachineschedule-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachineschedule-syntax.yaml"></a>

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

## Properties
<a name="sam-property-statemachine-statemachineschedule-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineschedule-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)。  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinescheduledeadletterconfig.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-statemachine-statemachineschedule-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-statemachine-statemachineschedule-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-statemachine-statemachineschedule-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-statemachine-statemachineschedule-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-statemachine-statemachineschedule-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)` 屬性。

 `RoleArn`   <a name="sam-statemachine-statemachineschedulev-rolearn"></a>
調用排程時EventBridge 排程器用於目標的 IAM 角色 ARN。  
*類型*：[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)  
*必要*：否。如果未提供，則會建立新的角色並使用。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)` 屬性。

 `Schedule`   <a name="sam-statemachine-statemachineschedule-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-statemachine-statemachineschedule-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)` 屬性。

 `Target`   <a name="sam-statemachine-statemachineschedule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-statemachine-statemachinetarget.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-statemachine-statemachineschedule--examples"></a>

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

CloudWatch 排程事件範例

#### YAML
<a name="sam-property-statemachine-statemachineschedule--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-statemachine-statemachinescheduledeadletterconfig"></a>

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

## 語法
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig-syntax.yaml"></a>

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

## Properties
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig-properties"></a>

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

 `Type`   <a name="sam-statemachine-statemachinescheduledeadletterconfig-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-statemachine-statemachinescheduledeadletterconfig--examples"></a>

### DeadLetterConfig
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig--examples--deadletterconfig--yaml"></a>

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

# Target
<a name="sam-property-statemachine-statemachinescheduletarget"></a>

設定觸發規則時 EventBridge 叫用 AWS 的資源。

## 語法
<a name="sam-property-statemachine-statemachinescheduletarget-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachinescheduletarget-syntax.yaml"></a>

```
  [Id](#sam-statemachine-statemachinescheduletarget-id): String
```

## Properties
<a name="sam-property-statemachine-statemachinescheduletarget-properties"></a>

 `Id`   <a name="sam-statemachine-statemachinescheduletarget-id"></a>
目標的邏輯 ID。  
的值`Id`可以包含英數字元、句點 (`.`)、連字號 (`-`) 和底線 ()`_`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[Id](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-id)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinescheduletarget--examples"></a>

### Target
<a name="sam-property-statemachine-statemachinescheduletarget--examples--target"></a>

#### YAML
<a name="sam-property-statemachine-statemachinescheduletarget--examples--target--yaml"></a>

```
EBRule:
  Type: Schedule
  Properties:
    Target:
      Id: MyTarget
```

# ScheduleV2
<a name="sam-property-statemachine-statemachineschedulev2"></a>

描述`ScheduleV2`事件來源類型的物件，會將您的狀態機器設定為排程觸發的 Amazon EventBridge 排程器事件的目標。如需詳細資訊，請參閱《[EventBridge 排程器使用者指南》中的什麼是 Amazon EventBridge 排程器？](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)。 *EventBridge *

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

## 語法
<a name="sam-property-statemachine-statemachineschedulev2-syntax"></a>

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

### YAML
<a name="sam-property-statemachine-statemachineschedulev2-syntax.yaml"></a>

```
DeadLetterConfig: DeadLetterConfig
[Description](#sam-statemachine-statemachineschedulev2-description): String
[EndDate](#sam-statemachine-statemachineschedulev2-enddate): String
[FlexibleTimeWindow](#sam-statemachine-statemachineschedulev2-flexibletimewindow): FlexibleTimeWindow
[GroupName](#sam-statemachine-statemachineschedulev2-groupname): String
[Input](#sam-statemachine-statemachineschedulev2-input): String
[KmsKeyArn](#sam-statemachine-statemachineschedulev2-kmskeyarn): String
[Name](#sam-statemachine-statemachineschedulev2-name): String
OmitName: Boolean
[PermissionsBoundary](#sam-statemachine-statemachineschedulev2-permissionsboundary): String
[RetryPolicy](#sam-statemachine-statemachineschedulev2-retrypolicy): RetryPolicy
[RoleArn](#sam-statemachine-statemachineschedulev2-rolearn): String
[ScheduleExpression](#sam-statemachine-statemachineschedulev2-scheduleexpression): String
[ScheduleExpressionTimezone](#sam-statemachine-statemachineschedulev2-scheduleexpressiontimezone): String
[StartDate](#sam-statemachine-statemachineschedulev2-startdate): String
[State](#sam-statemachine-statemachineschedulev2-state): String
```

## Properties
<a name="sam-property-statemachine-statemachineschedulev2-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineschedulev2-deadletterconfig"></a>
設定 Amazon Simple Queue Service (Amazon SQS) 佇列，EventBridge 會在目標呼叫失敗後傳送事件。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《[EventBridge 排程器使用者指南》中的為 EventBridge 排程器設定無效字母佇列](https://docs.aws.amazon.com/scheduler/latest/UserGuide/configuring-schedule-dlq.html)。 *EventBridge *  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinescheduledeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Scheduler::Schedule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `Description`   <a name="sam-statemachine-statemachineschedulev2-description"></a>
排程的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-description)` 屬性。

 `EndDate`   <a name="sam-statemachine-statemachineschedulev2-enddate"></a>
UTC 日期，排程可在此日期之前叫用其目標。視排程的週期運算式而定，叫用可能會在您指定的 **EndDate** 當天或之前停止。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[EndDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-enddate)` 屬性。

 `FlexibleTimeWindow`   <a name="sam-statemachine-statemachineschedulev2-flexibletimewindow"></a>
允許在其中叫用排程的時段組態。  
*類型*：[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-flexibletimewindow)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler.html#cfn-scheduler-schedule-flexibletimewindow)` 屬性。

 `GroupName`   <a name="sam-statemachine-statemachineschedulev2-groupname"></a>
要與此排程建立關聯的排程群組名稱。如果未定義，則會使用預設群組。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[GroupName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname)` 屬性。

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

 `KmsKeyArn`   <a name="sam-statemachine-statemachineschedulev2-kmskeyarn"></a>
KMS 金鑰的 ARN，將用於加密客戶資料。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-kmskeyarn)` 屬性。

 `Name`   <a name="sam-statemachine-statemachineschedulev2-name"></a>
排程的名稱。如果您未指定名稱， 會以 格式 AWS SAM 產生名稱`StateMachine-Logical-IDEvent-Source-Name`，並使用該 ID 做為排程名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-name)` 屬性。

`OmitName`  <a name="sam-statemachine-statemachineschedulev2-omitname"></a>
根據預設， AWS SAM 會產生並使用 *<State-machine-logical-ID><event-source-name>* 格式的排程名稱。將此屬性設定為 `true`，讓 CloudFormation 產生唯一的實體 ID，並改為將該 ID 用於排程名稱。  
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

 `PermissionsBoundary`   <a name="sam-statemachine-statemachineschedulev2-permissionsboundary"></a>
用來設定角色許可邊界的政策 ARN。  
如果`PermissionsBoundary`已定義 ， AWS SAM 會將相同的邊界套用至排程器排程的目標 IAM 角色。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineschedulev2-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)` 屬性。

 `RoleArn`   <a name="sam-statemachine-statemachineschedulev2-rolearn"></a>
調用排程時EventBridge 排程器用於目標的 IAM 角色 ARN。  
*類型*：[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)` 屬性。

 `ScheduleExpression`   <a name="sam-statemachine-statemachineschedulev2-scheduleexpression"></a>
排程表達式，可決定排程執行的時間和頻率。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpression)` 屬性。

 `ScheduleExpressionTimezone`   <a name="sam-statemachine-statemachineschedulev2-scheduleexpressiontimezone"></a>
計算排程運算式所使用的時區。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpressionTimezone](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpressiontimezone)` 屬性。

 `StartDate`   <a name="sam-statemachine-statemachineschedulev2-startdate"></a>
排程開始調用目標的日期，以 UTC 為單位。視排程的週期運算式而定，叫用可能會在您指定的 **StartDate** 當天或之後發生。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[StartDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-startdate)` 屬性。

 `State`   <a name="sam-statemachine-statemachineschedulev2-state"></a>
排程的狀態。  
*接受的值：* `DISABLED | ENABLED`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-state)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachineschedulev2--examples"></a>

### 定義 ScheduleV2 資源的基本範例
<a name="sam-property-statemachine-statemachineschedulev2--examples--example1"></a>

```
StateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    Name: MyStateMachine
    Events:
      ScheduleEvent:
        Type: ScheduleV2
        Properties:
          ScheduleExpression: "rate(1 minute)"
      ComplexScheduleEvent:
        Type: ScheduleV2
        Properties:
          ScheduleExpression: rate(1 minute)
          FlexibleTimeWindow:
            Mode: FLEXIBLE
            MaximumWindowInMinutes: 5
          StartDate: '2022-12-28T12:00:00.000Z'
          EndDate: '2023-01-28T12:00:00.000Z'
          ScheduleExpressionTimezone: UTC
          RetryPolicy:
            MaximumRetryAttempts: 5
            MaximumEventAgeInSeconds: 300
          DeadLetterConfig:
            Type: SQS
    DefinitionUri:
      Bucket: sam-sam-s3-demo-bucket
      Key: my-state-machine.asl.json
      Version: 3
    Policies:
      - LambdaInvokePolicy:
          FunctionName: !Ref MyFunction
```

# 為 產生 CloudFormation 資源 AWS SAM
<a name="sam-specification-generated-resources"></a>

本節提供處理 AWS SAM AWS 範本時所建立 CloudFormation 資源的詳細資訊。 AWS SAM 產生的 CloudFormation 資源集會因您指定的案例而有所不同。*案例*是範本檔案中指定的資源和屬性的 AWS SAM 組合。您可以參考範本檔案中其他位置產生的 CloudFormation 資源，類似於您在範本檔案中明確宣告的資源參考方式。

例如，如果您在 AWS SAM 範本檔案中指定`AWS::Serverless::Function`資源， AWS SAM 一律會產生`AWS::Lambda::Function`基本資源。如果您也指定選用`AutoPublishAlias`屬性，則 會 AWS SAM 另外產生 `AWS::Lambda::Version` `AWS::Lambda::Alias`和資源。

本節列出案例及其產生的 CloudFormation 資源，並說明如何參考 AWS SAM 範本檔案中產生的 CloudFormation 資源。

## 參考產生的 CloudFormation 資源
<a name="sam-specification-generated-resources-referencing"></a>

您有兩個選項可參考 AWS SAM 範本檔案中產生的 CloudFormation 資源，`LogicalId`或參考屬性。

### 參考 LogicalId 產生的 CloudFormation 資源
<a name="sam-specification-generated-resources-referencing-logicalid"></a>

每個 AWS SAM 產生的 CloudFormation 資源都有一個 `[LogicalId](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html#resources-section-structure-logicalid)`，這是範本檔案中唯一的英數字元 (A-Z、a-z、0-9) 識別符。 AWS SAM 會使用範本檔案中`LogicalIds` AWS SAM 的 資源的 來建構其產生的 CloudFormation 資源`LogicalIds`的 。您可以使用產生的 CloudFormation 資源`LogicalId`的 來存取範本檔案中該資源的屬性，就像 CloudFormation 您明確宣告的資源一樣。如需 CloudFormation 和 AWS SAM 範本`LogicalIds`中的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[資源](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html)。

**注意**  
部分產生的資源`LogicalIds`包含唯一的雜湊值，以避免命名空間衝突。這些資源`LogicalIds`的 會在建立堆疊時衍生。您只能在使用 AWS 管理主控台 AWS CLI或其中一個 AWS SDKs 建立堆疊之後擷取它們。我們不建議 參考這些資源，`LogicalId`因為雜湊值可能會變更。

### 透過可參考屬性參考產生的 CloudFormation 資源
<a name="sam-specification-generated-resources-referencing-referenceable-property"></a>

對於某些產生的資源， AWS SAM 會提供資源的 AWS SAM 可參考屬性。您可以使用此屬性來參考 AWS SAM 範本檔案中產生的 CloudFormation 資源及其屬性。

**注意**  
並非所有產生的 CloudFormation 資源都有可參考的屬性。對於這些資源，您必須使用 `LogicalId`。

## 產生的 CloudFormation 資源案例
<a name="sam-specification-generated-resources-scenarios"></a>

下表摘要說明組成產生 AWS SAM 資源之案例 CloudFormation 的資源和屬性。**案例**欄中的主題提供有關為該案例產生之額外 CloudFormation 資源 AWS SAM 的詳細資訊。


| AWS SAM 資源 | 基本 CloudFormation 資源 | 案例 | 
| --- | --- | --- | 
| AWS::Serverless::Api  | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::Application  | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::CapacityProvider  | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::Function | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::HttpApi | [AWS::ApiGatewayV2::Api](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::LayerVersion  | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::SimpleTable  | [AWS::DynamoDB::Table](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::StateMachine  | [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html) |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 

**Topics**
+ [參考產生的 CloudFormation 資源](#sam-specification-generated-resources-referencing)
+ [產生的 CloudFormation 資源案例](#sam-specification-generated-resources-scenarios)
+ [CloudFormation 指定 AWS::Serverless::Api 時產生的資源](sam-specification-generated-resources-api.md)
+ [CloudFormation 指定 AWS::Serverless::Application 時產生的資源](sam-specification-generated-resources-application.md)
+ [CloudFormation 指定 AWS::Serverless::CapacityProvider 時產生的資源](sam-specification-generated-resources-capacityprovider.md)
+ [CloudFormation 當您指定 時產生的資源 AWS::Serverless::Connector](sam-specification-generated-resources-connector.md)
+ [CloudFormation 指定 AWS::Serverless::Function 時產生的資源](sam-specification-generated-resources-function.md)
+ [CloudFormation 指定 AWS::Serverless::GraphQLApi 時產生的資源](sam-specification-generated-resources-graphqlapi.md)
+ [CloudFormation 指定 AWS::Serverless::HttpApi 時產生的資源](sam-specification-generated-resources-httpapi.md)
+ [CloudFormation 指定 AWS::Serverless::LayerVersion 時產生的資源](sam-specification-generated-resources-layerversion.md)
+ [CloudFormation 指定 AWS::Serverless::SimpleTable 時產生的資源](sam-specification-generated-resources-simpletable.md)
+ [CloudFormation 指定 AWS::Serverless::StateMachine 時產生的資源](sam-specification-generated-resources-statemachine.md)

# CloudFormation 指定 AWS::Serverless::Api 時產生的資源
<a name="sam-specification-generated-resources-api"></a>

指定 `AWS::Serverless::Api` 時， AWS Serverless Application Model (AWS SAM) 一律會產生`AWS::ApiGateway::RestApi`基本 CloudFormation 資源。此外，它也會一律產生 `AWS::ApiGateway::Stage`和 `AWS::ApiGateway::Deployment` 資源。

**`AWS::ApiGateway::RestApi`**  
*`LogicalId`: *`<api‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::ApiGateway::Stage`**  
*`LogicalId`: *`<api‑LogicalId><stage‑name>Stage`  
`<stage‑name>` 是 `StageName` 屬性設定為 的字串。例如，如果您將 `StageName`設定為 `Gamma`，則 `LogicalId`為 `MyRestApiGammaStage`。  
*可參考屬性： *`<api‑LogicalId>.Stage`

**`AWS::ApiGateway::Deployment`**  
*`LogicalId`: *`<api‑LogicalId>Deployment<sha>`  
`<sha>` 是建立堆疊時產生的唯一雜湊值。例如 `MyRestApiDeployment926eeb5ff1`。  
*可參考屬性： *`<api‑LogicalId>.Deployment`

除了這些 CloudFormation 資源之外，指定 `AWS::Serverless::Api` 時， 還會為下列案例 AWS SAM 產生其他 CloudFormation 資源。

**Topics**
+ [已指定 DomainName 屬性](#sam-specification-generated-resources-api-domain-name)
+ [已指定 UsagePlan 屬性](#sam-specification-generated-resources-api-usage-plan)

## 已指定 DomainName 屬性
<a name="sam-specification-generated-resources-api-domain-name"></a>

`AWS::Serverless::Api` 指定 `DomainName`的 `Domain` 屬性時， AWS SAM 會產生 `AWS::ApiGateway::DomainName` CloudFormation 資源。

**`AWS::ApiGateway::DomainName`**  
*`LogicalId`: *`ApiGatewayDomainName<sha>`  
`<sha>` 是建立堆疊時產生的唯一雜湊值。例如：`ApiGatewayDomainName926eeb5ff1`。  
*可參考屬性： *`<api‑LogicalId>.DomainName`

## 已指定 UsagePlan 屬性
<a name="sam-specification-generated-resources-api-usage-plan"></a>

`AWS::Serverless::Api` 指定 `UsagePlan`的 `Auth` 屬性時， AWS SAM 會產生下列 CloudFormation 資源：`AWS::ApiGateway::UsagePlan`、 `AWS::ApiGateway::UsagePlanKey`和 `AWS::ApiGateway::ApiKey`。

**`AWS::ApiGateway::UsagePlan`**  
*`LogicalId`: *`<api‑LogicalId>UsagePlan`  
*可參考屬性： *`<api‑LogicalId>.UsagePlan`

**`AWS::ApiGateway::UsagePlanKey`**  
*`LogicalId`: *`<api‑LogicalId>UsagePlanKey`  
*可參考屬性： *`<api‑LogicalId>.UsagePlanKey`

**`AWS::ApiGateway::ApiKey`**  
*`LogicalId`: *`<api‑LogicalId>ApiKey`  
*可參考屬性： *`<api‑LogicalId>.ApiKey`

# CloudFormation 指定 AWS::Serverless::Application 時產生的資源
<a name="sam-specification-generated-resources-application"></a>

指定 `AWS::Serverless::Application` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::CloudFormation::Stack`基本 CloudFormation 資源。

**`AWS::CloudFormation::Stack`**  
*`LogicalId`: *`<application‑LogicalId>`   
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

# CloudFormation 指定 AWS::Serverless::CapacityProvider 時產生的資源
<a name="sam-specification-generated-resources-capacityprovider"></a>

指定 `AWS::Serverless::CapacityProvider` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::Lambda::CapacityProvider`基本 CloudFormation 資源。

**`AWS::Lambda::CapacityProvider`**  
*`LogicalId`: *`<capacityprovider‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

除了此 CloudFormation 資源之外，`AWS::Serverless::CapacityProvider`指定 時， AWS SAM 也會為下列案例產生 CloudFormation 資源：

**Topics**
+ [未指定 OperatorRole 屬性](#sam-specification-generated-resources-capacityprovider-iam-role)

## 未指定 OperatorRole 屬性
<a name="sam-specification-generated-resources-capacityprovider-iam-role"></a>

`AWS::Serverless::CapacityProvider` *未*指定 的 `OperatorRole` 屬性時， AWS SAM 會產生已連接 `AWSLambdaManagedEC2ResourceOperator`受管政策`AWS::IAM::Role` CloudFormation 的資源。

**`AWS::IAM::Role`**  
*`LogicalId`: *`<capacityprovider‑LogicalId>OperatorRole`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

# CloudFormation 當您指定 時產生的資源 AWS::Serverless::Connector
<a name="sam-specification-generated-resources-connector"></a>

**注意**  
當您透過內嵌`Connectors`屬性定義連接器時，它會先轉換為 `AWS::Serverless::Connector` 資源，然後再產生這些資源。

當您在 AWS SAM 範本中指定 `AWS::Serverless::Connector` 資源時， 會視需要 AWS SAM 產生下列 AWS CloudFormation 資源。

**`AWS::IAM::ManagedPolicy`**  
 *`LogicalId`:*`<connector‑LogicalId>Policy`   
 *可參考屬性：*N/A （若要參考此 CloudFormation 資源，您必須使用 `LogicalId`。) 

**`AWS::SNS::TopicPolicy`**  
 *`LogicalId`:*`<connector‑LogicalId>TopicPolicy`   
 *可參考屬性：*N/A （若要參考此 CloudFormation 資源，您必須使用 `LogicalId`。) 

**`AWS::SQS::QueuePolicy`**  
 *`LogicalId`:*`<connector‑LogicalId>QueuePolicy`   
 *可參考屬性：*N/A （若要參考此 CloudFormation 資源，您必須使用 `LogicalId`。) 

**`AWS::Lambda::Permission`**  
 *`LogicalId`:*`<connector‑LogicalId><permission>LambdaPermission`   
 `<permission>` 是由 `Permissions` 屬性指定的許可。例如 `Write`。  
*可參考屬性：*N/A （若要參考此 CloudFormation 資源，您必須使用 `LogicalId`。) 

# CloudFormation 指定 AWS::Serverless::Function 時產生的資源
<a name="sam-specification-generated-resources-function"></a>

指定 `AWS::Serverless::Function` 時， AWS Serverless Application Model (AWS SAM) 一律會建立`AWS::Lambda::Function`基本 CloudFormation 資源。

**`AWS::Lambda::Function`**  
*`LogicalId`: *`<function‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

除了此 CloudFormation 資源之外，`AWS::Serverless::Function`指定 時， AWS SAM 也會為下列案例產生 CloudFormation 資源。

**Topics**
+ [核心函數屬性](#sam-specification-generated-resources-function-core-properties)
+ [事件來源](#sam-specification-generated-resources-function-event-sources)
+ [事件組態](#sam-specification-generated-resources-function-event-configuration)

## 核心函數屬性
<a name="sam-specification-generated-resources-function-core-properties"></a>

下列案例會根據核心函數屬性產生 CloudFormation 資源：

### 未指定角色屬性
<a name="sam-specification-generated-resources-function-not-role"></a>

`AWS::Serverless::Function` *未*指定 的 `Role` 屬性時， AWS SAM 會產生 `AWS::IAM::Role` CloudFormation 資源。

**`AWS::IAM::Role`**  
*`LogicalId`: *`<function‑LogicalId>Role`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定 AutoPublishAlias 屬性
<a name="sam-specification-generated-resources-function-autopublishalias"></a>

`AWS::Serverless::Function` 指定 的 `AutoPublishAlias` 屬性時， AWS SAM 會產生下列 CloudFormation 資源： `AWS::Lambda::Alias`和 `AWS::Lambda::Version`。

**`AWS::Lambda::Alias`**  
*`LogicalId`: *`<function‑LogicalId>Alias<alias‑name>`  
`<alias‑name>` 是設定為 `AutoPublishAlias` 的字串。例如，如果您將 `AutoPublishAlias`設定為 `live`，則 `LogicalId`為：*MyFunction* Alias*live*。  
*可參考屬性： *`<function‑LogicalId>.Alias`

**`AWS::Lambda::Version`**  
*`LogicalId`: *`<function‑LogicalId>Version<sha>`  
`<sha>` 是建立堆疊時產生的唯一雜湊值。例如，*MyFunction* Version*926eeb5ff1*。  
*可參考屬性： *`<function‑LogicalId>.Version`

如需 `AutoPublishAlias` 屬性的詳細資訊，請參閱 [ AWS::Serverless::Function 的屬性一節](sam-resource-function.md#sam-resource-function-properties)。

### 已指定 DeploymentPreference 屬性
<a name="sam-specification-generated-resources-function-deploymentpreference"></a>

`AWS::Serverless::Function` 指定 的 `DeploymentPreference` 屬性時， AWS SAM 會產生下列 CloudFormation 資源： `AWS::CodeDeploy::Application`和 `AWS::CodeDeploy::DeploymentGroup`。此外，如果*未*指定`DeploymentPreference`物件的 `Role` 屬性， AWS SAM 也會產生 `AWS::IAM::Role` CloudFormation 資源。

**`AWS::CodeDeploy::Application`**  
*`LogicalId`: *`ServerlessDeploymentApplication`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::CodeDeploy::DeploymentGroup`**  
*`LogicalId`: *`<function‑LogicalId>DeploymentGroup`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::IAM::Role`**  
*`LogicalId`: *`CodeDeployServiceRole`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定 FunctionUrlConfig 屬性
<a name="sam-specification-generated-resources-function-functionurlconfig"></a>

指定 `FunctionUrlConfig` 屬性時， 會根據 AWS SAM 產生不同的 CloudFormation 資源`AuthType`。

指定 `AuthType: NONE` 時， AWS SAM 會產生下列 CloudFormation 資源：

**`AWS::Lambda::Permission` （叫用存取）**  
*`LogicalId`: *`<function‑LogicalId>URLInvokeAllowPublicAccess`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::Lambda::Permission` （公開存取）**  
*`LogicalId`: *`<function‑LogicalId>UrlPublicPermissions`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::Lambda::Url`**  
*`LogicalId`: *`<function‑LogicalId>Url`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

指定 `AuthType: AWS_IAM` 時， 只會 AWS SAM 產生：

**`AWS::Lambda::Url`**  
*`LogicalId`: *`<function‑LogicalId>Url`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

如需 `FunctionUrlConfig` 屬性的詳細資訊，請參閱 [FunctionUrlConfig](sam-property-function-functionurlconfig.md)。

## 事件來源
<a name="sam-specification-generated-resources-function-event-sources"></a>

下列案例會根據事件來源產生 CloudFormation 資源：

### 已指定 Api 事件來源
<a name="sam-specification-generated-resources-function-api"></a>

當 的 `Event` 屬性`AWS::Serverless::Function`設定為 `Api`，但未**指定 `RestApiId` 屬性時， AWS SAM 會產生 `AWS::ApiGateway::RestApi` CloudFormation 資源。

**`AWS::ApiGateway::RestApi`**  
*`LogicalId`: *`ServerlessRestApi`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定 HttpApi 事件來源
<a name="sam-specification-generated-resources-function-httpapi"></a>

當 的 `Event` 屬性`AWS::Serverless::Function`設定為 `HttpApi`，但未**指定 `ApiId` 屬性時， AWS SAM 會產生 `AWS::ApiGatewayV2::Api` CloudFormation 資源。

**`AWS::ApiGatewayV2::Api`**  
*`LogicalId`: *`ServerlessHttpApi`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定串流事件來源
<a name="sam-specification-generated-resources-function-streaming"></a>

當 的 `Event` 屬性`AWS::Serverless::Function`設定為其中一個串流類型時， AWS SAM 會產生 `AWS::Lambda::EventSourceMapping` CloudFormation 資源。這適用於下列類型：`DynamoDB`、`Kinesis`、`MSK`、 `MQ`和 `SQS`。

**`AWS::Lambda::EventSourceMapping`**  
*`LogicalId`: *`<function‑LogicalId><event‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定事件橋接 （或事件匯流排） 事件來源
<a name="sam-specification-generated-resources-function-eventbridge"></a>

當 的 `Event` 屬性`AWS::Serverless::Function`設定為其中一個事件橋接 （或事件匯流排） 類型時， AWS SAM 會產生 `AWS::Events::Rule` CloudFormation 資源。這適用於下列類型：`EventBridgeRule`、 `Schedule`和 `CloudWatchEvents`。

**`AWS::Events::Rule`**  
*`LogicalId`: *`<function‑LogicalId><event‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

### 已指定 IotRule 事件來源
<a name="sam-specification-generated-resources-function-iotrule"></a>

當 的 `Event` 屬性`AWS::Serverless::Function`設定為 IoTRule 時， AWS SAM 會產生 `AWS::IoT::TopicRule` CloudFormation 資源。

**`AWS::IoT::TopicRule`**  
*`LogicalId`: *`<function‑LogicalId><event‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

## 事件組態
<a name="sam-specification-generated-resources-function-event-configuration"></a>

下列案例會根據事件組態產生 CloudFormation 資源：

### 針對 Amazon SNS 事件指定 OnSuccess （或 OnFailure) 屬性 Amazon SNS
<a name="sam-specification-generated-resources-function-sns-onsuccess"></a>

當`EventInvokeConfig``AWS::Serverless::Function`指定 之 屬性的 `DestinationConfig` 屬性 `OnSuccess`（或 `OnFailure`) 屬性，且目的地類型為 ，`SNS`但未**指定目的地 ARN 時， AWS SAM 會產生下列 CloudFormation 資源： `AWS::Lambda::EventInvokeConfig`和 `AWS::SNS::Topic`。

**`AWS::Lambda::EventInvokeConfig`**  
*`LogicalId`: *`<function‑LogicalId>EventInvokeConfig`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::SNS::Topic`**  
*`LogicalId`： *`<function‑LogicalId>OnSuccessTopic` （或 `<function‑LogicalId>OnFailureTopic`)  
*可參考屬性： *`<function‑LogicalId>.DestinationTopic`  
如果同時為 Amazon SNS 事件`OnFailure`指定 `OnSuccess`和 ，若要區分產生的資源，您必須使用 `LogicalId`。

### 針對 Amazon SQS 事件指定 OnSuccess （或 OnFailure) 屬性 Amazon SQS
<a name="sam-specification-generated-resources-function-sqs-onsuccess"></a>

當`AWS::Serverless::Function`指定 之 `DestinationConfig` 屬性的 `EventInvokeConfig` 屬性 `OnSuccess`（或 `OnFailure`) 屬性，且目的地類型為 ，`SQS`但未**指定目的地 ARN 時， AWS SAM 會產生下列 CloudFormation 資源： `AWS::Lambda::EventInvokeConfig`和 `AWS::SQS::Queue`。

**`AWS::Lambda::EventInvokeConfig`**  
*`LogicalId`: *`<function‑LogicalId>EventInvokeConfig`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::SQS::Queue`**  
*`LogicalId`：*`<function‑LogicalId>OnSuccessQueue`（或 `<function‑LogicalId>OnFailureQueue`)  
*可參考屬性： *`<function‑LogicalId>.DestinationQueue`  
如果同時為 Amazon SQS 事件`OnFailure`指定 `OnSuccess`和 ，若要區分產生的資源，您必須使用 `LogicalId`。

# CloudFormation 指定 AWS::Serverless::GraphQLApi 時產生的資源
<a name="sam-specification-generated-resources-graphqlapi"></a>

當您在 AWS Serverless Application Model (AWS SAM) 範本中指定 `AWS::Serverless::GraphQLApi` 資源時， AWS SAM 一律會建立下列基本 AWS CloudFormation 資源。

**`AWS::AppSync::DataSource`**  
*`LogicalId`: *`<graphqlapi-LogicalId><datasource-RelativeId><datasource-Type>DataSource`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::AppSync::FunctionConfiguration`**  
*`LogicalId`: *`<graphqlapi-LogicalId><function-RelativeId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::AppSync::GraphQLApi`**  
*`LogicalId`: *`<graphqlapi-LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::AppSync::GraphQLSchema`**  
*`LogicalId`: *`<graphqlapi-LogicalId>Schema`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

**`AWS::AppSync::Resolver`**  
*`LogicalId`: *`<graphqlapi-LogicalId><OperationType><resolver-RelativeId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

除了這些 CloudFormation 資源之外，`AWS::Serverless::GraphQLApi`指定 時， AWS SAM 也可能會產生下列 CloudFormation 資源。

`AWS::AppSync::ApiCache`  
*`LogicalId`: *`<graphqlapi-LogicalId>ApiCache`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

`AWS::AppSync::ApiKey`  
*`LogicalId`: *`<graphqlapi-LogicalId><apikey-RelativeId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

`AWS::AppSync::DomainName`  
*`LogicalId`: *`<graphqlapi-LogicalId>DomainName`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

`AWS::AppSync::DomainNameApiAssociation`  
*`LogicalId`: *`<graphqlapi-LogicalId>DomainNameApiAssociation`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

AWS SAM 也可以使用 `AWS::Serverless::Connector` 資源來佈建許可。如需詳細資訊，請參閱[CloudFormation 當您指定 時產生的資源 AWS::Serverless::Connector](sam-specification-generated-resources-connector.md)。

# CloudFormation 指定 AWS::Serverless::HttpApi 時產生的資源
<a name="sam-specification-generated-resources-httpapi"></a>

指定 `AWS::Serverless::HttpApi` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::ApiGatewayV2::Api`基本 CloudFormation 資源。

**`AWS::ApiGatewayV2::Api`**  
*`LogicalId`: *`<httpapi‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

除了此 CloudFormation 資源之外，`AWS::Serverless::HttpApi`指定 時， AWS SAM 也會為下列案例產生 CloudFormation 資源：

**Topics**
+ [已指定 StageName 屬性](#sam-specification-generated-resources-httpapi-stage-name)
+ [*未*指定 StageName 屬性](#sam-specification-generated-resources-httpapi-not-stage-name)
+ [已指定 DomainName 屬性](#sam-specification-generated-resources-httpapi-domain-name)

## 已指定 StageName 屬性
<a name="sam-specification-generated-resources-httpapi-stage-name"></a>

`AWS::Serverless::HttpApi` 指定 的 `StageName` 屬性時， AWS SAM 會產生 `AWS::ApiGatewayV2::Stage` CloudFormation 資源。

**`AWS::ApiGatewayV2::Stage`**  
*`LogicalId`: *`<httpapi‑LogicalId><stage‑name>Stage`  
`<stage‑name>` 是 `StageName` 屬性設定為 的字串。例如，如果您將 `StageName`設定為 `Gamma`，則 `LogicalId`為：*MyHttpApiGamma* Stage。  
*可參考屬性： *`<httpapi‑LogicalId>.Stage`

## *未*指定 StageName 屬性
<a name="sam-specification-generated-resources-httpapi-not-stage-name"></a>

`AWS::Serverless::HttpApi` *未*指定 的 `StageName` 屬性時， AWS SAM 會產生 `AWS::ApiGatewayV2::Stage` CloudFormation 資源。

**`AWS::ApiGatewayV2::Stage`**  
*`LogicalId`: *`<httpapi‑LogicalId>ApiGatewayDefaultStage`  
*可參考屬性： *`<httpapi‑LogicalId>.Stage`

## 已指定 DomainName 屬性
<a name="sam-specification-generated-resources-httpapi-domain-name"></a>

`AWS::Serverless::HttpApi` 指定 `DomainName`的 `Domain` 屬性時， AWS SAM 會產生 `AWS::ApiGatewayV2::DomainName` CloudFormation 資源。

**`AWS::ApiGatewayV2::DomainName`**  
*`LogicalId`: *`ApiGatewayDomainNameV2<sha>`  
`<sha>` 是建立堆疊時產生的唯一雜湊值。例如，`ApiGatewayDomainNameV2`*926eeb5ff1*。  
*可參考屬性： *`<httpapi‑LogicalId>.DomainName`

# CloudFormation 指定 AWS::Serverless::LayerVersion 時產生的資源
<a name="sam-specification-generated-resources-layerversion"></a>

指定 `AWS::Serverless::LayerVersion` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::Lambda::LayerVersion`基本 CloudFormation 資源。

**`AWS::Lambda::LayerVersion`**  
*`LogicalId`: *`<layerversion‑LogicalId>`   
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

# CloudFormation 指定 AWS::Serverless::SimpleTable 時產生的資源
<a name="sam-specification-generated-resources-simpletable"></a>

指定 `AWS::Serverless::SimpleTable` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::DynamoDB::Table`基本 CloudFormation 資源。

**`AWS::DynamoDB::Table`**  
*`LogicalId`: *`<simpletable‑LogicalId>`   
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

# CloudFormation 指定 AWS::Serverless::StateMachine 時產生的資源
<a name="sam-specification-generated-resources-statemachine"></a>

指定 `AWS::Serverless::StateMachine` 時， AWS Serverless Application Model (AWS SAM) 會產生`AWS::StepFunctions::StateMachine`基本 CloudFormation 資源。

**`AWS::StepFunctions::StateMachine`**  
*`LogicalId`: *`<statemachine‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

除了此 CloudFormation 資源之外，`AWS::Serverless::StateMachine`指定 時， AWS SAM 也會為下列案例產生 CloudFormation 資源：

**Topics**
+ [未指定角色屬性](#sam-specification-generated-resources-statemachine-not-role)
+ [已指定 API 事件來源](#sam-specification-generated-resources-statemachine-api)
+ [已指定事件橋接 （或事件匯流排） 事件來源](#sam-specification-generated-resources-statemachine-eventbridge)

## 未指定角色屬性
<a name="sam-specification-generated-resources-statemachine-not-role"></a>

`AWS::Serverless::StateMachine` *未*指定 的 `Role` 屬性時， AWS SAM 會產生 `AWS::IAM::Role` CloudFormation 資源。

**`AWS::IAM::Role`**  
*`LogicalId`: *`<statemachine‑LogicalId>Role`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

## 已指定 API 事件來源
<a name="sam-specification-generated-resources-statemachine-api"></a>

當 的 `Event` 屬性`AWS::Serverless::StateMachine`設定為 `Api`，但未**指定 `RestApiId` 屬性時， AWS SAM 會產生 `AWS::ApiGateway::RestApi` CloudFormation 資源。

**`AWS::ApiGateway::RestApi`**  
*`LogicalId`: *`ServerlessRestApi`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

## 已指定事件橋接 （或事件匯流排） 事件來源
<a name="sam-specification-generated-resources-statemachine-eventbridge"></a>

當 的 `Event` 屬性`AWS::Serverless::StateMachine`設定為其中一個事件橋接 （或事件匯流排） 類型時， AWS SAM 會產生 `AWS::Events::Rule` CloudFormation 資源。這適用於下列類型：`EventBridgeRule`、 `Schedule`和 `CloudWatchEvents`。

**`AWS::Events::Rule`**  
*`LogicalId`: *`<statemachine‑LogicalId><event‑LogicalId>`  
*可參考屬性：*N/A （您必須使用 `LogicalId`來參考此 CloudFormation 資源）

# 支援的資源屬性 AWS SAM
<a name="sam-specification-resource-attributes"></a>

資源屬性是您可以新增至 AWS SAM 和 CloudFormation 資源的屬性，以控制其他行為和關係。如需資源屬性的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[資源屬性參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-attribute-reference.html)。

AWS SAM 支援由 定義的資源屬性子集 CloudFormation。在支援的資源屬性中，有些只會複製到對應 CloudFormation 資源的基礎產生 AWS SAM 資源，有些則會複製到對應 CloudFormation 資源產生的所有產生 AWS SAM 資源。如需從對應 CloudFormation 資源產生 AWS SAM 之資源的詳細資訊，請參閱 [為 產生 CloudFormation 資源 AWS SAM](sam-specification-generated-resources.md)。

下表摘要說明 支援的資源屬性 AWS SAM，但需遵守下列[例外狀況](#sam-specification-resource-attributes-exceptions)內容。


| 資源屬性 | 目的地產生的資源 (s) | 
| --- | --- | 
|  ** [DependsOn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html) ** ** [中繼資料](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html) **1、2  |  僅限基本 CloudFormation 產生的資源。如需 AWS SAM 資源與基礎 CloudFormation 資源之間的映射資訊，請參閱 [產生的 CloudFormation 資源案例](sam-specification-generated-resources.md#sam-specification-generated-resources-scenarios)。  | 
| ** [條件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html) ** ** [DeletionPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html) ** ** [UpdateReplacePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html) **  |  來自對應 CloudFormation AWS SAM 資源的所有產生資源。如需所產生 CloudFormation 資源案例的資訊，請參閱 [產生的 CloudFormation 資源案例](sam-specification-generated-resources.md#sam-specification-generated-resources-scenarios)。  | 

**備註**：

1. 如需搭配 `Metadata` 資源類型使用 `AWS::Serverless::Function` 資源屬性的詳細資訊，請參閱 [在 中使用自訂執行期建置 Lambda 函數 AWS SAM](building-custom-runtimes.md)。

1. 如需搭配 `Metadata` 資源類型使用 `AWS::Serverless::LayerVersion` 資源屬性的詳細資訊，請參閱 [在 中建置 Lambda 層 AWS SAM](building-layers.md)。

## 例外狀況
<a name="sam-specification-resource-attributes-exceptions"></a>

上述資源屬性規則有許多例外狀況：
+ 對於 `AWS::Lambda::LayerVersion`， AWS SAM唯一的自訂欄位`DeletionPolicy`會為產生的 CloudFormation 資源`RetentionPolicy`設定 。其優先順序高於`DeletionPolicy`本身。如果兩者都未設定，則預設為 `DeletionPolicy` `Retain`。
+ 對於 `AWS::Lambda::Version`，如果`DeletionPolicy`未指定 ，則預設值為 `Retain`。
+ 對於`DeploymentPreferences`為無伺服器函數指定的 案例，資源屬性不會複製到下列產生的 CloudFormation 資源：
  + `AWS::CodeDeploy::Application`
  + `AWS::CodeDeploy::DeploymentGroup`
  + 為此案例建立`CodeDeployServiceRole`的 `AWS::IAM::Role`名稱
+ 如果您的 AWS SAM 範本包含多個具有隱含建立之 API 事件來源的函數，則函數將共用產生的`AWS::ApiGateway::RestApi`資源。在此案例中，如果函數具有不同的資源屬性，則對於產生的`AWS::ApiGateway::RestApi`資源， 會根據下列優先順序清單 AWS SAM 複製資源屬性：
  + `UpdateReplacePolicy`:

    1. `Retain`

    1. `Snapshot`

    1. `Delete`
  + `DeletionPolicy`:

    1. `Retain`

    1. `Delete`

# 的 API Gateway 擴充功能 AWS SAM
<a name="sam-specification-api-gateway-extensions"></a>

API Gateway 擴充功能專為 設計 AWS，提供額外的自訂功能，用於設計和管理 APIs。API Gateway 擴充功能是 OpenAPI 規格的擴充功能，可支援 AWS特定授權和 API Gateway 特定的 API 整合。如需 API Gateway 延伸模組的詳細資訊，請參閱 [ OpenAPI 的 API Gateway 延伸](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html)模組。

AWS SAM 支援 API Gateway 擴充功能的子集。若要查看 支援哪些 API Gateway 延伸 AWS SAM，請參閱下表。


|  |  | 
| --- |--- |
|  API Gateway 延伸模組  |  支援者 AWS SAM  | 
| [x-amazon-apigateway-any-method 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-any-method.html) | 是 | 
| [x-amazon-apigateway-api-key-source 屬性](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-api-key-source.html) | 否 | 
| [x-amazon-apigateway-auth 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-auth.html) | 是 | 
| [x-amazon-apigateway-authorizer 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html) | 是 | 
| [x-amazon-apigateway-authtype 屬性](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authtype.html) | 是 | 
| [x-amazon-apigateway-binary-media-types 屬性](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-binary-media-types.html) | 是 | 
| [x-amazon-apigateway-documentation 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-documentation.html) | 否 | 
| [x-amazon-apigateway-endpoint-configuration 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html) | 否 | 
| [x-amazon-apigateway-gateway-responses 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.html) | 是 | 
| [x-amazon-apigateway-gateway-responses.gatewayResponse 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.gatewayResponse.html) | 是 | 
| [x-amazon-apigateway-gateway-responses.responseParameters 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.responseParameters.html) | 是 | 
| [x-amazon-apigateway-gateway-responses.responseTemplates 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.responseTemplates.html) | 是 | 
| [x-amazon-apigateway-integration 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html) | 是 | 
| [x-amazon-apigateway-integration.requestTemplates 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-requestTemplates.html) | 是 | 
| [x-amazon-apigateway-integration.requestParameters 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-requestParameters.html) | 否 | 
| [x-amazon-apigateway-integration.responses 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-responses.html) | 是 | 
| [x-amazon-apigateway-integration.response 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-response.html) | 是 | 
| [x-amazon-apigateway-integration.responseTemplates 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-responseTemplates.html) | 是 | 
| [x-amazon-apigateway-integration.responseParameters 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration-responseParameters.html) | 是 | 
| [x-amazon-apigateway-request-validator 屬性](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validator.html) | 否 | 
| [x-amazon-apigateway-request-validators 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validators.html) | 否 | 
| [x-amazon-apigateway-request-validators.requestValidator 物件](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validators.requestValidator.html) | 否 | 

# 的內部 函數 AWS SAM
<a name="sam-specification-intrinsic-functions"></a>

內部函數是內建函數，可讓您將值指派給只能在執行期使用的屬性。 AWS SAM 對某些內部函數屬性的支援有限，因此無法解析某些內部函數。因此，我們建議您新增`AWS::LanguageExtensions`轉換來解決此問題。`AWS::LanguageExtensions` 是由 託管的巨集 CloudFormation ，可讓您使用預設不包含在 中的內部函數和其他功能 CloudFormation。

```
Transform:
  - AWS::LanguageExtensions
  - AWS::Serverless-2016-10-31
```

**注意**  
如果您在 CodeUri 屬性中使用內部函數， AWS SAM 將無法正確剖析值。請考慮改用`AWS::LanguageExtensions`轉換。  
如需詳細資訊，請參閱 [ AWS::Serverless::Function 的屬性一節](sam-resource-function.md#sam-resource-function-properties)。

如需內部函數的詳細資訊，請參閱*AWS CloudFormation 《 使用者指南*》中的[內部函數參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html)。