91

Script to automatically change all gp2 volumes to gp3 with aws-cli. You need fir...

 2 years ago
source link: https://gist.github.com/jmartinezl/e54f7d32a4b26d389a58c5dfc99f6a26
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Script to automatically change all gp2 volumes to gp3 with aws-cli. You need first to install jq · GitHub

Instantly share code, notes, and snippets.

Script to automatically change all gp2 volumes to gp3 with aws-cli. You need first to install jq

#! /bin/bash

region='us-west-2'

# Find all gp2 volumes within the given region volume_ids=$(/usr/bin/aws ec2 describe-volumes --region "${region}" --filters Name=volume-type,Values=gp2 | jq -r '.Volumes[].VolumeId')

# Iterate all gp2 volumes and change its type to gp3 for volume_id in ${volume_ids};do result=$(/usr/bin/aws ec2 modify-volume --region "${region}" --volume-type=gp3 --volume-id "${volume_id}" | jq '.VolumeModification.ModificationState' | sed 's/"//g') if [ $? -eq 0 ] && [ "${result}" == "modifying" ];then echo "OK: volume ${volume_id} changed to state 'modifying'" else echo "ERROR: couldn't change volume ${volume_id} type to gp3!" fi done


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK