0

我想serverless offline使用指向 Docker 映像的 Lambda 函数运行。

当我尝试运行serverless offline时,我只是收到:

Offline [http for lambda] listening on http://localhost:3002
Function names exposed for local invocation by aws-sdk:
           * hello-function: sample-app3-dev-hello-function

如果我尝试访问 http://localhost:3002/hello 会返回 404 错误


serverless.yml

service: sample-app3
frameworkVersion: '3'

plugins:
  - serverless-offline

provider:
  name: aws
  ecr:
    images:
      sampleapp3image:
        path: ./app/
        platform: linux/amd64

functions:
  hello-function:
    image:
      name: sampleapp3image
    events:
      - httpApi:
          path: /hello
          method: GET

app/myfunction.py

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': 'Hello World!'
    }

app/Dockerfile

FROM public.ecr.aws/lambda/python:3.9

COPY myfunction.py ./

CMD ["myfunction.lambda_handler"]
4

1 回答 1

0

目前serverless-offline插件不支持此类功能。围绕支持此用例的讨论开始存在一个问题:https ://github.com/dherault/serverless-offline/issues/1324

于 2022-02-03T09:29:05.473 回答