Nice Guy
Nice Guy

Reputation: 165

Lambda Function as a Zip with Layer as a Docker Image?

My entire lambda functions architecture is built around the .zip package type. I create a separate layer.zip for dependencies that are shared across but it recently crossed the 250 MB limit.

I'm not keen on moving my lambda functions to docker container images.

But I can happily docker containerize my layers.

Is there any way to use create/use a docker container image as a layer and attach it to a .zip lambda function?

Does this serve as a solution to get past the 250 MB layer limit?

Look forward to any feedback and resources! :)

Upvotes: 0

Views: 1476

Answers (1)

Parsifal
Parsifal

Reputation: 4506

Short answer: no.

Longer answer: they're two different ways of implementing your Lambda. In the "traditional" style, your code is deployed into an AWS-managed runtime that invokes your functions. In the "container" style, your container must implement that runtime.

While I think that 250 MB is an indication that Lambda is the wrong technology choice, you can work-around it by downloading additional content into /tmp when your Lambda first starts.

This is easier for languages such as Python, where you can update sys.path on the fly. It's much less easy (but still doable) for languages like Java, where you'd need a "wrapper" function that then creates a classpath for the downloaded JARs.

It's also easier if the bulk of your Lambda is a static resource, like an ML model, rather than code.

Upvotes: 3

Related Questions