Setup integration: AWS Elastic Beanstalk Notification

You need to setup an AWS SNS HTTPS endpoint for this integration!

This integration requires marbot  plus

AWS Elastic Beanstalk can run applications in various languages and frameworks. AWS Elastic Beanstalk Notifications are triggered by notable events include environment creation errors and all changes in environment and instance health. You can get either all event types or none; there is no filter feature available in Elastic Beanstalk. That’s why marbot filters them to exclude notifications where the status has changed to Info or Ok.

Allowing AWS to send messages to your topic

  1. Visit https://console.aws.amazon.com/sns/?region=us-east-1
  2. Click on the Topics link on the left
  3. Select the topic that you created for marbot
  4. Click on the Actions button, where you click on the Edit topic policy link.
    Edit SNS topic policy
  5. Select the Advanced view tab

If this is the first time you edit the SNS topic policy, you should see a default entry like this:

{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
[...TRUNCATED...]
}
]
}

If you see the default entry, go to the next step. Otherwise, replace it with this policy:

{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:GetTopicAttributes",
"SNS:SetTopicAttributes",
"SNS:AddPermission",
"SNS:RemovePermission",
"SNS:DeleteTopic",
"SNS:Subscribe",
"SNS:ListSubscriptionsByTopic",
"SNS:Publish",
"SNS:Receive"
],
"Resource": "ARN",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "ACCOUNT_ID"
}
}
}
]
}
  1. Replace ARN with your SNS topic ARN that you created for marbot.
  2. Replace ACCOUNT_ID with your AWS Account ID.
  3. Click on the Update policy button to save the policy.

Save SNS topic policy

Now, AWS is allowed to send messages to your topic.

Monitoring your Elastic Beanstalk environment

You need an existing Elastic Beanstalk environment for this example to work!

Unfortunately, Elastic Beanstalk (EB) notifications can not be configured to use an SNS topic using the graphical AWS Management Console. Instead, you have to use the AWS CLI to use the option in the aws:elasticbeanstalk:sns:topics namespace.

The command will add the option value to the aws:elasticbeanstalk:sns:topics namespace without touching the other namespaces. If you have existing options defined in the aws:elasticbeanstalk:sns:topics namespace it will override those values.

Replace the following values in the command below:

  • APPLICATION_NAME with the name of the EB application
  • ENVIRONMENT_NAME with the name of the EB environment
  • TOPIC_ARN with the SNS topic ARN that you created for marbot

And run the command in your terminal to enable SNS notifications:

aws --region us-east-1 elasticbeanstalk update-environment \
--application-name APPLICATION_NAME \
--environment-name ENVIRONMENT_NAME \
--option-settings Namespace=aws:elasticbeanstalk:sns:topics,OptionName="Notification Topic ARN",Value=TOPIC_ARN

Sample Alert

When the environment state changes, e.g. because you deploy a new application version, you should receive an alert in Slack:

Elastic Beanstalk Alert