

# Generated Amazon CloudFormation resources for Amazon SAM
<a name="sam-specification-generated-resources"></a>

This section provides details on the Amazon CloudFormation resources that are created when Amazon SAM processes your Amazon template. The set of Amazon CloudFormation resources that Amazon SAM generates differs depending on the scenarios you specify. A *scenario* is the combination of Amazon SAM resources and properties specified in your template file. You can reference the generated Amazon CloudFormation resources elsewhere within your template file, similar to how you reference resources that you declare explicitly in your template file.

For example, if you specify an `AWS::Serverless::Function` resource in your Amazon SAM template file, Amazon SAM always generates an `AWS::Lambda::Function` base resource. If you also specify the optional `AutoPublishAlias` property, Amazon SAM additionally generates `AWS::Lambda::Alias` and `AWS::Lambda::Version` resources.

This section lists the scenarios and the Amazon CloudFormation resources that they generate, and shows how to reference the generated Amazon CloudFormation resources in your Amazon SAM template file.

## Referencing generated Amazon CloudFormation resources
<a name="sam-specification-generated-resources-referencing"></a>

You have two options for referencing generated Amazon CloudFormation resources within your Amazon SAM template file, by `LogicalId` or by referenceable property.

### Referencing generated Amazon CloudFormation resources by LogicalId
<a name="sam-specification-generated-resources-referencing-logicalid"></a>

The Amazon CloudFormation resources that Amazon SAM generates each have a `[LogicalId](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/resources-section-structure.html#resources-section-structure-logicalid)`, which is an alphanumeric (A-Z, a-z, 0-9) identifier that is unique within a template file. Amazon SAM uses the `LogicalIds` of the Amazon SAM resources in your template file to construct the `LogicalIds` of the Amazon CloudFormation resources it generates. You can use the `LogicalId` of a generated Amazon CloudFormation resource to access properties of that resource within your template file, just like you would for an Amazon CloudFormation resource that you have explicitly declared. For more information about `LogicalIds` in Amazon CloudFormation and Amazon SAM templates, see [Resources](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/resources-section-structure.html) in the *Amazon CloudFormation User Guide*.

**Note**  
The `LogicalIds` of some generated resources include a unique hash value to avoid namespace clashes. The `LogicalIds` of these resources are derived when the stack is created. You can retrieve them only after the stack has been created using the Amazon Web Services Management Console, Amazon CLI, or one of the Amazon SDKs. We don't recommend referencing these resources by `LogicalId` because the hash values might change.

### Referencing generated Amazon CloudFormation resources by referenceable property
<a name="sam-specification-generated-resources-referencing-referenceable-property"></a>

For some generated resources, Amazon SAM provides a referenceable property of the Amazon SAM resource. You can use this property to reference a generated Amazon CloudFormation resource and its properties within your Amazon SAM template file.

**Note**  
Not all generated Amazon CloudFormation resources have referenceable properties. For those resources, you must use the `LogicalId`.

## Generated Amazon CloudFormation resource scenarios
<a name="sam-specification-generated-resources-scenarios"></a>

The following table summarizes the Amazon SAM resources and properties that make up the scenarios that generate Amazon CloudFormation resources. The topics in the **Scenarios** column provide details about the additional Amazon CloudFormation resources that Amazon SAM generates for that scenario.


| Amazon SAM resource | Base Amazon CloudFormation resource | Scenarios | 
| --- | --- | --- | 
| AWS::Serverless::Api  | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::Application  | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::CapacityProvider  | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::Function | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::HttpApi | [AWS::ApiGatewayV2::Api](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::LayerVersion  | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::SimpleTable  | [AWS::DynamoDB::Table](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 
| AWS::Serverless::StateMachine  | [https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html) |  [\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/en_us/serverless-application-model/latest/developerguide/sam-specification-generated-resources.html)  | 

**Topics**
+ [Referencing generated Amazon CloudFormation resources](#sam-specification-generated-resources-referencing)
+ [Generated Amazon CloudFormation resource scenarios](#sam-specification-generated-resources-scenarios)
+ [Amazon CloudFormation resources generated when AWS::Serverless::Api is specified](sam-specification-generated-resources-api.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::Application is specified](sam-specification-generated-resources-application.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::CapacityProvider is specified](sam-specification-generated-resources-capacityprovider.md)
+ [Amazon CloudFormation resources generated when you specify AWS::Serverless::Connector](sam-specification-generated-resources-connector.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::Function is specified](sam-specification-generated-resources-function.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::GraphQLApi is specified](sam-specification-generated-resources-graphqlapi.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::HttpApi is specified](sam-specification-generated-resources-httpapi.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::WebSocketApi is specified](sam-specification-generated-resources-websocketapi.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::LayerVersion is specified](sam-specification-generated-resources-layerversion.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::SimpleTable is specified](sam-specification-generated-resources-simpletable.md)
+ [Amazon CloudFormation resources generated when AWS::Serverless::StateMachine is specified](sam-specification-generated-resources-statemachine.md)