lib/chef/knife/helpers/ec2_base.rb in knife-ec2-2.1.0 vs lib/chef/knife/helpers/ec2_base.rb in knife-ec2-2.1.1

- old
+ new

@@ -149,11 +149,11 @@ server_data["groups"] = server_obj.groups.map(&:group_name) unless vpc_mode? server_data["iam_instance_profile"] = ( server_obj.instances[0].iam_instance_profile.nil? ? nil : server_obj.instances[0].iam_instance_profile.arn[%r{instance-profile/(.*)}] ) server_data["id"] = server_data["instance_id"] tags = server_obj.instances[0].tags.map(&:value) - server_data["name"] = tags[0] + server_data["name"] = find_name_tag(server_obj.instances[0].tags) server_data["placement_group"] = server_obj.instances[0].placement.group_name server_data["security_groups"] = server_obj.instances[0].security_groups.map(&:group_name) server_data["security_group_ids"] = server_obj.instances[0].security_groups.map(&:group_id) server_data["state"] = server_obj.instances[0].state.name server_data["subnet_id"] = server_obj.instances[0].network_interfaces[0].subnet_id if vpc_mode? @@ -177,9 +177,16 @@ end end def ami @ami ||= fetch_ami(config[:image]) + end + + # Name tag value return. + # @return [String] + def find_name_tag(tags) + name_tag = tags.find { |tag| tag[:key] == "Name" } + name_tag ? name_tag[:value] : nil end # Platform value return for Windows AMIs; otherwise, it is blank. # @return [Boolean] def is_image_windows?