

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

# 為 產生 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 資源）