0

I'm trying to obtain the latest RDS Snapshot using the AWS SDK (Java, specifically). This has been asked and solved before using the AWS CLI (How to find latest or most recent AWS RDS snapshot?)

The proposed solutions all involve the --query param which is conspicuously absent in the SDK:

aws rds describe-db-snapshots \
  --query="reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0]"

Is there any way to do this using the SDK or do I have to get all of the paginated snapshots, gather the dates, and then sort and select the most recent?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
nao
  • 1,128
  • 1
  • 14
  • 37

1 Answers1

2

The --query parameter in the AWS Command-Line Interface (CLI) merely filters the output fields that are returned by the command.

The reverse() and sort_by functionality is implemented locally within the AWS CLI using the JMESPath library. Your program that calls the SDK direcctly would need to perform such logic itself. This wouldn't be very difficult, since it would just involve sorting lists of values.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470