directory
Version:
v0.0.0-...-fa3ac1c
Opens a new window with list of versions in this module.
Published: Jan 25, 2024
License: Apache-2.0
Opens a new window with license information.
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.
- 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
cdk synth
cat cdk.out/LambdaContainerFunctionStack.template.json
Deploy
cdk deploy
Directories
¶
Click to show internal directories.
Click to hide internal directories.