-
AWS announced at re:Invent 2020 that Lambda Functions could now be deployed from Containers
-
Provisioning A Lambda function from a Container allows the establishment of a standardized Container-based build, and deployment, pipeline.
-
Lambda functions with large sets of dependencies will can be easier to package and deploy as a Container.
-
The Container Image is defined in
app.py.- If
use_pre_existing_imageis True, then it is expected that a Container Image was created elsewhere and will be used by this CDK code and that the image_name is the ECR Repo name. - If
use_pre_existing_imageis False, then a new container will be created using theDockerfilefrom the thelambda-imagesub-directory.
- If
-
After deploying the Lambda Function, go to the Lambda Dashboard, open the Lambda Function, and configure a test event.
- After running the test event, the output should be from the Lambda Function code compiled in to the Container Image.
- cdk is a NodeJS app.
- Install NodeJS.
- Use
npmto installcdk
sudo npm install -g --force cdkpython3 -m venv .venv
source .venv/bin/activate- Each service such as lambda (
aws_cdk.aws_lambda) or ec2 (aws_cdk.aws_ec2), has its own module which must be defined inrequirements.txt.
pip3 install -r requirements.txtcdk synthcat cdk.out/LambdaContainerFunctionStack.template.jsoncdk deploy
