'Changes an attribute of an instance
:type instance_id: string
:param instance_id: The instance id you wish to change
:type attribute: string
:param attribute: The attribute you wish to change.
* instanceType - A valid instance type (m1.small)
* kernel - Kernel ID (None)
* ramdisk - Ramdisk ID (None)
* userData - Base64 encoded String (None)
* disableApiTermination - Boolean (true)
* instanceInitiatedShutdownBehavior - stop|terminate
* blockDeviceMapping - List of strings - ie: [\'/dev/sda=false\']
* sourceDestCheck - Boolean (true)
* groupSet - Set of Security Groups or IDs
* ebsOptimized - Boolean (false)
* sriovNetSupport - String - ie: \'simple\'
:type value: string
:param value: The new value for the attribute
:type dry_run: bool
:param dry_run: Set to True if the operation should not actually run.
:rtype: bool
:return: Whether the operation succeeded or not'

def modify_instance_attribute(self, instance_id, attribute, value, dry_run=False):

    bool_reqs = ('disableapitermination', 'sourcedestcheck', 'ebsoptimized')
    if (attribute.lower() in bool_reqs):
        if isinstance(value, bool):
            if value:
                value = 'true'
            else:
                value = 'false'
    params = {'InstanceId': instance_id}
    if (attribute.lower() == 'groupset'):
        for (idx, sg) in enumerate(value):
            if isinstance(sg, SecurityGroup):
                sg = sg.id
            params[('GroupId.%s' % (idx + 1))] = sg
    elif (attribute.lower() == 'blockdevicemapping'):
        for (idx, kv) in enumerate(value):
            (dev_name, _, flag) = kv.partition('=')
            pre = ('BlockDeviceMapping.%d' % (idx + 1))
            params[('%s.DeviceName' % pre)] = dev_name
            params[('%s.Ebs.DeleteOnTermination' % pre)] = (flag or 'true')
    else:
        attribute = (attribute[0].upper() + attribute[1:])
        params[('%s.Value' % attribute)] = value
    if dry_run:
        params['DryRun'] = 'true'
    return self.get_status('ModifyInstanceAttribute', params, verb='POST')
