[英]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.