Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 Event Notificatons #31

Open
jtwp opened this issue Nov 14, 2018 · 5 comments
Open

S3 Event Notificatons #31

jtwp opened this issue Nov 14, 2018 · 5 comments

Comments

@jtwp
Copy link

jtwp commented Nov 14, 2018

Any possibility of adding in a function to handle S3 Events, e.g. puts or deletes.

@creichert
Copy link
Member

Definitely. Just to clarify, are you currently not receiving any S3 notifications at all?

Mine look like this:

image

This is an alert configured through CloudWatch as far as I know. I think S3 publishes some specific messages through SNS without CloudWatch?

Let me know what you're currently receiving and what you'd like to receive.

If possible, try to get the event data payload (not necessary if you don't know how).

@jtwp
Copy link
Author

jtwp commented Nov 16, 2018

Hi, so I'm adding an event for a PUT on the bucket so that whenever a certain file or file type is uploaded it sends the notification. I initially tried sending the event straight to the Lambda function, but this didn't send anything, so had it send to SNS and then subscribed the Lambda function to the topic. This worked, but think the formatting needs to be applied. Have added a screenshot of how it looks.

s3put

It doesn't need to display all the information, just the File Name, the Bucket it was uploaded to, the Event and Timestamp etc.

Here is the JSON payload - edited:

{ "Records": [ { "EventSource": "aws:sns", "EventVersion": "1.0", "EventSubscriptionArn": "arn:aws:sns:eu-west-1:::", "Sns": { "Type": "Notification", "MessageId": "xxx", "TopicArn": "arn:aws:sns:xxx", "Subject": "Amazon S3 Notification", "Message": "{\"Records\":[{\"eventVersion\":\"2.0\",\"eventSource\":\"aws:s3\",\"awsRegion\":\"eu-west-1\",\"eventTime\":\"2018-04-20T11:40:41.905Z\",\"eventName\":\"ObjectCreated:Put\",\"userIdentity\":{\"principalId\":\"AWS::i-\"},\"requestParameters\":{\"sourceIPAddress\":\"\"},\"responseElements\":{\"x-amz-request-id\":\"\",\"x-amz-id\":\"/=\"},\"s3\":{\"s3SchemaVersion\":\"1.0\",\"configurationId\":\"S3Put\",\"bucket\":{\"name\":\"\",\"ownerIdentity\":{\"principalId\":\"\"},\"arn\":\"arn:aws:s3:::\"},\"object\":{\"key\":\"list.txt\",\"size\":21,\"eTag\":\"\",\"sequencer\":\"\"}}}]}", "Timestamp": "2018-04-20T11:40:41.953Z", "SignatureVersion": "1", "Signature": "xxxxx", "SigningCertUrl": "xxx", "UnsubscribeUrl": "xxx", "MessageAttributes": {} } } ] }

@creichert
Copy link
Member

creichert commented Nov 16, 2018 via email

@jtwp
Copy link
Author

jtwp commented Nov 20, 2018

Cheers. Struggling a bit with the Slack payload code from the first link, and the parameters that are needed for the S3 event. Will keep trying, but I'm no node expert.

@creichert
Copy link
Member

creichert commented Nov 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants