简体   繁体   English

使用 lambda 函数的 AWS S3 存储桶索引

[英]AWS S3 Bucket indexing using lambda function

I have S3 bucket website which has multiple HTML files, now I have created a lambda function and connected it to S3 trigger.我有一个包含多个 HTML 文件的 S3 存储桶网站,现在我创建了一个 lambda 函数并将其连接到 S3 触发器。 Now I have created a lambda function which I want the first indexAll the current HTML file of S3 bucket to my Elastic search domain indices which I have after that if I upload or delete any HTML file in S3 bucket then this lambda function should index it to ES domain.现在我创建了一个 lambda 函数,我想要第一个索引 S3 存储桶的当前 HTML 文件到我的弹性搜索域索引,如果我上传或删除 S3 存储桶中的任何 HTML 文件,那么这个 lambda 函数应该将它索引到ES 域。 The issue is that I am not able to index my all current HTML also when I upload a new HTML file I am not able to index them to ES domain indices.问题是,当我上传新的 HTML 文件时,我也无法将所有当前的 HTML 编入索引,我无法将它们编入 ES 域索引。

Lambda Function to indexall then index one by one . Lambda 函数来索引所有然后一一索引。 Also I wan to create a test in AWS lambda test for S3 and use event indexAll to index all file first .我还想在 AWS lambda 测试中为 S3 创建一个测试,并首先使用事件indexAll来索引所有文件。

Error is Time out in 3 sec:错误是 3 秒后超时:

Your Lambda function timeout is too low (its default is 3 seconds).您的 Lambda 函数超时时间太短(默认为 3 秒)。

Also, it's not a good idea to try to analyze/index all S3 objects within a single invocation of a Lambda function unless you can constrain the number of objects.此外,除非您可以限制对象的数量,否则尝试在一次 Lambda 函数调用中分析/索引所有 S3 对象并不是一个好主意。 Lambda has a maximum timeout of 15 minutes. Lambda 的最大超时时间为 15 分钟。

One option to deal with existing files, as an alternative to EC2, would be to create a list of existing objects in the bucket (you could just list the bucket if it's reasonably sized, like 10k items or fewer, or you could use an S3 Inventory Report if it's a very large bucket).作为 EC2 的替代方案,处理现有文件的一种选择是在存储桶中创建现有对象的列表(如果存储桶大小合理,例如 10k 项或更少,您可以只列出存储桶,或者您可以使用 S3如果它是一个非常大的存储桶,则为库存报告)。 Either way, get a list of objects and then send them to an SQS queue, one by one.无论哪种方式,获取对象列表,然后将它们一个一个地发送到 SQS 队列。 Have SQS trigger your Lambda function one object per invocation or a batch of 10 objects per invocation.让 SQS 每次调用触发一个对象或每次调用一批 10 个对象来触发您的 Lambda 函数。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM