aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.62k stars 1.01k forks source link

Enhance `chalice package` to support container-based lambdas #1821

Open areeves87 opened 2 years ago

areeves87 commented 2 years ago

related #1598

I would like to see an enhancement to the chalice package command which supports configuring image-based lambdas. Something like chalice package --use-containers.

I am aware that the package command supports --merge-templates which would allow us to override zip-based lambda fields with image-based lamda fields in the AWS::Serverless::Function section if you include the appropriate json snippet. But that still leaves creating the Dockerfile for the build/testing process. So ideally the --use-containers command would write out an image-based SAM template and a Dockerfile to build, test, and deploy the packaged lambda.

The logic for writing out the sam template could have logic similar to this comment I made to demo POC https://github.com/aws/chalice/issues/1598#issuecomment-917511355

Note that I am trying to limit the scope of this feature request to just the packaging command so that SAM can be leveraged for resource management (ECR, build/test, etc). Other work could handle implementation for a similar chalice deploy --use-containers command.

RogerWebb commented 1 year ago

https://gist.github.com/RogerWebb/99e93ae29bbe36e612ed9da62c62e54f

I made a deployer of my own using the "chalice package" function and modifying it's output to deploy the project as a Docker Image. Feel free to make use of it, and let me know if you end up polishing it up any and want to share back. It's a rough draft, but it works (on my machine, of course, lol)