Support for Building Layers
SAM CLI now supports building layers specified in template by specifying BuildMethod
under a Metadata Attribute of the Layer Resource. If BuildMethod
is not specified, the layer is not built.
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.8
Layers:
- !Ref MyLayer
- !Ref MyLayer2
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
MyLayer:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Layer description
ContentUri: 'my_layer/'
CompatibleRuntimes:
- python3.8
Metadata:
BuildMethod: python3.8
MyLayer2:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Layer description
ContentUri: 'my_layer2/'
CompatibleRuntimes:
- python3.8
sam build MyLayer
build single layer.
sam build HelloWorldFunction
builds function and the layer that the function uses.
23212ef - Build for Layers (#1936)
de8ad8e - Adding design doc for 'build for layers' (#1945)
24af60e - chore: version bump to 0.50.0 (#1998)
30b1016 - bug: security prompt - instrinsics in definition body (#1988)