-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Describe what happened
When using docker_build.Image to build and push images to ECR for AWS Lambda functions, the ref output provides a format that AWS Lambda doesn't accept. The ref output returns repo:tag@sha256:digest, but AWS Lambda's imageUri parameter only accepts either:
- repo:tag (tag only)
- repo@sha256:digest (digest only)
Using the ref output directly causes Lambda to throw:
InvalidParameterValueException:
Source image <ACCT_ID>.dkr.ecr.us-east-1.amazonaws.com/<REPO_NAME>:latest@sha256:fd33b63053cbeabf0dc833cb4c19098f62625c382e7fd262063a54d59d5fbf51 is not valid. Provide a valid source image.
Sample program
import pulumi
import pulumi_aws as aws
import pulumi_docker_build as docker_build
from pulumi_aws.lambda_ import Function
# Create ECR repository
ecr_repo = aws.ecr.Repository("my-repo")
# Get ECR auth token
ecr_auth_token = aws.ecr.get_authorization_token_output()
# Build and push image
docker_image = docker_build.Image(
"my-image",
context={"location": "./app"},
dockerfile={"location": "./app/Dockerfile"},
platforms=["linux/arm64"],
push=True,
registries=[{
"address": ecr_repo.repository_url.apply(lambda url: url.split("/")[0]),
"password": ecr_auth_token.password,
"username": ecr_auth_token.user_name,
}],
tags=[ecr_repo.repository_url.apply(lambda url: f"{url}:latest")],
)
# This FAILS with InvalidParameterValueException
lambda_func = Function(
"my-lambda",
package_type="Image",
image_uri=docker_image.ref, # Returns repo:tag@digest format
role=lambda_role.arn,
)Log output
No response
Affected Resource(s)
No response
Output of pulumi about
CLI v3.148.0
aws v7.1.0
docker-build v0.0.7
python 3.12
Additional context
I'm new to this package, and I'd like to suggest either:
- Add a new output like
digest_urithat returns the repo@digest format suitable for Lambda - Document this limitation in the AWS ECR example
- Add a helper method/property that formats the URI for Lambda compatibility
This issue affects anyone using docker_build.Image with AWS Lambda functions. The documentation at https://www.pulumi.com/registry/packages/docker-build/api-docs/image/#push-to-aws-ecr-with-caching shows using ref for exports, but doesn't mention this Lambda incompatibility.
The ref output format (repo:tag@digest) is valid for many Docker operations, but AWS Lambda specifically requires either the tag format or the digest format, not both combined.
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).