Last active
October 11, 2024 08:51
-
-
Save cahva/bf03dc2d853b38f9d5b1c40ed3d786f5 to your computer and use it in GitHub Desktop.
Get suppressed emails from SES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# Get aws sesv2 list-suppressed-destinations | |
# It will have a json output and has format like this: | |
# { | |
# "SuppressedDestinationSummaries": [ | |
# { | |
# "EmailAddress": "string", | |
# "LastUpdateTime": "string", | |
# "Reason": "string" # BOUNCE | COMPLAINT | |
# } | |
# ], | |
# "NextToken": "string" # This is not here if there are no more results to be fetched | |
# } | |
# | |
# If nextToken is not empty, it means there are more results to be fetched. | |
# We can use the nextToken to fetch the next results. | |
# | |
# Get the suppressed destinations | |
function get_suppressed_destinations() { | |
local nextToken="" | |
while true; do | |
local cmd="aws sesv2 list-suppressed-destinations" | |
if [ -n "$nextToken" ]; then | |
cmd="$cmd --next-token $nextToken" | |
fi | |
local result=$(eval $cmd) | |
local suppressedDestinations=$(echo $result | jq -r '.SuppressedDestinationSummaries') | |
local nextToken=$(echo $result | jq -r '.NextToken') | |
echo $suppressedDestinations | |
if [ -z "$nextToken" ]; then | |
break | |
fi | |
done | |
} | |
# Get the suppressed destinations | |
suppressedDestinations=$(get_suppressed_destinations) | |
# Print the suppressed destinations | |
echo $suppressedDestinations | jq -r '.[] | "\(.EmailAddress), Reason: \(.Reason)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment