Skip to content

Instantly share code, notes, and snippets.

@joker1007
Created March 30, 2021 12:22
Show Gist options
  • Save joker1007/49f6d65f6672a1ae27ef1b9544ea77e3 to your computer and use it in GitHub Desktop.
Save joker1007/49f6d65f6672a1ae27ef1b9544ea77e3 to your computer and use it in GitHub Desktop.
extend_ebs.sh
instance_ids=""
device_name=""
for vol in $(aws ec2 describe-instances --region ap-northeast-1 --instance-ids ${instance_ids} | jq '.Reservations[].Instances[] | .BlockDeviceMappings[] | select(.DeviceName == "'${device_name}'") | .Ebs.VolumeId' -r); do
current=$(aws ec2 describe-volumes --volume-ids ${vol} | jq '.Volumes[] | .Size')
target=$(expr $current + 50)
echo "${vol}: ${current} -> ${target}"
echo "aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run"
#aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment