Can a aws lambda be broken into two different layers which has common code?

Question:

I have a lambda functions which share common code. I am trying to remove the shared code into a layer but the size is greater than preferred limit. Is it possible to break a layer within two while keeping the code intact.

Asked By: Ajinkya Kulkarni

||

Answers:

yes, it exceeds 250 mb

The purpose of lambda is to be quick and lightweight and that comes with imposed limits.

If you really need to include very large files (data, libraries, ..) I see multiple options:

  • use a different deployment option (ec2, ecs, aws batch/..)
  • share the common data / libraries on an EFS and mount the filesystem to lambda
  • download data/libraries on demand e.g. from an S3 bucket
  • build your own lambda image

Every option has its own pros and cons and price, depending on your usage requirements and expectations what is the most feasible for you.

Answered By: gusto2