diff --git a/lib/chef/knife/ec2_server_create.rb b/lib/chef/knife/ec2_server_create.rb index af359a18..98bf615e 100644 --- a/lib/chef/knife/ec2_server_create.rb +++ b/lib/chef/knife/ec2_server_create.rb @@ -161,8 +161,9 @@ class Ec2ServerCreate < Chef::Knife::Bootstrap option :ebs_volume_type, long: "--ebs-volume-type TYPE", - description: "Possible values are standard (magnetic) | io1 | gp2 | sc1 | st1. Default is gp2", - default: "gp2" + description: "Possible values are standard (magnetic) | io1 | gp2 | gp3 | sc1 | st1. Default is gp3", + proc: Proc.new { |key| Chef::Config[:knife][:ebs_volume_type] = key }, + default: "gp3" option :ebs_provisioned_iops, long: "--provisioned-iops IOPS", @@ -626,8 +627,8 @@ def plugin_validate_options! exit 1 end - if config[:ebs_volume_type] && ! %w{gp2 io1 standard st1 sc1}.include?(config[:ebs_volume_type]) - ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2' or 'st1' or 'sc1'") + if config[:ebs_volume_type] && ! %w{gp2 gp3 io1 standard st1 sc1}.include?(config[:ebs_volume_type]) + ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2' or 'gp3' or 'st1' or 'sc1'") msg opt_parser exit 1 end @@ -682,8 +683,9 @@ def plugin_validate_options! # validation for ebs_size and ebs_volume_type and ebs_encrypted if !config[:ebs_size] errors << "--ebs-encrypted option requires valid --ebs-size to be specified." - elsif (config[:ebs_volume_type] == "gp2") && ! config[:ebs_size].to_i.between?(1, 16384) - errors << "--ebs-size should be in between 1-16384 for 'gp2' ebs volume type." + + elsif (config[:ebs_volume_type] =~ /^gp/) && ! config[:ebs_size].to_i.between?(1, 16384) + errors << "--ebs-size should be in between 1-16384 for 'gp*' ebs volume type." elsif (config[:ebs_volume_type] == "io1") && ! config[:ebs_size].to_i.between?(4, 16384) errors << "--ebs-size should be in between 4-16384 for 'io1' ebs volume type." elsif (config[:ebs_volume_type] == "standard") && ! config[:ebs_size].to_i.between?(1, 1024)