diff --git a/src/s3-sns/CHANGELOG.md b/src/s3-sns/CHANGELOG.md index b7e27b91..f37015a3 100644 --- a/src/s3-sns/CHANGELOG.md +++ b/src/s3-sns/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## s3-sns + +### 1.0.29 +* [Update] Added Support for Sns Notification type object. \ No newline at end of file diff --git a/src/s3-sns/index.js b/src/s3-sns/index.js index 9879c145..58bade77 100644 --- a/src/s3-sns/index.js +++ b/src/s3-sns/index.js @@ -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 */ @@ -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 diff --git a/src/s3-sns/package.json b/src/s3-sns/package.json index 6ebcf84d..3af6729c 100644 --- a/src/s3-sns/package.json +++ b/src/s3-sns/package.json @@ -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", diff --git a/src/s3-sns/template.yaml b/src/s3-sns/template.yaml index daff1f96..b08b5036 100644 --- a/src/s3-sns/template.yaml +++ b/src/s3-sns/template.yaml @@ -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: