When I tried to deploy a container image from Amazon Elastic Container Registry (Amazon ECR) to my AWS Lambda function, I received an "InvalidParameterValueException" error message.
Short description
Lambda requires container images to conform to Docker Image Manifest V2 Schema 2 format. Lambda doesn't support Open Container Initiative (OCI) image index manifest lists or provenance attestations. By default, Docker Engine v29 and later versions add provenance attestations.
Resolution
Review the following resolutions based on your specific scenario.
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Build single-architecture images
Lambda doesn't support multi-architecture container images or OCI image index manifest lists. The final container image that you deploy to a Lambda function must target only one specific architecture.
To follow best practices for multiple architectures, take the following actions:
Turn off provenance attestations in Docker builds
Docker Buildx version 0.10+ and Docker Engine v29+ turn on provenance attestations by default. These attestations create manifest formats that Lambda doesn't support.
-
To turn off provenance, run the following command:
docker build --platform linux/amd64 --provenance=false -t your-image:tag .
Note: Replace your-image with your image name and tag with your image tag.
-
For builds that also generate software bill of materials (SBOM) attestations, run the following command to turn off both provenance and SBOM:
docker build --platform linux/amd64 --provenance=false --sbom=false -t your-image:tag .
-
After you build with these flags, push the image to ECR and update your Lambda function:
docker push example-registry/example-repository:example-tag
-
To update the function code, run the following update-function-code AWS CLI command:
aws lambda update-function-code --function-name example-function \
--image-uri example-registry/example-repository:example-tag
Note: Replace example-function with your function name, example-registry with your ECR registry URI, example-repository with your repository name, and example-tag with your image tag.
Configure GitHub Actions workflows
If you use GitHub Actions with the docker build-push-action, then you must turn off attestations. For more information, see build-push-action on the Docker website.
To turn off attestations, add these parameters to your workflow:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: your-image:tag
provenance: false
sbom: false
Reference specific image digests instead of tags
If you use Docker Buildx to build and push images to ECR with a tag like latest, then Docker creates an image index manifest list. The image index points to platform specific images, and Lambda tries to use the image index instead of the platform specific image. Then, the image index causes deployment to fail.
To resolve this issue, reference the specific SHA256 digest of the actual image instead of the tag.
Complete the following steps:
- Open the Amazon ECR console.
- In the navigation pane, under Private registry, choose, choose Repositories.
- Select your repository.
- Locate the specific image, and then check the Image manifest type column.
- Copy the SHA256 digest of the single-platform image manifest Docker Image Manifest V2 Schema 2 or OCI image manifest.
- To update your Lambda function with the image URI and the SHA256 digest, run the following update-function-code AWS CLI command:
aws lambda update-function-code --function-name example-function \
--image-uri example-registry/example-repository@sha256:example-digest
Note: Replace example-registry with your ECR private registry URI, example-repository with your repository name, and example-digest with the SHA256 digest you copied. Replace example-function with your Lambda function name.
Check image manifest format
To diagnose image structure issues and inspect the image manifest in ECR, run the following batch-get-image AWS CLI command:
aws ecr batch-get-image --repository-name example-repository \
--image-ids imageTag=latest --region us-east-1 \
--query 'images[].imageManifest' --output text | jq '.mediaType'
Note: Replace example-repository with your ECR repository name.
Additional troubleshooting
If you continue to experience issues after you use the preceding solutions, then take the following actions:
-
Confirm that your ECR repository and Lambda function are in the same AWS Region.
-
Make sure that you use Lambda compatible base images. AWS provides base Docker images for Lambda, such as:
FROM public.ecr.aws/lambda/python:3.12
-
To save and inspect the image locally to find unexpected layers or attestations, run the following command:
docker save your-image:tag -o image.tar
tar -tf image.tar
-
Confirm that there's a valid config.json and manifest.json file in your ECR repository and make sure that there isn't an attestations/ directory.
-
If your Lambda function enters a Failed state with a "StateReasonCode: InvalidImage" error message, then the container image format isn't compatible. Rebuild the image with --provenance=false, push the image to Amazon ECR, and then update your Lambda function with the new image.
-
Review AWS CloudTrail logs to get the specific error returned during deployment.
Related information
Create a Lambda function using a container image
Selecting and configuring an instruction set architecture for your Lambda function
docker image build on the Docker website
Container image manifest format support in Amazon ECR