Skip to content

Commit

Permalink
added sns object support
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-coralogix committed Aug 16, 2023
1 parent 8751554 commit b324c17
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/s3-sns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## s3-sns

### 1.0.29
* [Update] Added Support for Sns Notification type object.
<!-- To add a new entry write: -->
<!-- ### version / full date -->
<!-- * [Update/Bug fix] message that describes the changes that you apply -->
19 changes: 15 additions & 4 deletions src/s3-sns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @link https://coralogix.com/
* @copyright Coralogix Ltd.
* @licence Apache-2.0
* @version 1.0.28
* @version 1.0.29
* @since 1.0.0
*/

Expand Down Expand Up @@ -107,9 +107,20 @@ function getSeverityLevel(message) {
*/
function handler(event, context, callback) {
const s3_event = JSON.parse(event.Records[0].Sns.Message);
const bucket = s3_event.Records[0].s3.bucket.name;
const key = decodeURIComponent(s3_event.Records[0].s3.object.key.replace(/\+/g, " "));

let bucket
let key
if ("s3" in s3_event.Records[0]){
bucket = s3_event.Records[0].s3.bucket.name;
key = decodeURIComponent(s3_event.Records[0].s3.object.key.replace(/\+/g, " "));
} else if ("Sns" in s3_event.Records[0]){
const sns_event = JSON.parse(s3_event.Records[0].Sns.Message);
console.log(sns_event.Records[0].s3);
bucket = sns_event.Records[0].s3.bucket.name;
key = decodeURIComponent(sns_event.Records[0].s3.object.key.replace(/\+/g, " "));
} else {
throw new Error ('Wrong Object found in SNS')
}
console.log(bucket+" "+key);
s3.getObject({
Bucket: bucket,
Key: key
Expand Down
2 changes: 1 addition & 1 deletion src/s3-sns/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "coralogix-s3-via-sns",
"title": "AWS S3 Lambda function for Coralogix via SNS Trigger",
"version": "1.0.28",
"version": "1.0.29",
"description": "AWS Lambda function to send logs from S3 bucket to Coralogix via SNS Trigger",
"homepage": "https://coralogix.com",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/s3-sns/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Metadata:
- s3
- sns
HomePageUrl: https://coralogix.com
SemanticVersion: 1.0.28
SemanticVersion: 1.0.29
SourceCodeUrl: https://github.com/coralogix/coralogix-aws-serverless
AWS::CloudFormation::Interface:
ParameterGroups:
Expand Down

0 comments on commit b324c17

Please sign in to comment.