Last active
May 17, 2020 19:56
-
-
Save wheel5up/fe7c90af7749e6ef1710e27baaa24dfc to your computer and use it in GitHub Desktop.
Lamdba function to map GuardDuty Findings to Opsgenie priorities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
exports.handler = (event, context, callback) => { | |
console.log(event); | |
console.log(context); | |
var sns = new AWS.SNS(); | |
if ( event.detail.severity > 0.1 && event.detail.severity < 3.9 ) { | |
event.detail.priority = "P3"; | |
} else if (event.detail.severity > 3.9 && event.detail.severity < 6.9 ) { | |
event.detail.priority = "P2"; | |
} else if (event.detail.severity > 6.9 && event.detail.severity < 9.0 ) { | |
event.detail.priority = "P1"; | |
} | |
sns.publish({Message: JSON.stringify(event), TopicArn:"arn:aws:sns:us-east-1:86753098675309:OpsGenie"}, function(err, data) { | |
if(err) { | |
console.log('error publishing to SNS'); | |
context.fail(err); | |
} else { | |
console.log('message published to SNS'); | |
context.succeed(null, data); | |
} | |
}); | |
return event; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment