This file contains hidden or 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
const https = require('https'); | |
const Promise = require('bluebird'); | |
const zlib = Promise.promisifyAll(require('zlib')); | |
export async function main(event, context) { | |
const payload = new Buffer(event.awslogs.data, 'base64'); | |
const gunzipped = (await zlib.gunzipAsync(payload)).toString('utf8'); | |
const eventDetails = JSON.parse(gunzipped); | |
let messageArray = eventDetails.logEvents[0].message.split('\t'); | |
let errorJSON, errorType, errorMessage; | |
let timestamp = messageArray[0]; |
This file contains hidden or 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
// Load the SDK for JavaScript | |
var AWS = require('aws-sdk'); | |
const cloudwatchlogs = new AWS.CloudWatchLogs(); | |
export async function main(event, context) { | |
console.log(JSON.stringify(event)); | |
const detail = event.detail; | |
const resourceSplit = event.resources[0].split(':'); | |
const functionName = [resourceSplit[resourceSplit.length - 1]]; |
This file contains hidden or 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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": "sns:Publish", | |
"Resource": "arn:aws:sns:us-east-1:*:*" | |
} | |
] |
This file contains hidden or 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
//Takes a hostname, path, and msg to post to slack | |
var https = require("https"); | |
exports.posttoslack = function(hostname, path, msg){ | |
return new Promise((resolve, reject) => { | |
var options = { | |
"method": "POST", | |
"hostname": hostname, | |
"path": path, | |
"headers": { | |
"Content-Type": "application/json" |