How can I list Amazon Elastic Block Store (Amazon EBS) volume or snapshot information for my Amazon Elastic Compute Cloud (Amazon EC2) instance using the AWS Command Line Interface (AWS CLI)?

Find all snapshots over 1 month old

The following command lists all EBS snapshots using the describe-snapshots operation, where the time stamp is older than one month (--date='-1 month').

$ aws ec2 describe-snapshots --owner self | jq '.Snapshots[] | select(.StartTime < "'$(date --date='-1 month' '+%Y-%m-%d')'") | [.Description, .StartTime, .SnapshotId]'

List snapshots over 1 month old in all Regions

The following example command uses the same command as in the first example. It also loops through snapshots in all Regions using the describe-regions operation.

$ for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]') ; do echo $REGION && aws ec2 describe-snapshots --owner self --region $REGION | jq '.Snapshots[] | select(.StartTime < "'$(date --date='-1 month' '+%Y-%m-%d')'") | [.Description, .StartTime, .SnapshotId]' ; done

Find all publicly available snapshots in an AWS account in all Regions

This example command lists all snapshots where the CreateVolumePermission Group is equal to all, for all Regions.

$ for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]') ; do echo "$REGION:"; for snap in $(aws ec2 describe-snapshots --owner self --region $REGION --query 'Snapshots[*].SnapshotId' | jq -r '.[]'); do aws ec2 describe-snapshot-attribute --snapshot-id $snap --region $REGION --attribute createVolumePermission --query '[SnapshotId,CreateVolumePermissions[?Group == `all`]]' | jq -r '.[]'; done; echo; done

Get the status of all volumes currently in the optimizing stage (after volume modification) in all Regions

The following example command lists all volumes by using the describe-volumes-modifications operation, where the modification-state is set to the value of optimizing, for all Regions.

$ for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]') ; do echo $REGION && aws ec2 describe-volumes-modifications --query 'VolumesModifications[].{VolumeID:VolumeId,TargetSize:TargetSize,OriginalSize:OriginalSize,Progress:Progress,OriginalIops:OriginalIops,TargetIops:TargetIops}' --output json --filter 'Name=modification-state,Values=optimizing' --region $REGION; done

Find all volumes not attached to any instance in all Regions

This example command lists volumes where the status is set to available, for all Regions.

$ for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]') ; do echo $REGION && aws ec2 describe-volumes --filter "Name=status,Values=available" --query 'Volumes[*].{VolumeID:VolumeId,Size:Size,Type:VolumeType,AvailabilityZone:AvailabilityZone}' --region $REGION; done

Find all volumes in the "error" state in all Regions

The following example command describes all volumes, in all Regions, where the status is set to error.

$ for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]') ; do echo $REGION && aws ec2 describe-volumes --filter "Name=status,Values=error" --query 'Volumes[*].{VolumeID:VolumeId,Size:Size,Type:VolumeType,AvailabilityZone:AvailabilityZone}' --region $REGION; done

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2019-03-29