Serverless-python-requirements: layer: retain: true doesn't seem to work

Created on 30 Aug 2019  路  3Comments  路  Source: UnitedIncome/serverless-python-requirements

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?

open-for-visibility

Most helpful comment

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nknotts picture nknotts  路  5Comments

doublemarked picture doublemarked  路  3Comments

amadensor picture amadensor  路  3Comments

brettdh picture brettdh  路  5Comments

jnicho02 picture jnicho02  路  6Comments