@@ -0,0 +1,2397 @@
+import boto3%0Aimport csv%0Afrom datetime import datetime%0Afrom pprint import pprint%0Aimport os%0A%0Aclient = boto3.client('sqs', region_name=os.getenv('AWS_REGION'))%0A%0A%0Adef _formatted_date_from_timestamp(timestamp):%0A    return datetime.fromtimestamp(%0A        int(timestamp)%0A    ).strftime('%25Y-%25m-%25d %25H:%25M:%25S')%0A%0A%0Adef get_queues():%0A    response = client.list_queues()%0A    queues = response%5B'QueueUrls'%5D%0A    return queues%0A%0A%0Adef get_queue_attributes(queue_name):%0A    response = client.get_queue_attributes(%0A        QueueUrl=queue_name,%0A        AttributeNames=%5B%0A            'All'%0A        %5D%0A    )%0A    queue_attributes = response%5B'Attributes'%5D%0A    return queue_attributes%0A%0A%0Adef delete_queue(queue_name):%0A    response = client.delete_queue(%0A        QueueUrl=queue_name%0A    )%0A    if response%5B'ResponseMetadata'%5D%5B'HTTPStatusCode'%5D == 200:%0A        print('Deleted queue successfully')%0A    else:%0A        print('Error occured when attempting to delete queue')%0A        pprint(response)%0A    return response%0A%0A%0Adef output_to_csv(queue_attributes):%0A    csv_name = 'queues.csv'%0A    with open(csv_name, 'w') as csvfile:%0A        fieldnames = %5B%0A            'Queue Name',%0A            'Number of Messages',%0A            'Number of Messages Delayed',%0A            'Number of Messages Not Visible',%0A            'Created'%0A        %5D%0A        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)%0A        writer.writeheader()%0A        for queue_attr in queue_attributes:%0A            queue_url = client.get_queue_url(%0A                QueueName=queue_attr%5B'QueueArn'%5D%0A            )%5B'QueueUrl'%5D%0A            writer.writerow(%7B%0A                'Queue Name': queue_attr%5B'QueueArn'%5D,%0A                'Queue URL': queue_url,%0A                'Number of Messages': queue_attr%5B'ApproximateNumberOfMessages'%5D,%0A                'Number of Messages Delayed': queue_attr%5B'ApproximateNumberOfMessagesDelayed'%5D,%0A                'Number of Messages Not Visible': queue_attr%5B'ApproximateNumberOfMessagesNotVisible'%5D,%0A                'Created': _formatted_date_from_timestamp(queue_attr%5B'CreatedTimestamp'%5D)%0A            %7D)%0A    return csv_name%0A%0A%0Adef read_from_csv(csv_name):%0A    queue_urls = %5B%5D%0A    with open(csv_name, 'r') as csvfile:%0A        next(csvfile)%0A        rows = csv.reader(csvfile, delimiter=',')%0A        for row in rows:%0A            queue_urls.append(row%5B1%5D)%0A    return queue_urls%0A%0A%0Aqueues = get_queues()%0Afor queue in queues:%0A    delete_queue(queue)%0A

Add a script to delete sqs queues: * Uses boto to retrieve/delete queues * Additional functions to output/read from csv