Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 6.43 KB

sam-resource-layerversion.md

File metadata and controls

97 lines (73 loc) · 6.43 KB

AWS::Serverless::LayerVersion

Creates a Lambda LayerVersion that contains library or runtime code needed by a Lambda Function.

The AWS::Serverless::LayerVersion resource also supports the Metadata resource attribute, so you can instruct AWS SAM to build layers included in your application. For more information about building layers, see Building layers.

Important Note: Since the release of the UpdateReplacePolicy resource attribute in AWS CloudFormation, AWS::Lambda::LayerVersion (recommended) offers the same benefits as AWS::Serverless::LayerVersion.

When a Serverless LayerVersion is transformed, SAM also transforms the logical id of the resource so that old LayerVersions are not automatically deleted by CloudFormation when the resource is updated.

Syntax

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

YAML

Type: AWS::Serverless::LayerVersion
Properties:
  [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
  [RetentionPolicy](#sam-layerversion-retentionpolicy): String

Properties

CompatibleRuntimes List of runtimes compatible with this LayerVersion.
Type: List
Required: No
AWS CloudFormation compatibility: This property is passed directly to the [CompatibleRuntimes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-compatibleruntimes) property of an AWS::Lambda::LayerVersion resource.

ContentUri AWS S3 Uri, path to local folder, or LayerContent object of the layer code.
If an AWS S3 Uri or LayerContent object is provided, The AWS S3 object referenced must be a valid ZIP archive that contains the contents of an AWS Lambda layer.
If a path to a local folder is provided, for the content to be transformed properly the template must go through the workflow that includes sam build followed by either sam deploy or sam package. By default, relative paths are resolved with respect to the AWS SAM template's location.
Type: String | LayerContent
Required: Yes
AWS CloudFormation compatibility: This property is similar to the [Content](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-content) property of an AWS::Lambda::LayerVersion resource. The nested Amazon S3 properties are named differently.

Description Description of this layer.
Type: String
Required: No
AWS CloudFormation compatibility: This property is passed directly to the [Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-description) property of an AWS::Lambda::LayerVersion resource.

LayerName The name or Amazon Resource Name (ARN) of the layer.
Type: String
Required: No
Default: Resource logical id
AWS CloudFormation compatibility: This property is similar to the [LayerName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-layername) property of an AWS::Lambda::LayerVersion resource. If you don't specify a name, the logical id of the resource will be used as the name.

LicenseInfo Information about the license for this LayerVersion.
Type: String
Required: No
AWS CloudFormation compatibility: This property is passed directly to the [LicenseInfo](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-layerversion.html#cfn-lambda-layerversion-licenseinfo) property of an AWS::Lambda::LayerVersion resource.

RetentionPolicy Specifies whether old versions of your LayerVersion are retained or deleted after an update.
Valid values: Retain or Delete
Type: String
Required: No
AWS CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an AWS CloudFormation equivalent.
Additional notes: When you specify Retain, AWS SAM adds a Resource attributes of DeletionPolicy: Retain to the transformed AWS::Lambda::LayerVersion resource.

Return Values

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, it returns the resource ARN of the underlying Lambda LayerVersion.

For more information about using the Ref function, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html in the AWS CloudFormation User Guide.

Examples

LayerVersionExample

Example of a LayerVersion

YAML

Properties:
  LayerName: MyLayer
  Description: Layer description
  ContentUri: 's3://my-bucket/my-layer.zip'
  CompatibleRuntimes:
    - nodejs10.x
    - nodejs12.x
  LicenseInfo: 'Available under the MIT-0 license.'
  RetentionPolicy: Retain