Get Volume ID of a Volume, if it exists

Get Volume ID of a Volume, if it exists
volume_name="Name of your volume"
volume_id=`aws ec2 describe-volumes --filters Name=tag-key,Values=diskuse,Name=tag-value,Values=${volume_name}  |jq -r --arg zone "$zone" '[.Volumes[] | select( (.State=="available") and (.AvailabilityZone==$zone))][0] | .VolumeId'`

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: