We recently started working with Slack to streamline workflows and try some ChatOps. While pushing our Jenkins and Shippable updates to Slack was accomplished with a single cURL command, we also wanted our Elastic Beanstalk notifications to show up in some particular channels.
I’ve been wanting to try out AWS Lambda for some time now, and it just so happens that SNS (which Elastic Beanstalk uses for notifications) supports piping directly to a Lambda function.
2. Click “Topics” and locate the topic for your Elastic Beanstalk environment. If you don’t have one, create a new topic and give a descriptive name that associates it with your environment.
3. Click the topic link and then “Create Subscription”.
The “Topic ARN” should already be filled in for you, but you’ll need to change “Protocol” to “AWS Lambda”. If you had to create a new topic, highlight the ARN and copy it to your clipboard (you’ll need it below). Now, the “Endpoint” drop-down should populate with the Lambda function we just created.
4. Choose the function and click “Create Subscription”.
If you didn’t already have an SNS topic associated with your Elastic Beanstalk environment, we’ll need to associate it with the topic you just created. The simplest way to do this is with the AWS CLI:
Armed with the ARN in your clipboard, we can associate it with our Elastic Beanstalk environment (Note: the next command will update your Elastic Beanstalk environment, potentially disrupting service. Use with caution!):