'Runs an image on EC2.
:type image_id: string
:param image_id: The ID of the image to run.
:type min_count: int
:param min_count: The minimum number of instances to launch.
:type max_count: int
:param max_count: The maximum number of instances to launch.
:type key_name: string
:param key_name: The name of the key pair with which to
launch instances.
:type security_groups: list of strings
:param security_groups: The names of the EC2 classic security groups
with which to associate instances
:type user_data: string
:param user_data: The user data passed to the launched instances
:type instance_type: string
:param instance_type: The type of instance to run:
* t1.micro
* m1.small
* m1.medium
* m1.large
* m1.xlarge
* m3.medium
* m3.large
* m3.xlarge
* m3.2xlarge
* c1.medium
* c1.xlarge
* m2.xlarge
* m2.2xlarge
* m2.4xlarge
* cr1.8xlarge
* hi1.4xlarge
* hs1.8xlarge
* cc1.4xlarge
* cg1.4xlarge
* cc2.8xlarge
* g2.2xlarge
* c3.large
* c3.xlarge
* c3.2xlarge
* c3.4xlarge
* c3.8xlarge
* c4.large
* c4.xlarge
* c4.2xlarge
* c4.4xlarge
* c4.8xlarge
* i2.xlarge
* i2.2xlarge
* i2.4xlarge
* i2.8xlarge
* t2.micro
* t2.small
* t2.medium
:type placement: string
:param placement: The Availability Zone to launch the instance into.
:type kernel_id: string
:param kernel_id: The ID of the kernel with which to launch the
instances.
:type ramdisk_id: string
:param ramdisk_id: The ID of the RAM disk with which to launch the
instances.
:type monitoring_enabled: bool
:param monitoring_enabled: Enable detailed CloudWatch monitoring on
the instance.
:type subnet_id: string
:param subnet_id: The subnet ID within which to launch the instances
for VPC.
:type private_ip_address: string
:param private_ip_address: If you\'re using VPC, you can
optionally use this parameter to assign the instance a
specific available IP address from the subnet (e.g.,
10.0.0.25).
:type block_device_map: :class:`boto.ec2.blockdevicemapping.BlockDeviceMapping`
:param block_device_map: A BlockDeviceMapping data structure
describing the EBS volumes associated with the Image.
:type disable_api_termination: bool
:param disable_api_termination: If True, the instances will be locked
and will not be able to be terminated via the API.
:type instance_initiated_shutdown_behavior: string
:param instance_initiated_shutdown_behavior: Specifies whether the
instance stops or terminates on instance-initiated shutdown.
Valid values are:
* stop
* terminate
:type placement_group: string
:param placement_group: If specified, this is the name of the placement
group in which the instance(s) will be launched.
:type client_token: string
:param client_token: Unique, case-sensitive identifier you provide
to ensure idempotency of the request. Maximum 64 ASCII characters.
:type security_group_ids: list of strings
:param security_group_ids: The ID of the VPC security groups with
which to associate instances.
:type additional_info: string
:param additional_info: Specifies additional information to make
available to the instance(s).
:type tenancy: string
:param tenancy: The tenancy of the instance you want to
launch. An instance with a tenancy of \'dedicated\' runs on
single-tenant hardware and can only be launched into a
VPC. Valid values are:"default" or "dedicated".
NOTE: To use dedicated tenancy you MUST specify a VPC
subnet-ID as well.
:type instance_profile_arn: string
:param instance_profile_arn: The Amazon resource name (ARN) of
the IAM Instance Profile (IIP) to associate with the instances.
:type instance_profile_name: string
:param instance_profile_name: The name of
the IAM Instance Profile (IIP) to associate with the instances.
:type ebs_optimized: bool
:param ebs_optimized: Whether the instance is optimized for
EBS I/O.  This optimization provides dedicated throughput
to Amazon EBS and an optimized configuration stack to
provide optimal EBS I/O performance.  This optimization
isn\'t available with all instance types.
:type network_interfaces: :class:`boto.ec2.networkinterface.NetworkInterfaceCollection`
:param network_interfaces: A NetworkInterfaceCollection data
structure containing the ENI specifications for the instance.
:type dry_run: bool
:param dry_run: Set to True if the operation should not actually run.
:rtype: Reservation
:return: The :class:`boto.ec2.instance.Reservation` associated with
the request for machines'

def run_instances(self, image_id, min_count=1, max_count=1, key_name=None, security_groups=None, user_data=None, addressing_type=None, instance_type='m1.small', placement=None, kernel_id=None, ramdisk_id=None, monitoring_enabled=False, subnet_id=None, block_device_map=None, disable_api_termination=False, instance_initiated_shutdown_behavior=None, private_ip_address=None, placement_group=None, client_token=None, security_group_ids=None, additional_info=None, instance_profile_name=None, instance_profile_arn=None, tenancy=None, ebs_optimized=False, network_interfaces=None, dry_run=False):

    params = {'ImageId': image_id, 'MinCount': min_count, 'MaxCount': max_count}
    if key_name:
        params['KeyName'] = key_name
    if security_group_ids:
        l = []
        for group in security_group_ids:
            if isinstance(group, SecurityGroup):
                l.append(group.id)
            else:
                l.append(group)
        self.build_list_params(params, l, 'SecurityGroupId')
    if security_groups:
        l = []
        for group in security_groups:
            if isinstance(group, SecurityGroup):
                l.append(group.name)
            else:
                l.append(group)
        self.build_list_params(params, l, 'SecurityGroup')
    if user_data:
        if isinstance(user_data, six.text_type):
            user_data = user_data.encode('utf-8')
        params['UserData'] = base64.b64encode(user_data).decode('utf-8')
    if addressing_type:
        params['AddressingType'] = addressing_type
    if instance_type:
        params['InstanceType'] = instance_type
    if placement:
        params['Placement.AvailabilityZone'] = placement
    if placement_group:
        params['Placement.GroupName'] = placement_group
    if tenancy:
        params['Placement.Tenancy'] = tenancy
    if kernel_id:
        params['KernelId'] = kernel_id
    if ramdisk_id:
        params['RamdiskId'] = ramdisk_id
    if monitoring_enabled:
        params['Monitoring.Enabled'] = 'true'
    if subnet_id:
        params['SubnetId'] = subnet_id
    if private_ip_address:
        params['PrivateIpAddress'] = private_ip_address
    if block_device_map:
        block_device_map.ec2_build_list_params(params)
    if disable_api_termination:
        params['DisableApiTermination'] = 'true'
    if instance_initiated_shutdown_behavior:
        val = instance_initiated_shutdown_behavior
        params['InstanceInitiatedShutdownBehavior'] = val
    if client_token:
        params['ClientToken'] = client_token
    if additional_info:
        params['AdditionalInfo'] = additional_info
    if instance_profile_name:
        params['IamInstanceProfile.Name'] = instance_profile_name
    if instance_profile_arn:
        params['IamInstanceProfile.Arn'] = instance_profile_arn
    if ebs_optimized:
        params['EbsOptimized'] = 'true'
    if network_interfaces:
        network_interfaces.build_list_params(params)
    if dry_run:
        params['DryRun'] = 'true'
    return self.get_object('RunInstances', params, Reservation, verb='POST')
