skip to Main Content

Hi I am trying to list only private snapshots of AWS EBS volumes through the AWS CLI and I couldn’t find any reference online to proceed. Could experts please help?

aws ec2 describe-snapshots --query 'Snapshots[*].[SnapshotId,VolumeId,VolumeSize,StartTime,Description]' --region eu-west-2 --output json   

2

Answers


  1. Since a private snapshot is one that is owned by you, you could limit the output to only be those that are owned by "self". Also, if you want the ones that are associated with a specific volume, then you can filter on that. For example:

    aws ec2 describe-snapshots --owner-ids self --filter Name=volume-id,Values=vol-060e26663d9fb1c67

    Of course, you’d want to replace the volume ID with your own.

    Login or Signup to reply.
  2. To adhere to best practises, watch out for large results. This can apply if you are working on larger architectures (i.e. many private snapshots).

    I use use pagination to make the result sets easier to parse/use.

    Example:

     aws ec2 describe-snapshots --query 'Snapshots[*].[SnapshotId,VolumeId,VolumeSize,StartTime,Description]' --region eu-west-2 --output json --max-results 20
    

    Here I used --max-results 20.

    For more information and AWS best practises regarding this: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination

    (see "Query requests for Amazon EC2" and section "Pagination")

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search