lambda-from-container/

directory
v0.0.0-...-e56c885 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2025 License: Apache-2.0

README

Lambda Function from Container

  • 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_image is 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_image is False, then a new container will be created using the Dockerfile from the the lambda-image sub-directory.
  • 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.

Deploy using CDK

Install CDK
  • cdk is a NodeJS app.
  • Install NodeJS.
  • Use npm to install cdk
sudo npm install -g --force cdk
Create Python Virtual Environment
python3 -m venv .venv
source .venv/bin/activate
Install Python-specific modules
  • Each service such as lambda (aws_cdk.aws_lambda) or ec2 (aws_cdk.aws_ec2), has its own module which must be defined in requirements.txt.
pip3 install -r requirements.txt
Create Cloudformation from CDK
cdk synth
View the generated Cloudformation
cat cdk.out/LambdaContainerFunctionStack.template.json
Deploy
cdk deploy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL