Last active
March 16, 2024 22:08
-
-
Save rochacon/703d92f485f5c1a4e9bf920127d6b4e5 to your computer and use it in GitHub Desktop.
Bun shell experiments
This file contains 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
// this script lists all queues with a message count diferrent than 0 | |
// usage: bun list-queues-sizes.ts | |
import { $ } from 'bun'; | |
const queuesUrls = await $`aws sqs list-queues`.json(); | |
const attrs = "QueueArn ApproximateNumberOfMessages ApproximateNumberOfMessagesNotVisible ApproximateNumberOfMessagesDelayed"; | |
const queueAttributes = await Promise.all(queuesUrls.QueueUrls.map((url) => ( | |
$`aws sqs get-queue-attributes --attribute-names ${{ raw: attrs }} --queue-url ${url}`.quiet().json() | |
))); | |
const output = queueAttributes.filter((e) => e.Attributes.ApproximateNumberOfMessages !== "0").map((e) => e.Attributes); | |
console.table(output); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment