Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To utilize jq with streams to parse information about Amazon's RDS instances, you can use the following method:

  1. Use the AWS CLI to get a stream of RDS instances in JSON format:
aws rds describe-db-instances --output json --query "DBInstances[*]" --stream
  1. Pipe the stream into jq to filter and extract the desired information. For example, to extract the ID, name, and status of each RDS instance:
aws rds describe-db-instances --output json --query "DBInstances[*]" --stream | jq -c '{id: .DBInstanceIdentifier, name: .DBName, status: .DBInstanceStatus}'

This command uses the -c option to output each result as a single line of JSON for easier parsing and manipulation.

  1. You can further filter and manipulate the output using the full range of jq's capabilities. For example, to extract only the IDs of RDS instances that are running:
aws rds describe-db-instances --output json --query "DBInstances[*]" --stream | jq -r '.[] | select(.DBInstanceStatus == "available") | .DBInstanceIdentifier'

This command uses the -r option to output the result as raw text, and the select filter to only include instances with a status of "available".