I've started a new package, that is purely to create a lambda layer and upload it - no actual code/functions, only the Layer.
I _think_ I'm supposed to use this kind of syntax:
service: sample-py37
frameworkVersion: ">=1.51.0 <2.0.0"
plugins:
- serverless-python-requirements
provider:
name: aws
runtime: python3.7
region: us-east-1
custom:
pythonRequirements:
dockerizePip: true
layer:
retain: true
But it doesn't appear to actually retain the older versions. Am I doing something wrong?
retain: true appears to be an option for the main serverless provider for layers, as opposed to the python-requirements plugin. I'm also curious how to emulate this behavior though.
I figured it out, since I had the same issue. What you actually want to do is this:
resources:
Resources:
PythonRequirementsLambdaLayer:
UpdateReplacePolicy: Retain
This will set the layer to retain previous versions of the layer when it updates, preventing your functions that are using the older layer from failing.
NOTE: This does mean you need to externally delete your unused layers or else they will linger.
This appears to be an issue in serverless, but we'll keep it open for visibility.
Most helpful comment
I figured it out, since I had the same issue. What you actually want to do is this:
This will set the layer to retain previous versions of the layer when it updates, preventing your functions that are using the older layer from failing.
NOTE: This does mean you need to externally delete your unused layers or else they will linger.