Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resalloc-aws-new: add root-volume-size option #7

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions bin/resalloc-aws-new
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Options:
--spot-price PRICE Start a spot instance, instead of (default) on-demand,
with the given maximal price per hour.
--playbook PLAYBOOK Use this playbook, instead of the pre-configured one.
--root-volume-size GB
Allocate root volume of given size.
--additional-volume-size GB
Allocate additional volume of given size.
--private-ip This VM starts on private IP, work over private IP.
Expand Down Expand Up @@ -92,7 +94,7 @@ run_cmd()
test "${#@}" -eq 0 && show_help 1

long_opts="name:,ami:,initial-preparation,create-snapshot-image,help,spot-price:,\
playbook:,private-ip,debug,additional-volume-size:,no-print-ip,aws-profile:,\
playbook:,private-ip,debug,root-volume-size:,additional-volume-size:,no-print-ip,aws-profile:,\
ssh-key-name:,security-group-id:,possible-subnet:,instance-type:,tag:"
ARGS=$( getopt -o "h" -l "$long_opts" -n "getopt" -- "$@") || show_help 1

Expand All @@ -109,6 +111,7 @@ mandatory_options="
eval set -- "$ARGS"

opt_initial_preparation=false
opt_root_volume_size=
opt_additional_volume_size=
opt_create_snapshot_image=false
opt_ami=
Expand Down Expand Up @@ -145,7 +148,7 @@ while true; do
show_help 0
;;

--name|--ami|--spot-price|--playbook|--additional-volume-size|\
--name|--ami|--spot-price|--playbook|--root-volume-size|--additional-volume-size|\
--aws-profile|--ssh-key-name|--security-group-id|--instance-type)
option_variable "$1"
eval "$option_variable_result=\$2"
Expand Down Expand Up @@ -266,7 +269,14 @@ InstanceInterruptionBehavior=terminate,SpotInstanceType=one-time}"
fi

# Use gp3 volume for the root filesystem
device_mappings='{"DeviceName":"/dev/sda1","Ebs":{"VolumeType":"gp3"}}'
device_mappings='{"DeviceName":"/dev/sda1","Ebs":{"VolumeType":"gp3"'

if test -n "$opt_root_volume_size"; then
device_mappings+=',"VolumeSize":'
device_mappings+=$opt_root_volume_size
fi

device_mappings+='}}'

if test -n "$opt_additional_volume_size"; then
device_mappings+=',{"DeviceName":"/dev/sdd","Ebs":{"VolumeSize":'
Expand Down