Automating Deletion of Suppression List in AWS SES
Mithun Satyanarayana
Dynamic Senior SRE & DevOps Engineer | Expert in SDLC & Agile | Mastery in AWS, Azure, GCP, Terraform, Kubernetes, Jenkins | Ex-HARMAN AWS DevOps Champion | H1B Visa Holder
Are you managing a large number of suppressed email addresses in Amazon SES? Automating the deletion process can save you time and effort. In this article, we'll walk through a step-by-step guide to automate the deletion of suppressed destinations in AWS SES using the AWS CLI and a simple shell script.
Prerequisites
Before getting started, make sure you have the following:
- An AWS account with SES access.
- AWS CLI installed and configured with your AWS credentials.
- Basic knowledge of shell scripting.
Step 1: List Suppressed Destinations
First, let's list the suppressed destinations and save them to a file named list.txt.
```shell
aws sesv2 list-suppressed-destinations | grep -i "EmailAddress" | awk -F ":" '{print $2}' > list.txt
```
This command retrieves the list of suppressed email addresses and stores them in list.txt.
Step 2: Delete Suppressed Destinations
Next, we'll read the list.txt file line by line and delete each suppressed destination.
```shell
while read -r email; do
aws sesv2 delete-suppressed-destination --email-address "$email"
done < list.txt
```
This loop reads each email address from list.txt and deletes it from the suppression list using the delete-suppressed-destination command.
领英推荐
Step 3: Automate the Process
To automate this process, create a shell script delete_suppressed.sh with the following content:
```shell
#!/bin/bash
aws sesv2 list-suppressed-destinations | grep -i "EmailAddress" | awk -F ":" '{print $2}' > list.txt
while read -r email; do
aws sesv2 delete-suppressed-destination --email-address "$email"
done < list.txt
rm list.txt
```
Make the script executable:
```shell
chmod +x delete_suppressed.sh
```
Now, you can run this script whenever you need to delete suppressed destinations in your SES account:
```shell
./delete_suppressed.sh
```
Conclusion
Automating the deletion of suppressed destinations in AWS SES can help you manage your suppression list more efficiently, especially when dealing with a large number of email addresses. By following the steps outlined in this article, you can save time and reduce manual errors in managing your SES suppression list.
#AWSSES #suppressionlist management, #AWSCLI, #shellscripting #emailmanagement #automation