Prerequisite: Install the ec2 command line tool. Follow the instructions from here.
You may need to change the region and url. Anyways, here you go.
#!/bin/bash
export EC2_REGION=us-east-1
export EC2_URL=https://us-east-1.ec2.amazonaws.com
zone=us-east-1c
# Ask for size of volume to create
echo "Enter volume size between 10-1024 GB, then hit return"
read volume_size
echo "Validating value..."
if [[ $volume_size =~ ^[0-9]+$ ]]; then
echo "..."
else
echo "Value must be an integer"
exit 1
fi
if (( $volume_size < 10 )) || (( $volume_size > 1024 )); then
echo "Value must be between 10-1024 GB"
exit 1
fi
#if (( $volume_size > 1024 )); then
# echo "Value must be between 10-1024 GB"
# exit 1
#fi
echo "Creating $volume_size EBS volume now..."
# create ebs volume
ec2-create-volume -s $volume_size -z $zone
echo "Request complete. Keep reference of volume id above"
No comments:
Post a Comment