Skip to content

jakubknejzlik/cwlogs2sns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cwlogs2sns

AWS CloudWatch to SNS handler for lambda

Installation

Assuming you already have created cloudwatch log group/stream, SNS topic and lambda with role permissions for SNS publishing...

  1. Create node project and add dependency: npm install cwlogs2sns

  2. Create index.js file with following content:

const cwlogs2sns = require("cwlogs2sns");

exports.handler = cwlogs2sns();
  1. Zip your project file and upload it to AWS Lambda.

  2. Setup environment variables:

  • AWS_SNS_TOPIC - arn of SNS topic you want publish to
  • TRIGGER_WORDS - this lambda function publish only logs that contain these trigger words, you can use * to forward all (default: Error,Failure,Exception,UnhandledPromiseRejection)

Reference

cwlogs2sns(options): lambda handler function

options:

  • map(logEvent, logGroup, logStream): optional function for transforming logs and custom filtering (return null to filter the log)

What's this for?

When you setup this lambda, you can subscribe for the AWS SNS. For example, you can use sns2slack to forward messages to you slack channels.

About

AWS CloudWatch to SNS handler for lambda

Resources

License

Stars

Watchers

Forks

Packages

No packages published