简体   繁体   English

如何使用无服务器使 AWS lambda function 具有公共访问权限

[英]How to make a AWS lambda function with public access using serverless

I am trying to create a AWS lambda function with public access without any authorization via serverless .我正在尝试创建一个AWS lambda function具有公共访问权限,无需通过serverless进行任何授权。 In my API witch I have all functions with a private access via authorizer.在我的 API 女巫中,我拥有所有功能,可以通过授权人进行私人访问。 I tried to deploy the function without authorizer but it gives me 403 Forbidden .我试图在没有授权的情况下部署 function 但它给了我403 Forbidden

My function example:我的 function 示例:

    rel-Session:
    description: do something public
    handler: src/handlers/items/getNewPublicItem.getNewPublicItem
    events:
      - http:
          path: api/v1.0/public/item/{id}
          method: get
          request:
            parameters:
              paths:
                id: true
          cors:
            origin: ${env:CorsAllowOrigin}

How can I make my endpoint to be with public access?如何使我的端点具有公共访问权限?

Your issue is with your API, not the Lambda function.您的问题出在您的 API 上,而不是 Lambda function 上。 You can make your api available to the public with an API key or by configuring identity pools with AWS Cognito.您可以使用 API 密钥或使用 AWS Cognito 配置身份池,将您的 api 向公众开放。 It would all depend on what you're using for authentication.这完全取决于您用于身份验证的内容。 Here's a serverless template for attaching a lambda function to run based on an API method:这是一个无服务器模板,用于附加 lambda function 以基于 API 方法运行:

https://carova.io/snippets/serverless-aws-lambda-function-as-api-gateway-endpoint https://carova.io/snippets/serverless-aws-lambda-function-as-api-gateway-endpoint

Here's AWS docs on configuring an API Key:这是有关配置 API 密钥的 AWS 文档:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用无服务器框架通过 AWS Lambda Function 环境变量访问 SSM 参数存储值? - How to access SSM Parameter Store Values through AWS Lambda Function Environment Variables using Serverless Framework? 如何在使用无服务器框架时从AWS Lambda访问DynamoDB? - How to access DynamoDB from AWS Lambda when using the Serverless Framework? 使用无服务器框架时如何在aws lambda函数中打包可执行文件? - How to package executables in aws lambda function when using serverless framework? 如何为AWS Lambda函数建立公共API路由? - How Can I Make A Public API Route For An AWS Lambda Function? 使用无服务器将AWS sqs添加为AWS Lambda函数触发器 - Add aws sqs as aws lambda function trigger using serverless AWS Lambda 上的私有和公共 API - Private and public APIs on AWS Lambda Serverless 回调不是函数无服务器 AWS lambda - callback is not a function serverless AWS lambda 使用无服务器部署,如何将对一个 AWS Lambda 的访问限制为 IP 地址的子集 - Using serverless deployment, how do I restrict access to one AWS Lambda to a subset of IP addresses AWS Lambda(无服务器框架)上的 Nestjs | 如何访问事件参数? - Nestjs on AWS Lambda (Serverless Framework) | How to access the event parameter? 无服务器:无法使用部署命令在 AWS 上加载 lambda 函数 - Serverless: can't load lambda function on the AWS using deploy comand
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM