Search code examples
amazon-web-servicesamazon-rds

Is there a way to query AWS RDS instance by its tag values?


As per this https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-instances.html, you can only filter RDS instances with the following filters --filters (list)

db-cluster-id
db-instance-id
dbi-resource-id 
domain
engine

In my AWS environment, I have consistent tags for the service/application and env. Thus, I want to retrieve RDS instances by their tags similar to what we do with EC2s.

Has someone gotten around it?


Solution

  • If you wanna get all the RDS instances that have tag key TAG_KEY and tag value TAG_VAL:

    aws rds describe-db-instances --query 'DBInstances[?contains(TagList[].Key, `TAG_KEY`) && contains(TagList[].Value, `TAG_VAL`)]'