仅通过API网关从S3进行AWS Lambda访问 [英] AWS Lambda Access from S3 Only with API Gateway

查看:123
本文介绍了仅通过API网关从S3进行AWS Lambda访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要完成的工作是允许lambda函数由来自指定S3存储桶的请求执行. API网关用于与lambda函数进行通信.我只需要允许基于S3存储桶使用端点.

What i am trying to accomplish is to allow a lambda function to be executed by a request from a specified S3 bucket. The API Gateway is used to communicate to the lambda functions. I need to allow the usage of of the endpoint based on the S3 bucket only.

我可以设置CORS,但这不是我想要的.我不仅需要浏览器安全性. 我所有允许的请求必须仅来自S3存储桶.如何在API Gateway中创建这样的策略或验证?还是有其他方法可以完成此任务?

I can set up CORS, but that is not what i intend to do. I need more than just a browser security. All my allowed requests must be coming from the S3 bucket only. How can i create such a policy or validation in API Gateway? Or is there any other way to accomplish this task?

我现在要解释更多.因此,以为我有一个具有静态网站的S3存储桶.我也有一个lambda函数.现在我的网站希望加载一些数据,所以我正在使用我的API网关调用lambda函数.该API现在已打开.没有身份验证或CORS.如果仅来自特定的S3存储桶,我需要我的API网关来允许请求.我们不希望仅开放API.现在,CORS只是浏览器的安全性,因此我们不仅仅希望如此.我已经为这个特定用例进行了很多搜索,但找不到任何东西.

I am explaining more now. So think that i have an S3 bucket which has a static website. I also have a lambda function. Now my website wants some data to be loaded, so i am calling the lambda function using my API gateway. The API is open right now. There is no authentication or CORS. I need my API Gateway to allow request if it coming from that particular S3 bucket only. We don't want the API to just be open. Now CORS are just browser security, so we want more than that. I have searched a lot for this particular use case, but couldn't find anything.

推荐答案

S3不是调用"服务.其他服务,例如Lambda或API网关.

S3 is not a service that "calls" other services such as Lambda or API Gateway.

我相信您正在寻找的是利用S3事件,在这种情况下,来自S3的事件(例如对象创建)会触发lambda执行.请参阅此处: https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

I believe what you are looking for is to leverage S3 Events, in which case an event from S3 (like object creation) can trigger a lambda execution. See here: https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

这篇关于仅通过API网关从S3进行AWS Lambda访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆