Skip to content

Instantly share code, notes, and snippets.

@rochacon
Last active March 16, 2024 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rochacon/703d92f485f5c1a4e9bf920127d6b4e5 to your computer and use it in GitHub Desktop.
Save rochacon/703d92f485f5c1a4e9bf920127d6b4e5 to your computer and use it in GitHub Desktop.
Bun shell experiments
// 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