Skip to content

Instantly share code, notes, and snippets.

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];
// 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]];
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "arn:aws:sns:us-east-1:*:*"
}
]
@cplankey
cplankey / index.js
Last active February 23, 2019 16:39
A simple node module that takes a hostname, path, and msg to post to Slack from a Lambda Layer
//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"