1 Answers
0
Accepted Answer
You could create a base image that contains all your shared dependencies (i.e. codec tools) and then reference this base image in the Dockerfile on your lambda functions. The base image should be built as a pre-requisite step and pushed to an ECR repository.
answered a month ago
Relevant questions
Lambda source code updating issue during its container image building via cdk
Accepted Answerasked a month agoProblem starting Docker image as lambda function source
asked 2 years agoLambda container and oci image manifest type
asked 2 months agoHow to create an container image and deploy it to an lambda function using CDK?
Accepted Answerasked a month ago"Container image support for Lambda" pricing with ECR
Accepted Answerasked 2 years agoLambda Container-Based Function Needs --privileged and --device /dev/fuse
Accepted Answerasked 2 months agoCDK NodejsFunction with Lambda Layer
asked a month agoUpdating /etc/hosts File in Lambda Container
asked 7 days ago"Error - ENOENT" while creating a lambda function via cdk
asked 21 days agoLambda function from container - Missing Parent Directory
asked 7 months ago
Would you mind pointing out how exactly to create a base image and then reference it in the lambda? I was making the base image by the
DockerImageAsset
fromaws-cdk-lib/aws-ecr-assets
, and then usingasset.imageUri
to reference it when creating a lambda, like the following:But I got an Error said:
Cannot use tokens in keys or values of "buildArgs" since they are needed before deployment
.Thanks!
The error you get from CDK is because the imageUri is only known at execution time, but the buildArgs are needed at synth time. You may need to separate the build of the base image in a separate process to have the base image pushed to a known ECR registry that can then be referenced from the lambda stack. The following construct could be used to publish the base image to ECR: https://github.com/cdklabs/cdk-ecr-deployment