Created
August 14, 2020 05:37
-
-
Save rbalman/19079e96410ff59c1a65324ddfac0352 to your computer and use it in GitHub Desktop.
Get AWS SQS queue attributes of multiple queues
This file contains hidden or 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
#!/bin/bash | |
if [ -z ${AWS_PROFILE} ] | |
then | |
echo "AWS_PROFILE is not set" | |
exit | |
fi | |
if [ -z ${AWS_REGION} ] | |
then | |
echo "AWS_REGION is not set" | |
exit | |
fi | |
if [ -z ${SEPARATOR} ] | |
then | |
echo "SEPARATOR is not set" | |
exit | |
fi | |
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query "Account" --profile ${AWS_PROFILE} --region ${AWS_REGION}) | |
export PREFIX="https://sqs.us-east-1.amazonaws.com/${ACCOUNT_ID}" | |
function qattrs() { | |
qname="${1}" | |
endpoint="${PREFIX}/${qname}" | |
echo "ENDPOINT: ${endpoint}" | |
aws sqs get-queue-attributes --queue-url "${endpoint}" --attribute-names ApproximateNumberOfMessages ApproximateNumberOfMessagesNotVisible --profile "${AWS_PROFILE}" --region "${AWS_REGION}" | |
} | |
export -f qattrs | |
script=$(basename "$0") | |
cat /tmp/${script} | awk -F ${SEPARATOR} '{print $2}' | xargs -I {} bash -c 'qattrs "$@"' _ {} | |
###### INPUT | |
###- first-queue | |
###- 2nd-queue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment