Skip to content

Instantly share code, notes, and snippets.

@jasonco-dev
Forked from aheld/get_rds_tags
Created January 19, 2022 21:28
Show Gist options
  • Save jasonco-dev/0ac76f11e53d80c705d683d0f72175e9 to your computer and use it in GitHub Desktop.
Save jasonco-dev/0ac76f11e53d80c705d683d0f72175e9 to your computer and use it in GitHub Desktop.
get RDS tags using AWS cli , this really seems too complicated
#!/bin/bash
REGION="us-east-1"
PROFILE="prod"
get_account_id(){
aws ec2 describe-security-groups \
--group-names 'Default' \
--query 'SecurityGroups[0].OwnerId' \
--output text \
--profile "$PROFILE"
}
ACCOUNT_ID=$(get_account_id)
list_rds() {
aws rds describe-db-instances \
--query "DBInstances[].[DBInstanceIdentifier]" \
--output text \
--profile "$PROFILE"
}
get_rds_tags() {
aws rds list-tags-for-resource --resource-name "$1" \
--query "TagList[]" \
--output text \
--profile "$PROFILE"
# --query "TagList[?Key == 'vnoc-rsg']" \
# --query "TagList[?(Key =='project' ||Key == 'vnoc-rsg')]" \
}
for id in $(list_rds)
do
echo arn:aws:rds:$REGION:$ACCOUNT_ID:db:$id
get_rds_tags arn:aws:rds:$REGION:$ACCOUNT_ID:db:$id
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment