AWS Lambda使S3上载的CloudFront失效 [英] aws Lambda to invalidate CloudFront on S3 upload
问题描述
我同时上传了10-50个文件. Lambda会为每个更新的文件触发一个事件(如果文件大小已更改).
I have 10-50 files upload at the same time. Lambda triggers an event for every updated file (if file size changed).
因此,我不想在上传结束时一次运行通配符*
,而不是一次使50x无效.
So instead of invalidating one by one 50x I'd like to run the wildcard "*"
character once at the end of the upload.
任何人都可以阐明如何实现这一目标?谢谢!
Anyone can shed some light on how to accomplish that? Thanks!
推荐答案
如果我正确理解了您的问题,则您的lambda函数会知道CloudFront是否应该使之无效,但不知道什么时候该准确发生.
If I understood your question correctly, your lambda function knows whether CloudFront should invalidate or not but does not know when should that happen exactly.
在这种情况下,您可以返回布尔值标志(例如mustInvalidate
)作为响应的一部分,以指示应创建一个无效请求.然后,您的应用程序(或任何发起批处理上传请求的程序)可以在上传批处理完成后立即创建/target-location/*
无效请求.
In that case, you could return a boolean flag (e.g., mustInvalidate
) as part of the response to indicate that an invalidation request should be created. Then, your application (or whatever initiated the batch upload request) can create the /target-location/*
invalidation request as soon as the upload batch completes.
这篇关于AWS Lambda使S3上载的CloudFront失效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!