#!/bin/bash PREFIX=$1 DRY_RUN=$2 echo "Starting the purge of queues that have the prefix of ${PREFIX}" while true do # Get the list of queues with the PREFIX and store as a block of json QUEUES=$(aws-vault exec $AWS_PROFILE -- aws sqs list-queues --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-vault exec $AWS_PROFILE -- aws sqs delete-queue --region eu-west-2 --queue-url "${QUEUE}" else echo "[DRY RUN] Deleting ${QUEUE}" fi done; done