Layer
Resource Overview
A Layer represents an AWS Lambda Layer. Layers allow you to share library code or other assets between your Lambda functions.
Event Subscription
The following resources can be subscribed to a Layer:
- Function
An event subscription wire (solid line) may be used to connect a Layer to a Function. In this case a reference to the Layer is added to the Function's configuration, and the Layer resources are included in the Function runtime environment upon deployment.
Configurable Properties
Logical ID
The unique identifier used to reference this resource in the stack template. Defining a custom Logical ID is recommended, as it allows you to quickly identify a resource and any associated sub-resources when working with your stack in AWS, or anywhere outside of the Stackery Dashboard. As a project grows, it becomes useful in quickly spotting this resource in template.yaml
or while viewing a stack in Template View mode.
The identifier you provide must contain only alphanumeric characters (A-Za-z0-9) and must be unique within the stack.
Default Logical ID Example: Layer2
Source Path
You can designate a specific path within the repository that houses the Layer's content. Layers are given an auto-generated name and stored within the 'src' folder by default. This folder is relative to the template location.
Build Method
An optional build method used to construct a your Layer contents. For example, if you set the build method to 'nodejs14.x', you should place a package.json in the directory named by 'Source Path'. During deployment, 'npm install' will be run in the 'Source Path' directory to set up the Layer contents. If no build method is specified, the contents of the Source Path directory will be used directly as the source of the Layer.
Delete Previous Version
When enabled, previous versions of the Layer will be deleted when new versions are deployed. Otherwise, previous versions are retained.
IAM Permissions
When connected by a service discovery wire (dashed wire), a Function or Docker Task will add the following IAM policy to its role and gain permission to access this resource.
No Permissions Added
Environment Variables
When connected by a service discovery wire (dashed wire), a Function or Docker Task will automatically populate and reference the following environment variables in order to interact with this resource.
No Environment Variables Added
Related AWS Documentation
AWS Documentation: AWS::Serverless::LayerVersion