我可以将 aws rds 快照查询的结果限制在特定时间范围内吗?

Can I limit the results of an aws rds snapshot query to a certain timeframe?

我使用以下查询查找在特定日期之后创建的所有 rds 快照:

aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json

我现在要做的是将结果限制在所需时间点的两小时内,例如>=Date1,但 <=Date2.

到目前为止,我的方法是尝试向查询添加第二个参数,如下所示:

aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date1`<=`Date2`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json

但这会导致返回一个空列表。

如果不使用 jq,我在这里尝试做的事情是否可行?

最后答案很简单,不同的查询条件可以很容易地用一个&&运算符组合起来。所以在这种情况下,解决方案是:

aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date1`&&SnapshotCreateTime<=`Date2`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json