Resource attributes supported by Amazon SAM - Amazon Serverless Application Model
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Resource attributes supported by Amazon SAM

Resource attributes are attributes that you can add to Amazon SAM and Amazon CloudFormation resources to control additional behaviors and relationships. For more information about resource attributes, see Resource Attribute Reference in the Amazon CloudFormation User Guide.

Amazon SAM support a subset of resource attributes that are defined by Amazon CloudFormation. Of the supported resource attributes, some are copied to only the base generated Amazon CloudFormation resource of the corresponding Amazon SAM resource, and some are copied to all generated Amazon CloudFormation resources resulting from the corresponding Amazon SAM resource. For more information about Amazon CloudFormation resources generated from corresponding Amazon SAM resources, see Generated Amazon CloudFormation resources.

The following table summarizes resource attribute support by Amazon SAM, subject to the Exceptions listed below.

Resource attributes Destination generated resource(s)

DependsOn

Metadata 1, 2

Base Amazon CloudFormation generated resource only. For information about the mapping between Amazon SAM resources and base Amazon CloudFormation resources, see Generated Amazon CloudFormation resource scenarios.

Condition

DeletionPolicy

UpdateReplacePolicy

All generated Amazon CloudFormation resources from the corresponding Amazon SAM resource. For information about scenarios for generated Amazon CloudFormation resources, see Generated Amazon CloudFormation resource scenarios.

Notes:

  1. For more information about using the Metadata resource attribute with the AWS::Serverless::Function resource type, see Building Lambda functions with custom runtimes.

  2. For more information about using the Metadata resource attribute with the AWS::Serverless::LayerVersion resource type, see Building Lambda layers.

Exceptions

There are a number of exceptions to the resource attribute rules described previously:

  • For AWS::Lambda::LayerVersion, the Amazon SAM-only custom field RetentionPolicy sets the DeletionPolicy for the generated Amazon CloudFormation resources. This has a higher precedence than DeletionPolicy itself. If neither is set, then by default DeletionPolicy is set to Retain.

  • For AWS::Lambda::Version, if DeletionPolicy is not specified, the default is Retain.

  • For the scenario where DeploymentPreferences is specified for a serverless function, resource attributes are not copied to the following generated Amazon CloudFormation resources:

    • AWS::CodeDeploy::Application

    • AWS::CodeDeploy::DeploymentGroup

    • The AWS::IAM::Role named CodeDeployServiceRole that is created for this scenario

  • If your Amazon SAM template contains multiple functions with API event sources that are implicitly created, then the functions will share the generated AWS::ApiGateway::RestApi resource. In this scenario, if the functions have different resource attributes, then for the generated AWS::ApiGateway::RestApi resource, Amazon SAM copies the resource attributes according to the following prioritized lists:

    • UpdateReplacePolicy:

      1. Retain

      2. Snapshot

      3. Delete

    • DeletionPolicy:

      1. Retain

      2. Delete