PowerShellで実行するコード
foreach ($region in (aws ec2 describe-regions --query "Regions[].RegionName" --output json | ConvertFrom-Json)) {
echo "region:${region}"
$queueUrls = (aws sqs list-queues --region $region --query 'QueueUrls' --output json | ConvertFrom-Json)
foreach ($queueUrl in $queueUrls) {
echo "delete-queue:$queueUrl"
aws sqs delete-queue --queue-url $queueUrl --region $region
}
}
実行結果(test1とtest2を削除した結果)
region:ap-south-1
region:eu-north-1
region:eu-west-3
delete-queue:https://sqs.eu-west-3.amazonaws.com/999999999999/test1
region:eu-west-2
region:eu-west-1
region:ap-northeast-3
region:ap-northeast-2
region:ap-northeast-1
delete-queue:https://sqs.ap-northeast-1.amazonaws.com/999999999999/test2
region:ca-central-1
region:sa-east-1
region:ap-southeast-1
region:ap-southeast-2
region:eu-central-1
region:us-east-1
region:us-east-2
region:us-west-1
region:us-west-2