代码之家  ›  专栏  ›  技术社区  ›  johnny_mac

部署到AWS时未调用无服务器Lambda授权程序

  •  0
  • johnny_mac  · 技术社区  · 5 年前

    使用serverless,我在Node中部署了一个API网关和几个lambda函数。js。我还使用lambda授权程序(authenticate.js)向一个GET端点添加了身份验证。我没有主意了,所以任何帮助都将不胜感激。我能看到的唯一一件事是没有为授权人分配Lambda Invoke角色。我没有找到任何关于如何将其添加到无服务器yaml的文档,但是Cloudwatch日志没有显示任何授权人执行情况,所以我希望是403之类的。

    1. 使用无服务器脱机进行本地测试效果很好
    2. 在当地与邮递员一起测试效果很好
    3. 部署后,在AWS控制台中测试lambda工作正常
    4. 部署之后,在AWS控制台中测试API网关方法就可以了
    5. 部署后,测试身份验证。js Lambda授权器工作正常
    6. 部署后,在Postman中测试端点失败,并返回以下错误:

    <HEAD>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
        <TITLE>ERROR: The request could not be satisfied</TITLE>
    </HEAD>
    
    <BODY>
        <H1>403 ERROR</H1>
        <H2>The request could not be satisfied.</H2>
        <HR noshade size="1px">
        Bad request.
        We can't connect to the server for this app or website at this time. There might be too much traffic or a
        configuration error. Try again later, or contact the app or website owner.
        <BR clear="all">
    If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
        <BR clear="all">
        <HR noshade size="1px">
        <PRE>
    Generated by cloudfront (CloudFront)
    Request ID: yx1B1i6k_J1nqf_jPMTN4AyHD8gKE85KajxhcosOMUZ-tHWoU1E54w==
    </PRE>
        <ADDRESS>
        </ADDRESS>
    </BODY>
    
    </HTML>
    

    无服务器。亚马尔:

    functions:
      authenticate:
        handler: src/handlers/auth.authenticate
    
      list:
        handler: src/handlers/api.list
          events:
            - http:
                path: todos
                method: get
                cors: true
                authorizer: authenticate
    

    Lambda授权人:

    enter image description here

    enter image description here

    0 回复  |  直到 5 年前