lib/chef/knife/ec2_server_create.rb in knife-ec2-1.0.26 vs lib/chef/knife/ec2_server_create.rb in knife-ec2-1.0.28
- old
+ new
@@ -574,10 +574,11 @@
end
# When options connection_protocol and connection_port are not provided
# It will set as default
def plugin_setup!
+ validate_aws_config!(%i{image aws_access_key_id aws_secret_access_key})
config[:connection_protocol] ||= connection_protocol_ec2
config[:connection_port] ||= connection_port
end
def validate_name_args!
@@ -590,12 +591,10 @@
Chef::Config[:knife].delete(:aws_ssh_key_id)
ui.warn("Use of aws_ssh_key_id option in knife.rb/config.rb config is deprecated, use ssh_key_name option instead.")
end
create_key_pair unless config_value(:ssh_key_name)
- validate_aws_config!(%i{image ssh_key_name aws_access_key_id aws_secret_access_key})
-
validate_nics! if config_value(:network_interfaces)
if ami.nil?
ui.error("The provided AMI value '#{config_value(:image)}' could not be found. Is this AMI availble in the provided region #{config_value(:region)}?")
exit 1
@@ -1395,10 +1394,9 @@
# we'll use the one that you gave in the URL.
def connection_protocol_ec2
return @connection_protocol_ec2 if @connection_protocol_ec2
default_protocol = is_image_windows? ? "winrm" : "ssh"
-
from_url = host_descriptor =~ %r{^(.*)://} ? $1 : nil
from_cli = config[:connection_protocol]
from_knife = Chef::Config[:knife][:connection_protocol]
@connection_protocol_ec2 = from_url || from_cli || from_knife || default_protocol
end