记录使用 aws lambda +apigateway 过程中遇到的问题

我希望创建一个 api-gateway httpapi,把 $default 路由全发给一个lambda函数。

SAM配置:

...
      Events:
        ExplicitApi: # warning: creates a public endpoint
          Type: HttpApi
          Properties:
            ApiId: !Ref HttpApi
            # route all path to one endpoint.
            Path: $default
            Method: ANY
            TimeoutInMillis: 15000
            # https://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
            PayloadFormatVersion: "2.0"
            RouteSettings:
              ThrottlingBurstLimit: 50

Cloudfomation 报错

Resource handler returned message: "Warnings found during import: Parse issue: attribute paths. Resource $default should start with / (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: ce4209a2-49b6-445a-b1c2-6120eff65ace; Proxy: null) (Service: null; Status Code: 404; Error Code: BadRequestException; Request ID: null; Proxy: null)" (RequestToken: 100b7e44-826d-cca7-3b2b-144ce77f3771, HandlerErrorCode: GeneralServiceException)

原因是SAM还不支持这种 '$default' 方式。bug: https://github.com/aws/serverless-application-model/issues/2481#issuecomment-1233074041

posted @   Jneeee  阅读(77)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示