# File lib/aws/ec2/instance_collection.rb, line 211
      def create options = {}

        if profile = options.delete(:iam_instance_profile)
          profile = case profile
          when /^arn:aws:iam::/ then { :arn => profile }
          when String then { :name => profile }
          when Hash then profile
          else
            msg = "expected a name or ARN string for :iam_instance_profile"
          end
          options[:iam_instance_profile] = profile
        end

        if image = options.delete(:image)
          options[:image_id] = image.id
        end

        if kernel = options.delete(:kernel)
          options[:kernel_id] = kernel.id
        end

        if ramdisk = options.delete(:ramdisk)
          options[:ramdisk_id] = ramdisk.id
        end

        if key_pair = options.delete(:key_pair)
          options[:key_name] = key_pair.name
        end

        options = count_options(options).merge(options)
        options.delete(:count)

        options[:user_data] = Base64.encode64(options[:user_data]).strip if
          options[:user_data]

        if options[:block_device_mappings].is_a?(Hash)
          options[:block_device_mappings] =
            translate_block_device_mappings(options[:block_device_mappings])
        end

        options[:monitoring] = { :enabled => true } if
          options[:monitoring_enabled]
        options.delete(:monitoring_enabled)

        placement = {}

        if options[:availability_zone]
          placement[:availability_zone] = options[:availability_zone].to_s
          options.delete(:availability_zone)
        end

        if options[:placement_group]
          placement[:group_name] = options[:placement_group].to_s
          options.delete(:placement_group)
        end

        if options[:dedicated_tenancy]
          placement[:tenancy] = 'dedicated'
          options.delete(:dedicated_tenancy)
        end

        options[:placement] = placement unless placement.empty?

        network_interface = {}

        if options[:associate_public_ip_address]
          if subnet_id = subnet_id_option(options)
            network_interface[:subnet_id] = subnet_id
            options.delete(:subnet)
            options.delete(:subnet_id)
          end
          if private_ip_address = options.delete(:private_ip_address)
            network_interface[:private_ip_address] = private_ip_address
          end
          if security_group_ids = options.delete(:security_group_ids)
            network_interface[:groups] = Array(security_group_ids)
          end
          network_interface[:associate_public_ip_address] = true
          network_interface[:device_index] = 0
        end
        options.delete(:associate_public_ip_address)

        options[:network_interfaces] = [network_interface] unless network_interface.empty?

        if subnet_id = subnet_id_option(options)
          options[:subnet_id] = subnet_id
        end

        security_group_opts(options)

        options[:client_token] = SecureRandom.uuid

        resp = client.run_instances(options)

        if options[:min_count] == options[:max_count] and
            options[:min_count] == 1
          self[resp.instances_set.first.instance_id]
        else
          resp[:instances_set].map {|i| self[i[:instance_id]] }
        end
      end