Layers upload on each deploy?


AWS Layers support was added in v1.34. How it seems to work right now is that every time you deploy your serverless app the layers are packaged and uploaded. However, this is not what I expected. I thought we would only want to upload/update the layer package if a file was added/removed or changed.

Is there a reason it is implemented this way? I think my deployment time would be cut down by a minute or two if we didn’t upload unchanged layers because some of my layers are large (100mb +) so they take a while to upload.


I agree. Also, every time a deploy is made, a new version of the layer is generated even if we don’t make any change to it.


You’re right about that. Looking into it now.

For the time being, one way to handle this is to have your layer & your service using the layer in different serverless projects.

In your service’s serverless.yml:

service: foobar
  name: aws
  language: python3.6
    handler: handler.hello
      - ${cf:foobar-layer-dev.FoobarLayerExport}

Then in a separate project managing your layer:

service: foobar-layer
  name: aws
    path: layer
          Ref: FoobarLambdaLayer
          Name: FoobarLambdaLayer


Update: I’ve tried tweaking the cloudformation template in subsequent uploads so that the layer definition is identical. But it still creates a new layer version. As such, the work around above is your best solution it seems.


+1, having layers deployed only when they change would be really nice. The ffmpeg example in the blog post is about 50MB, which is quite long to upload and layers could definitely be the solution to upload it only once.


+1, hope to keep this conversation alive. Redeploying layers every time seems to eliminate a huge advantage of using layers to begin with.