Skip to content

Commit

Permalink
add gp3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Struijk authored and betesh-at-data-axle committed Oct 27, 2022
1 parent e63d0f6 commit a2bf003
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/chef/knife/ec2_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a2bf003

Please sign in to comment.