Subscribing All SES Identities to an SNS Topic

I recently ran across an issue where I was experiencing many bounced emails on my Amazon SES account. So much so that Amazon reached out and put me on a warning notice.

I realized that I had no logging in place to handle this. In order to create a logging mechanism I decided to send all “Bounce” notifications to a Slack channel so that I could better understand what was going on.

To accomplish this I first had to subscribe an SNS topic to a Slack channel. There are a multitude of ways that you can do this so I won’t go into detail here. If you have questions please reach out.

I wrote a simple function to loop through all of my identities in SES and then subscribe them to my SNS topic. Here is the code:

import boto3
ses = boto3.client('ses')
response = ses.list_identities()

for id in response['Identities']:
    update = ses.set_identity_notification_topic(
        SnsTopic='<your SNS ARN here>'

You can see this is a pretty straight forward loop that utilizes the Boto3 library in order to collect all of the identities.

Feel free to use this code however you want and if you have any questions reach out via email or social media!



, ,




Leave a Reply