Created
May 28, 2025 11:34
-
-
Save NeilMasters/8d5d5390246439db83e43b6d7db83e74 to your computer and use it in GitHub Desktop.
Purge SQS queues that match a provided prefix
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/bash | |
PREFIX=$1 | |
DRY_RUN=$2 | |
REGION=$3 | |
echo "Starting the purge of queues that have the prefix of ${PREFIX}" | |
# Get the list of queues with the $ PREFIX and store as a block of json | |
QUEUES=$(aws sqs list-queues --region "${REGION}" --queue-name-prefix=${PREFIX} | jq '.QueueUrls') | |
echo $QUEUES > /tmp/queues.json | |
jq -r '.[]' /tmp/queues.json | while read QUEUE; do | |
if [[ ${DRY_RUN} == "no" ]] | |
then | |
echo "Deleting ${QUEUE}" | |
aws sqs delete-queue --region "${REGION}" --queue-url "${QUEUE}" | |
else | |
echo "[DRY RUN] Deleting ${QUEUE}" | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment