lib/chef/knife/ec2_server_create.rb in knife-ec2-1.0.32 vs lib/chef/knife/ec2_server_create.rb in knife-ec2-1.0.33

- old
+ new

@@ -621,11 +621,11 @@ end if config[:associate_eip] eips = ec2_connection.describe_addresses.addresses.collect { |addr| addr if addr.domain == eip_scope }.compact - unless eips.detect { |addr| addr.public_ip == config[:associate_eip] && addr.instance_id.nil? } + unless eips.detect { |addr| addr.public_ip == config[:associate_eip] && (addr.instance_id.nil? || addr.instance_id.empty?) } ui.error("Elastic IP requested is not available.") exit 1 end end @@ -856,11 +856,10 @@ def server_attributes attributes = { image_id: config_value(:image), instance_type: config_value(:flavor), - groups: config[:security_groups], key_name: config_value(:ssh_key_name), max_count: 1, min_count: 1, placement: { availability_zone: config_value(:availability_zone), @@ -876,10 +875,12 @@ if vpc_mode? network_attrs[:groups] = config_value(:security_group_ids) if !!config_value(:security_group_ids) network_attrs[:private_ip_address] = config_value(:private_ip_address) network_attrs[:associate_public_ip_address] = config_value(:associate_public_ip) + else + attributes[:security_groups] = config[:security_groups] end if network_attrs.length > 0 network_attrs[:device_index] = 0 attributes[:network_interfaces] = [network_attrs] @@ -1197,13 +1198,20 @@ Chef::Config[:knife][:ssh_identity_file] = file.path puts "\nGenerated keypair file: #{file.path}" end def associate_address(elastic_ip) - ec2_connection.associate_address({ - allocation_id: elastic_ip.allocation_id, - instance_id: server.id, - }) + if vpc_mode? + ec2_connection.associate_address({ + allocation_id: elastic_ip.allocation_id, + instance_id: server.id, + }) + else + ec2_connection.associate_address({ + public_ip: elastic_ip.public_ip, + instance_id: server.id, + }) + end end def validate_nics! params = {} if vpc_mode?