0
votes

I am working on a requirement where I want to trigger the AWS Lambda function written in Java when a file is uploaded on S3 bucket. The condition is that the function should pick-up the latest file in the bucket. Right now, I have the lambda function which picks up the specified file (having already specified file name). But as per the requirement, the file name can be anything(eg. web-log-). Is there any way to do that?

Since with lambda functions, we have access to the event object, can I use it to find out the recently uploaded file?

1
Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear? - Boris van Katwijk
@BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code. - Swapnil

1 Answers

1
votes

You could check out the AWS Lambda S3 tutorials, which should show how the uploaded object is passed in as event data. The example code contains a line which should point you in the right direction:

event.Records[0].s3.object.key