Export AWS SES suppressed Email list to S3

0

The primary way of exporting a list of suppressed email is through CLI. but is there a way to export these suppressed emails to S3 in CSV if yes how do I go about it? all suggestions are welcomed.

1 Answer
0

Hello.

There is an AWS CLI command that retrieves the list of email addresses registered in the suppression list, so I think it is possible to do this by creating a shell script using that command.
https://docs.aws.amazon.com/ses/latest/dg/sending-email-suppression-list.html#sending-email-suppression-list-view-entries

aws sesv2 list-suppressed-destinations

Running the above command will give you the following output:
I think it would be a good idea to process this and create a CSV.

{
    "SuppressedDestinationSummaries": [
        {
            "EmailAddress": "recipient2@example.com",
            "Reason": "COMPLAINT",
            "LastUpdateTime": "2020-04-10T21:03:05Z"
        },
        {
            "EmailAddress": "recipient0@example.com",
            "Reason": "COMPLAINT",
            "LastUpdateTime": "2020-04-10T21:04:26Z"
        },
        {
            "EmailAddress": "recipient1@example.com",
            "Reason": "BOUNCE",
            "LastUpdateTime": "2020-04-10T22:07:59Z"
        }
    ]
}

I think it is possible by combining the "jq" commands as shown below.

aws sesv2 list-suppressed-destinations | jq -r '.SuppressedDestinationSummaries[] | [.EmailAddress, .Reason] | @csv' > suppression_list.csv

Once processed into CSV, you can upload it to S3 using the "aws s3 cp" command.

aws s3 cp ./suppression_list.csv s3://test-s3
profile picture
EXPERT
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions