Bulk Delete Queues in AWS

This is a post to myself. Due to a faulty application we have a lot of dead queues in AWS SQS. To get rid of them I wrote the following script that I executed in a container that has the AWS CLI installed

queues=$(aws sqs list-queues --queue-name-prefix $prefix)
for q in ${queues[@]}
  if [ "${q:0:1}" == "\"" ]; then
          if [ $x != "QueueUrls" ]; then
                  aws sqs delete-queue --queue-url $x

The script is quick and dirty and deals with the fact that the AWS CLI returns the list of queues as a JSON array.

About Gabriel Schenker

Gabriel N. Schenker started his career as a physicist. Following his passion and interest in stars and the universe he chose to write his Ph.D. thesis in astrophysics. Soon after this he dedicated all his time to his second passion, writing and architecting software. Gabriel has since been working for over 25 years as a consultant, software architect, trainer, and mentor mainly on the .NET platform. He is currently working as senior software architect at Alien Vault in Austin, Texas. Gabriel is passionate about software development and tries to make the life of developers easier by providing guidelines and frameworks to reduce friction in the software development process. Gabriel is married and father of four children and during his spare time likes hiking in the mountains, cooking and reading.
This entry was posted in AWS, How To and tagged , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post.