Hemant Rajpoot
Hemant Rajpoot

Reputation: 690

lambda function triggers only for a upload of filename pattern

Let's say I upload folder/key.jpg to a S3 bucket. How would I trigger a lambda function only when a file contains jpg at the end of File Name, is uploaded?

Is this possible or do I need to check the filename in the function and early-out it doesn't match what I'm looking for?

The reason I ask is that a lot of stuff will be uploaded to the bucket, and it seems inefficient (and costly) for the function to trigger every time.

Upvotes: 1

Views: 2064

Answers (3)

Marcin
Marcin

Reputation: 238081

You can use S3 Event notifications.

For example:

enter image description here

Upvotes: 1

Ajay
Ajay

Reputation: 21

It is possible to trigger lambda only on jpg image is uploaded in your s3 folder, follow https://n2ws.com/blog/aws-automation/lambda-function-s3-event-triggers. Just add jpg as suffix and foldername as prefix in event section of s3.

Upvotes: 2

Jaffer
Jaffer

Reputation: 2968

You could use Suffix filter. As per this blog

Upvotes: 0

Related Questions