Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample code to help identify an RDS database by a specified tag key and that tag's value. In this example, with a Name tag where the Name tag's value is VIPDatabase, it would look like this.
aws_region=$(/bin/curl -s | sed "s/.$//g")
RDSDatabaseARNIdentifier=$(aws --region "$aws_region" resourcegroupstaggingapi get-resources --resource-type-filters rds:db --query "ResourceTagMappingList[?Tags[? Key == '$TagKey' && Value == '$TagValue']].ResourceARN" --output=text)
RDSDatabaseDBIdentifier=$(aws rds --region "$aws_region" describe-db-instances --db-instance-identifier "$RDSDatabaseARNIdentifier" --query "*[].{DBInstanceIdentifier:DBInstanceIdentifier}" --output text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment