Docker on Lambda or Lambda on Docker?

Andy Jassy announced AWS Lambda Container Support on December 1st, 2020.

AWS Lambda now supports container images as a packaging format

You can now package and deploy AWS Lambda functions as a container image of up to 10 GB. Customers can start building functions as container images by using either a set of AWS base images for Lambda, or by using one of their preferred community or enterprise images.

Creating Lambda container images

You can package your Lambda function code and dependencies as a container image, using tools such as the Docker CLI. You can then upload the image to your container registry hosted on Amazon Elastic Container Registry (Amazon ECR). Note that you must create the Lambda function from the same account as the container registry in Amazon ECR.

AWS provides a set of open-source base images that you can use to create your container image. These base images include a runtime interface client to manage the interaction between Lambda and your function code.

Not sure yet how this differs from Fargate or whether this even makes sense at all, but a lot of people want to deploy Redwood with a Docker container without losing the simplicity of deploying with Lambda.

Fargate is a bit like running Lambda on Docker, whereas now we are able to run Docker on Lambda. For all we know running Docker on Lambda could just as easily be the worst of both worlds instead of the best, but seems worth investigating to find out.

The Serverless Application Model is the first AWS metaframework to offer support.

In this blog post, I walk through building a simple serverless application that uses Lambda functions packaged as container images with AWS SAM. I demonstrate creating a new application and highlight changes to the AWS SAM template specific to container image support.

I then cover building the image locally for debugging in addition to eventual deployment. Finally, I show using AWS SAM to handle packaging and deploying Lambda functions from a developer’s machine or a CI/CD pipeline.

If anyone is curious I recently created a simple proof of concept showing how to deploy a Docker image to ECR with the Serverless Framework and invoke it via AWS Lambda.

1 Like

Im using containers to run a couple bits and pieces that need more than just a node environment. Using sls too.

This might not be the best idea because I don’t know if I’m effectively relying on a porcelain feature of redwood’s but because yarn rw build api builds all ts files in the api folder, I’m including these files from the dist folder so my deploy is yarn rw build api && sls deploy for this part of the app. It’s nice being able to keep it all typescript.

For reference

Thank you @Irev-Dev for the links and details, I’m getting back on the containerizing Redwood train so any references and resources are extremely valuable and appreciated. There’s gonna be so many ways to do this cause of the split between the two sides, web and api.

I like the idea of only containerizing the api as a use case because it just requires one Dockerfile, so it makes a good self contained (ha!) example. I’ll likely write up some docs or a forum post to that effect, but I think most people are going to want their whole thing “contained” together with a Docker Compose file bringing it all together.

1 Like