AWS Lambda Trigger For Same S3 File Name In Quick Succession

27 Views Asked by At

I have AWS Lambda trigger configured on POST/PUT S3 event. S3 files are generated with same name with some variation in the content almost at the same time. The first file (file1.json) is generated with Content A and the second file with same name (file1.json) is generated with Content B. When these two files are dropped almost at the same time, Lambda triggers twice however both trigger reads the latest Content. It looks like by the time Lambda is triggered first time, the latest Content is overridden and both triggers happens to read the latest Content. Is it possible to have (by some configuration) the first trigger reads Content A and then second trigger reads Content B?

I tried to enable the versioning on the bucket which creates two version of same file however that is not helping

1

There are 1 best solutions below

2
Sandip Dutta On

I found these 2 links:

From what I gathered, from the event, you can get the versionId of the object and use AWS SDK to procure that specific version of the object. Then you can continue processing it as per your use case.