December 2019
Intermediate to advanced
382 pages
9h 43m
English
Lambda layers are a recent addition to the Lambda feature set and have already been built into the serverless.yml syntax. You learned about layers in a previous chapter.
To declare a layer in the Serverless Framework, we use a new top-level block called layers, as shown in the following code. We need to specify the path relative to the function's working directory. This is the directory that lambda will place the extracted files that were bundled in the layer in:
layers: layerName: path: /path/to/layer
This declares a layer. Now, we can attach it to a function. Notice that the reference to the layer means that our deploy command will look for that layer in our current serverless service. You'll also note that the framework capitalizes ...