Open jtwp opened 5 years ago
Definitely. Just to clarify, are you currently not receiving any S3 notifications at all?
Mine look like this:
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).
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.
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": {} } } ] }
Fantastic, thank you for all the information. I don't think it's too difficult to add support.
If you're up for making a PR, it should mostly involve following what's already sketched out:
s3: { match_text: "S3 Notification" }
test/s3-event.json
If you don't have time, or don't want to, no worries :). I can probably add support later this evening or Sunday.
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.
No worries, thanks for taking a crack at it. If you want to push a PR with your current progress I can help out.
Any possibility of adding in a function to handle S3 Events, e.g. puts or deletes.