AWS Lambda showing "The provided image is invalid." with no reason

1

Hi

I am trying to run a NextJS application in a lambda with a docker image, using the lambda web adaptor. I have setup a lambda with 1024 memory and default storage and if I try to run the image locally it works fine but when I try to select it in the lambda dashboard I get the following error:

"Failed to update the function <my function>: The provided image is invalid."

Is there any way I could get more information about what issue the lambda function is having with the image?

For some additional info: the image that isn't working is built from BitBucket Pipelines. But if I run the same image locally it works. Also, if I build the image locally and push it to ECR then it works when I select it in the AWS dashboard. All images are using the correct architecture. I have also tried with my app and the example from the web adaptor repo: 'https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/nextjs'.

Garth
asked 10 months ago1385 views
4 Answers
0

Hi, don't you have a naming issue of your image like the one reported in https://github.com/serverless/serverless/issues/8636 ?

In this case, the user combined :latestt with @sha and it creates a problem like yours

Best,

Didier

profile pictureAWS
EXPERT
answered 10 months ago
0

That was my first guess too, but I've tried using the tag and digest and double-checked the naming and it still happens.

Even when using the exact same image path and tag but updating the underlying image in ECR and then trying to publish a new lambda version results in the error. So it seems it's something with the image itself, although the same image works on my local machine.

Garth
answered 10 months ago
0

After some digging it appears that the issue lies when copying the lambda adapter binary from the remote image.

COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.0 /lambda-adapter /opt/extensions/lambda-adapter

If that binary exists locally and is copied across in the Dockerfile using COPY ./lambda-adapter /opt/extensions/lambda-adapter everything works. And as mentioned in my original post this only happens when building from BitBucket Pipelines.

Could it be a docker version issue? Locally I tried with 20.10.23 and 23.0.5 and they both work. BitBucket Pipelines users 20.10.24.

In terms of the lambda issue I can only assume that when trying to set the image in the function dashboard that file can't be executed/accessed, or something else to do with how extensions are handled.

Any other ideas?

Garth
answered 10 months ago
0

And after that discovery it appears all that was needed was to copy using a chown. But why this is only needed in Pipelines I'm not sure.

COPY --chown=root:root --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.7.0 /lambda-adapter /opt/extensions/lambda-adapter

Garth
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions