Giter Site home page Giter Site logo

slack-aws-sns's Introduction

slack-aws-sns

Create a slack webhook

Unfortunately this is a ui driven process

  1. Go to https://your-company.slack.com/services/new
  2. Click 'Incoming WebHooks'
  3. Create a new one by selecting a channel and clicking "Add incoming webhook integration"
  4. Copy the webhook url for use later

Create sns topic

> aws sns create-topic --name Billing
{
    "TopicArn": "arn:aws:sns:us-east-1:111122223333:Billing"
}
> aws sns subscribe --topic-arn arn:aws:sns:us-east-1:111122223333:Billing --protocol email --notification-endpoint <your-email-address>

Create cloudwatch alarm

> aws cloudwatch put-metric-alarm \
	--alarm-name "billing more than $1" \
	--comparison-operator GreaterThanOrEqualToThreshold \
	--evaluation-periods 1 \
	--metric-name EstimatedCharges \
	--namespace AWS/Billing \
	--dimensions Name=Currency,Value=USD" \
	--period 21600 \
	--statistic Maximum \
	--threshold 1 \
	--actions-enabled \
	--alarm-actions arn:aws:sns:us-east-1:111122223333:Billing

Create the aws lambda function

> aws lambda create-function \
	--function-name snsToSlack \
	--zip-file file://file-path/snsToSlack-created-from-snsToSlack.js.zip \
	--role role-arn-looked-up-from-iam \
	--handler index.handler \
	--runtime nodejs
{
    "CodeSize": number,
    "Description": "string",
    "FunctionArn": "string",
    "FunctionName": "string",
    "Handler": "string",
    "LastModified": "string",
    "MemorySize": number,
    "Role": "string",
    "Runtime": "string",
    "Timeout": number
}

Subscribe to lambda function to the sns topic

> aws sns subscribe \
    --topic-arn arn:aws:sns:us-east-1:111122223333:Billing \
    --protocol lambda \
    --notification-endpoint arn:aws:lambda:REGION:ACCOUNT:function:LAMBDAFUNCTION

Concept heavily borrowed from

https://medium.com/cohealo-engineering/how-set-up-a-slack-channel-to-be-an-aws-sns-subscriber-63b4d57ad3ea

slack-aws-sns's People

Contributors

jplikesbikes avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.