Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

Latest commit

 

History

History
58 lines (36 loc) · 1.91 KB

README.md

File metadata and controls

58 lines (36 loc) · 1.91 KB

CF Notify

What?

An AWS Lambda function that will post Cloud Formation status updates to a Slack channel via a Slack Web Hook.

Why?

To give visibility of Cloud Formation changes to the whole team in a quick and simple manner. For example:

example Slack messages

How?

CF Notify has a stack of AWS resources consisting of:

  • An SNS Topic
  • A Lambda function, which uses the SNS Topic as an event source
  • An IAM Role to execute the Lambda function

We add the SNS Topic of CF Notify to the notification ARNs of the Stack we want to monitor. Search for NotificationARNs.member.N here for more information on notification ARNs.

Setup

To setup CF Notify, we need to do the following.

Prerequisites

Slack incoming webhook

You can create an incoming webhook here.

Deploy Lambda

This is done using the script deploy.sh.

./deploy.sh $CHANNEL $WEBHOOK $AWS_PROFILE

Where:

  • CHANNEL is the Slack channel or user to send messages to. It will be used in the naming of the Lambda artifact file stored in S3.
  • WEBHOOK is the Web Hook URL of an Incoming Web Hook (see https://api.slack.com/incoming-webhooks).
  • AWS_PROFILE is the aws cli profile you want to use for deploy. Default profile is "default"

deploy.sh will create a zip file and upload it to S3 and also create a cloud formation stack using the template.

Usage

Once setup is complete, all you need to do now is set the notification ARN when you update any Cloud Formation stack:

SNS_ARN=`aws cloudformation describe-stacks --stack-name cf-notify-$CHANNEL | jq ".Stacks[].Outputs[].OutputValue"  | tr -d '"'`

aws cloudformation [create-stack|update-stack|delete-stack] --notification-arns $SNS_ARN

You should now see messages in Slack!