AWS SAM "No response from invoke container for" 错误的函数名称

AWS SAM "No response from invoke container for" wrong function name

我调试了我的应用程序,发现了一个问题。我有 2 个 REST API 网关,似乎因为它们都绑定在同一个端点上,所以第一个将收到第二个应该处理的呼叫。

这是我的 template.yaml

Resources:
  mysampleapi1: 
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: packages/mysampleapi1/dist/index.handler
      Runtime: nodejs14.x
      CodeUri: .
      Description: ''
      MemorySize: 1024
      Timeout: 30
      Role: >-
        arn:aws:iam:: [PRIVATE]
      Events:
        Api1:
          Type: Api
          Properties:
            Path: /users
            Method: ANY
      Environment:
        Variables:
          NODE_ENV: local
      Tags:
        STAGE: local
  mysampleapi2:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: packages/mysampleapi2/dist/index.handler
      Runtime: nodejs14.x
      CodeUri: .
      Description: ''
      MemorySize: 1024
      Timeout: 30
      Role: >-
        arn:aws:iam:: [PRIVATE]
      Events:
        Api1:
          Type: Api
          Properties:
            Path: /wallet
            Method: ANY
      Environment:
        Variables:
          NODE_ENV: local
      Tags:
        STAGE: local

当我为 mysampleapi2

发送 HTTP 请求时

这是使用启动命令在日志中发生的事情

sam local start-api --port 3001 --log-file /tmp/server-output.log --profile personal --debug
2022-04-27 18:2:34,953 | Mounting /home/mathieu_auclair/Documents/Project/repositories/server as /var/task:ro,delegated inside runtime container
2022-04-27 18:20:35,481 | Starting a timer for 30 seconds for function 'mysampleapi1'
2022-04-27 18:21:05,484 | Function 'mysampleapi1' timed out after 30 seconds
2022-04-27 18:21:46,732 | Container was not created. Skipping deletion
2022-04-27 18:21:46,732 | Cleaning all decompressed code dirs
2022-04-27 18:21:46,733 | No response from invoke container for mysampleapi1
2022-04-27 18:21:46,733 | Invalid lambda response received: Lambda response must be valid json

为什么我的 mysampleapi2 没有选择 HTTP 调用?如果我 运行 使用不同的端口将它们放在单独的模板文件中,那么它就可以工作...这是为什么?

在单独的进程中启动我的 lambda 后,我发现第二个服务的配置存在问题。

使用此启动器后问题仍然存在

echo "" > /tmp/server-output-1.log
sam local start-api --port 3001 --log-file /tmp/server-output-1.log --template .template.1.yaml --debug &
tail -f /tmp/server-output-1.log &

echo "" > /tmp/server-output-2.log
sam local start-api --port 3002 --log-file /tmp/server-output-2.log --template .template.2.yaml --debug &
tail -f /tmp/server-output-2.log &

我在导出配置时注意到,对于其中一项服务,template.yaml

中有以下内容
            Path: '/{proxy+}'

没有代理行,lambda 处理程序由于某种原因永远不会被调用