0

I'm new to AWS and working on Lambda function triggered by S3. I have two json files and need to use the both data to send queue to SQS. For example, two files, "file_a.json" and "file_b.json" are to be uploaded to S3 at the same time.

file_a.json
{"data": "123"}

file_b.json
{"data": "456"}

Then, Lambda will send queue message like ["123", "456"] which is created with the data from both files.

However, S3 invokes Lambda function every time the single file is uploaded and this makes it hard to send queue to SQS as I wrote above. I'm thinking if S3 can wait until the two files are uploaded to trigger Lambda, it can solve the issue. If anyone had faced the similar situation, I would like to know how to resolve this problem. Thanks!

1
  • 2
    @MisterSmith has answered correctly so I won't post the same answer again, but you may consider uploading the 2 files at once in an archive (zip) and triggering your lambda on that. Commented Jan 8, 2022 at 5:37

1 Answer 1

3

S3 notifications are simple events in response to changes in S3, so you cant "make s3 wait" for both files, its upto you to handle that in your lambda.

You could store the message (or whatever data you need) - s3, rds, paramstore etc, or if you can deduce the other filename from the message you can query S3 and check if the other file exists yet and act accordingly.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for answering my question. Good to know that we cannot do it with S3 features only. I will try the approach as you advised. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.