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

Insert conditional to avoid error for non T2/T3 instance #616

Merged
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
11 changes: 6 additions & 5 deletions lib/chef/knife/ec2_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class Ec2ServerCreate < Chef::Knife::Bootstrap
option :cpu_credits,
long: "--cpu-credits CPU_CREDITS",
description: "The credit option for CPU usage of the instance. Valid values are standard and unlimited. T3 instances launch as unlimited by default. T2 instances launch as standard by default.",
default: "standard",
in: %w{standard unlimited}

def plugin_create_instance!
Expand Down Expand Up @@ -984,10 +983,12 @@ def server_attributes

attributes[:instance_initiated_shutdown_behavior] = config_value(:instance_initiated_shutdown_behavior)

attributes[:credit_specification] =
{
cpu_credits: config[:cpu_credits],
}
if config[:cpu_credits]
attributes[:credit_specification] =
{
cpu_credits: config[:cpu_credits],
}
end
attributes
end

Expand Down