I upload many files using aws s3 sync command
Works perfectly and all files are uploaded. Then I have a trigger for a lambda that checks if all the files are uploaded and then I want to invoke another function
The problem is that if the files are uploaded very fast the lambda executes many times in concurrency!!
const s3Files = await s3.listObjectsV2(params).promise();
const s3FileNames = [];
s3Files.Contents.forEach((content) => {
s3FileNames.push(content.Key);
});
// hidden code validating if file names are fine
if(allLoaded) {
//invoke another function
} else { return; }
If I upload 10 small files, it executes invoke another function 10 times!! I only want to run ONCE.
Where do I save like a boolean saying if all loaded don't call the function again