Lambci docker images are deprecated and no more maintained.
Bug Report
Current Behavior
Goal: create a lambda with useDocker and Python.
With useDocker value being true, the image that will be used is lambci/lambda:python3.x.
The above link shows clearly that this repository (and the images it carries of course) are deprecated in favor of AWS' ones.
For python versions: 3.9, 3.10, and 3.11 this leads to an error, which is:
GET /hello (λ: hello)
✖ time="2024-01-04T09:17:04+01:00" level=warning msg="targets metadata is nearing expiry, you should re-sign the role metadata"
time="2024-01-04T09:17:04+01:00" level=warning msg="snapshot is nearing expiry, you should re-sign the role metadata"
No valid trust data for python3.11
✖ Unhandled exception in handler 'hello'.
✖ { Error: Command failed with exit code 1: docker pull --disable-content-trust=false lambci/lambda:python3.11
time="2024-01-04T09:17:04+01:00" level=warning msg="targets metadata is nearing expiry, you should re-sign the role metadata"
time="2024-01-04T09:17:04+01:00" level=warning msg="snapshot is nearing expiry, you should re-sign the role metadata"
No valid trust data for python3.11
at makeError (file:///my_path/node_modules/execa/lib/error.js:60:11)
at handlePromise (file:///my_path/node_modules/execa/index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async #pullImage (file:///my_path/node_modules/serverless-offline/src/lambda/handler-runner/docker-runner/DockerImage.js:20:7)
at async file:///my_path/node_modules/p-memoize/dist/index.js:42:32
at async DockerContainer.start (file:///my_path/node_modules/serverless-offline/src/lambda/handler-runner/docker-runner/DockerContainer.js:74:5)
at async DockerRunner.run (file:///my_path/node_modules/serverless-offline/src/lambda/handler-runner/docker-runner/DockerRunner.js:58:7)
at async HandlerRunner.run (file:///my_path/node_modules/serverless-offline/src/lambda/handler-runner/HandlerRunner.js:114:14)
at async LambdaFunction.runHandler (file:///my_path/node_modules/serverless-offline/src/lambda/LambdaFunction.js:301:16)
at async file:///my_path/node_modules/serverless-offline/src/events/http/HttpServer.js:606:18
at async exports.Manager.execute (/my_path/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
at async internals.handler (/my_path/node_modules/@hapi/hapi/lib/handler.js:46:20)
at async exports.execute (/my_path/node_modules/@hapi/hapi/lib/handler.js:31:20)
at async Request._lifecycle (/my_path/node_modules/@hapi/hapi/lib/request.js:370:32)
at async Request._execute (/my_path/node_modules/@hapi/hapi/lib/request.js:280:9)
shortMessage: 'Command failed with exit code 1: docker pull --disable-content-trust=false lambci/lambda:python3.11',
command: 'docker pull --disable-content-trust=false lambci/lambda:python3.11',
escapedCommand: 'docker pull "--disable-content-trust=false" "lambci/lambda:python3.11"',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr:
'time="2024-01-04T09:17:04+01:00" level=warning msg="targets metadata is nearing expiry, you should re-sign the role metadata"\ntime="2024-01-04T09:17:04+01:00" level=warning msg="snapshot is nearing expiry, you should re-sign the role metadata"\nNo valid trust data for python3.11',
cwd: '/my_path/test-sls-off',
failed: true,
timedOut: false,
isCanceled: false,
killed: false }
✖ Command failed with exit code 1: docker pull --disable-content-trust=false lambci/lambda:python3.11
time="2024-01-04T09:17:04+01:00" level=warning msg="targets metadata is nearing expiry, you should re-sign the role metadata"
time="2024-01-04T09:17:04+01:00" level=warning msg="snapshot is nearing expiry, you should re-sign the role metadata"
No valid trust data for python3.11
Sample Code
- file: serverless.yml
service: sls-offline-image-error
provider:
name: aws
runtime: python3.11
region: eu-west-1
profile: default
custom:
serverless-offline:
host: 0.0.0.0
lambdaPort: 3039
useDocker: true
noPrependStageInUrl: true
printOutput: true
functions:
hello:
handler: handler.handler
events:
- http:
path: hello
method: get
plugins:
- serverless-offline
- file: handler.py
def handler(event, context):
return {
'statusCode': 200,
'body': 'Hello World!'
}
Expected behavior/code The handler should be wrapped by a docker image (AWS python official one based on my runtime settings, 3.11 in this case)
Environment
Framework Core: 3.38.0 (local) 3.38.0 (global)Plugin: 7.2.0SDK: 4.5.1serverless-offline: 13.3.2Node JS: 20.10.0OS: Ubuntu 22.04.1Python: 3.11
Possible Solution Find a way to use AWS' images that can be retrieved here: https://gallery.ecr.aws/lambda?page=1 I'd like to point out that every serverless-offline's supported runtime is support by AWS too.
Problem of proposed solution
Current runtime value does not match AWS' images naming convention.
Eg. runtime: python3.11 currently creates this path -> lambci/lambda:python3.11
AWS' python 3.11 image link is: public.ecr.aws/lambda/python:3.11
The difference is just that lambci uses the whole runtime value as image tag and AWS uses the "base" runtime value to point to a specific repository and the version value as image tag.
Is there any update?
I am using lambci/lambda:provided.al2 and encountering the same issue.
@vallops99 @karify98 This should now be fixed. I just merged a PR that solves this issue - #1755