I am new to AWS, I wanted to get S3 object URI/path when the object creation event is generated. Object can be created anywhere in the bucket, like there can be multiple sub folders that dynamically created in s3 bucket based on the date. So I want to know exactly where object is created. Is there anyway to do so? Seems like most of the message structure examples I can see only object name and bucket name not the entire object URI. I'm planning to use this message to SNS or kinesis streams with eventbridge.
Asked
Active
Viewed 691 times
1 Answers
3
You have to setup S3 Event Notifications for your bucket that will trigger your custom lambda function.
Once the object is uploaded to the bucket, your function is going to get invoked and obtain all the associated data about the event, such as object name, key, bucket, data, etc. Then your lambda may use that information to construct custom messages (entire object URI) that will be then uploaded to SNS or Kinesis.

Marcin
- 215,873
- 14
- 235
- 294
-
But I couldn't see any event message examples that has the folder details, if we specify prefix to append, then it was coming with object key(but in my case folders generated dynamically so we don't know in which folder this file is being created), otherwise just object name, bucket name only those details were coming in event message – codeSeeker Jun 06 '22 at 06:41
-
1@codeSeeker There are no "folders" in S3. Only object keys. You have to construct the "folder" yourself, from the object's key. – Marcin Jun 06 '22 at 07:01