代码之家  ›  专栏  ›  技术社区  ›  Willem van Ketwich

AWS CLI-如何查询特定日期后创建的快照

  •  2
  • Willem van Ketwich  · 技术社区  · 7 年前

    我试图查询特定日期后创建的快照,但没有返回任何结果。我正在尝试的查询如下:

    aws ec2 describe-snapshots --query 'Snapshots[?StartTime >= `2017-06-01`].{id:SnapshotId}' --owner-ids nnnnnnnnnnn
    

    我试着检查 JMESPath docs here 无济于事。

    谢谢

    2 回复  |  直到 7 年前
        1
  •  5
  •   John Rotenstein    7 年前

    在快照上找到日期,然后将该日期放入查询中——在前一天,然后在后一天再次运行它。这应该有助于你追踪这种奇怪的行为。

    $ aws ec2 describe-snapshots --query 'Snapshots[?StartTime >= `2016-08-30`].{id:SnapshotId}' --owner-ids 123456789012
    [
        {
            "id": "snap-e044d613"
        }, 
        {
            "id": "snap-f4444506"
        }
    ]
    
    $ aws ec2 describe-snapshots --query 'Snapshots[?StartTime >= `2016-08-31`].{id:SnapshotId}' --owner-ids 123456789012
    []
    
        2
  •  0
  •   manish jha    5 年前

    aws ec2 describe-snapshots --owner self --output json | jq '.Snapshots[] | select(.StartTime > "2019-12-18")'