desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Removes tags from this object. Removing tags involves a round-trip to the EC2 service. :type tags: dict :param tags: A dictionary of key-value pairs for the tags being removed. For each key, the provided value must match the value currently stored in EC2. If not, that particular tag will not be removed. However, if...
def remove_tags(self, tags, dry_run=False):
status = self.connection.delete_tags([self.id], tags, dry_run=dry_run) for (key, value) in tags.items(): if (key in self.tags): if ((value is None) or (value == self.tags[key])): del self.tags[key]
'Creates a new AutoScalingGroup with the specified name. You must not have already used up your entire quota of AutoScalingGroups in order for this call to be successful. Once the creation request is completed, the AutoScalingGroup is ready to be used in other calls. :type name: str :param name: Name of autoscaling gro...
def __init__(self, connection=None, name=None, launch_config=None, availability_zones=None, load_balancers=None, default_cooldown=None, health_check_type=None, health_check_period=None, placement_group=None, vpc_zone_identifier=None, desired_capacity=None, min_size=None, max_size=None, tags=None, termination_policies=N...
self.name = (name or kwargs.get('group_name')) self.connection = connection self.min_size = (int(min_size) if (min_size is not None) else None) self.max_size = (int(max_size) if (max_size is not None) else None) self.created_time = None default_cooldown = (default_cooldown or kwargs.get('cooldow...
'Set the desired capacity for the group.'
def set_capacity(self, capacity):
params = {'AutoScalingGroupName': self.name, 'DesiredCapacity': capacity} req = self.connection.get_object('SetDesiredCapacity', params, Request) self.connection.last_request = req return req
'Sync local changes with AutoScaling group.'
def update(self):
return self.connection._update_group('UpdateAutoScalingGroup', self)
'Convenience method which shuts down all instances associated with this group.'
def shutdown_instances(self):
self.min_size = 0 self.max_size = 0 self.desired_capacity = 0 self.update()
'Delete this auto-scaling group if no instances attached or no scaling activities in progress.'
def delete(self, force_delete=False):
return self.connection.delete_auto_scaling_group(self.name, force_delete)
'Get all activies for this group.'
def get_activities(self, activity_ids=None, max_records=50):
return self.connection.get_all_activities(self, activity_ids, max_records)
'Configures an Auto Scaling group to send notifications when specified events take place. Valid notification types are: \'autoscaling:EC2_INSTANCE_LAUNCH\', \'autoscaling:EC2_INSTANCE_LAUNCH_ERROR\', \'autoscaling:EC2_INSTANCE_TERMINATE\', \'autoscaling:EC2_INSTANCE_TERMINATE_ERROR\', \'autoscaling:TEST_NOTIFICATION\''...
def put_notification_configuration(self, topic, notification_types):
return self.connection.put_notification_configuration(self, topic, notification_types)
'Deletes notifications created by put_notification_configuration.'
def delete_notification_configuration(self, topic):
return self.connection.delete_notification_configuration(self, topic)
'Suspends Auto Scaling processes for an Auto Scaling group.'
def suspend_processes(self, scaling_processes=None):
return self.connection.suspend_processes(self.name, scaling_processes)
'Resumes Auto Scaling processes for an Auto Scaling group.'
def resume_processes(self, scaling_processes=None):
return self.connection.resume_processes(self.name, scaling_processes)
'Populates a dictionary with the name/value pairs necessary to identify this Tag in a request.'
def build_params(self, params, i):
prefix = ('Tags.member.%d.' % i) params[(prefix + 'ResourceId')] = self.resource_id params[(prefix + 'ResourceType')] = self.resource_type params[(prefix + 'Key')] = self.key params[(prefix + 'Value')] = self.value if self.propagate_at_launch: params[(prefix + 'PropagateAtLaunch')] = 'tr...
'Init method to create a new connection to the AutoScaling service. B{Note:} The host argument is overridden by the host specified in the boto configuration file.'
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', security_token=None, validate_certs=True, profile_name=None, use_block_device_types=False):
if (not region): region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint, AutoScaleConnection) self.region = region self.use_block_device_types = use_block_device_types super(AutoScaleConnection, self).__init__(aws_access_key_id, aws_secret_access_key, is_secure, port, proxy...
'Items is a list of dictionaries or strings:: \'Protocol\' : \'HTTP\', \'LoadBalancerPort\' : \'80\', \'InstancePort\' : \'80\' ] etc. or:: [\'us-east-1b\',...]'
def build_list_params(self, params, items, label):
for i in range(1, (len(items) + 1)): if isinstance(items[(i - 1)], dict): for (k, v) in six.iteritems(items[(i - 1)]): if isinstance(v, dict): for (kk, vv) in six.iteritems(v): params[('%s.member.%d.%s.%s' % (label, i, k, kk))] = vv ...
'Attach instances to an autoscaling group.'
def attach_instances(self, name, instance_ids):
params = {'AutoScalingGroupName': name} self.build_list_params(params, instance_ids, 'InstanceIds') return self.get_status('AttachInstances', params)
'Detach instances from an Auto Scaling group. :type name: str :param name: The name of the Auto Scaling group from which to detach instances. :type instance_ids: list :param instance_ids: Instance ids to be detached from the Auto Scaling group. :type decrement_capacity: bool :param decrement_capacity: Whether to decrem...
def detach_instances(self, name, instance_ids, decrement_capacity=True):
params = {'AutoScalingGroupName': name} params['ShouldDecrementDesiredCapacity'] = ('true' if decrement_capacity else 'false') self.build_list_params(params, instance_ids, 'InstanceIds') return self.get_status('DetachInstances', params)
'Create auto scaling group.'
def create_auto_scaling_group(self, as_group):
return self._update_group('CreateAutoScalingGroup', as_group)
'Deletes the specified auto scaling group if the group has no instances and no scaling activities in progress.'
def delete_auto_scaling_group(self, name, force_delete=False):
if force_delete: params = {'AutoScalingGroupName': name, 'ForceDelete': 'true'} else: params = {'AutoScalingGroupName': name} return self.get_object('DeleteAutoScalingGroup', params, Request)
'Creates a new Launch Configuration. :type launch_config: :class:`boto.ec2.autoscale.launchconfig.LaunchConfiguration` :param launch_config: LaunchConfiguration object.'
def create_launch_configuration(self, launch_config):
params = {'ImageId': launch_config.image_id, 'LaunchConfigurationName': launch_config.name, 'InstanceType': launch_config.instance_type} if launch_config.key_name: params['KeyName'] = launch_config.key_name if launch_config.user_data: user_data = launch_config.user_data if isinstance...
'Returns the limits for the Auto Scaling resources currently granted for your AWS account.'
def get_account_limits(self):
params = {} return self.get_object('DescribeAccountLimits', params, AccountLimits)
'Creates a new Scaling Policy. :type scaling_policy: :class:`boto.ec2.autoscale.policy.ScalingPolicy` :param scaling_policy: ScalingPolicy object.'
def create_scaling_policy(self, scaling_policy):
params = {'AdjustmentType': scaling_policy.adjustment_type, 'AutoScalingGroupName': scaling_policy.as_name, 'PolicyName': scaling_policy.name, 'ScalingAdjustment': scaling_policy.scaling_adjustment} if ((scaling_policy.adjustment_type == 'PercentChangeInCapacity') and (scaling_policy.min_adjustment_step is not ...
'Deletes the specified LaunchConfiguration. The specified launch configuration must not be attached to an Auto Scaling group. Once this call completes, the launch configuration is no longer available for use.'
def delete_launch_configuration(self, launch_config_name):
params = {'LaunchConfigurationName': launch_config_name} return self.get_object('DeleteLaunchConfiguration', params, Request)
'Returns a full description of each Auto Scaling group in the given list. This includes all Amazon EC2 instances that are members of the group. If a list of names is not provided, the service returns the full details of all Auto Scaling groups. This action supports pagination by returning a token if there are more page...
def get_all_groups(self, names=None, max_records=None, next_token=None):
params = {} if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token if names: self.build_list_params(params, names, 'AutoScalingGroupNames') return self.get_list('DescribeAutoScalingGroups', params, [('member', AutoScalingGroup)])
'Returns a full description of the launch configurations given the specified names. If no names are specified, then the full details of all launch configurations are returned. :type names: list :param names: List of configuration names which should be searched for. :type max_records: int :param max_records: Maximum amo...
def get_all_launch_configurations(self, **kwargs):
params = {} max_records = kwargs.get('max_records', None) names = kwargs.get('names', None) if (max_records is not None): params['MaxRecords'] = max_records if names: self.build_list_params(params, names, 'LaunchConfigurationNames') next_token = kwargs.get('next_token') if ne...
'Get all activities for the given autoscaling group. This action supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again with the returned token as the NextToken parameter :type autoscale_group: str or :class:`boto.ec2.autoscale.group.AutoScalingGroup` ...
def get_all_activities(self, autoscale_group, activity_ids=None, max_records=None, next_token=None):
name = autoscale_group if isinstance(autoscale_group, AutoScalingGroup): name = autoscale_group.name params = {'AutoScalingGroupName': name} if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token if activity_ids: self.bu...
'Gets all valid termination policies. These values can then be used as the termination_policies arg when creating and updating autoscale groups.'
def get_termination_policies(self):
return self.get_object('DescribeTerminationPolicyTypes', {}, TerminationPolicies)
'Deletes a previously scheduled action. :type scheduled_action_name: str :param scheduled_action_name: The name of the action you want to delete. :type autoscale_group: str :param autoscale_group: The name of the autoscale group.'
def delete_scheduled_action(self, scheduled_action_name, autoscale_group=None):
params = {'ScheduledActionName': scheduled_action_name} if autoscale_group: params['AutoScalingGroupName'] = autoscale_group return self.get_status('DeleteScheduledAction', params)
'Terminates the specified instance. The desired group size can also be adjusted, if desired. :type instance_id: str :param instance_id: The ID of the instance to be terminated. :type decrement_capability: bool :param decrement_capacity: Whether to decrement the size of the autoscaling group or not.'
def terminate_instance(self, instance_id, decrement_capacity=True):
params = {'InstanceId': instance_id} if decrement_capacity: params['ShouldDecrementDesiredCapacity'] = 'true' else: params['ShouldDecrementDesiredCapacity'] = 'false' return self.get_object('TerminateInstanceInAutoScalingGroup', params, Activity)
'Delete a policy. :type policy_name: str :param policy_name: The name or ARN of the policy to delete. :type autoscale_group: str :param autoscale_group: The name of the autoscale group.'
def delete_policy(self, policy_name, autoscale_group=None):
params = {'PolicyName': policy_name} if autoscale_group: params['AutoScalingGroupName'] = autoscale_group return self.get_status('DeletePolicy', params)
'Returns a description of each Auto Scaling instance in the instance_ids list. If a list is not provided, the service returns the full details of all instances up to a maximum of fifty. This action supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again...
def get_all_autoscaling_instances(self, instance_ids=None, max_records=None, next_token=None):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceIds') if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token return self.get_list('DescribeAutoScalingInstances', params, [('member', Instance)])
'Returns a list of metrics and a corresponding list of granularities for each metric.'
def get_all_metric_collection_types(self):
return self.get_object('DescribeMetricCollectionTypes', {}, MetricCollectionTypes)
'Returns descriptions of what each policy does. This action supports pagination. If the response includes a token, there are more records available. To get the additional records, repeat the request with the response token as the NextToken parameter. If no group name or list of policy names are provided, all available ...
def get_all_policies(self, as_group=None, policy_names=None, max_records=None, next_token=None):
params = {} if as_group: params['AutoScalingGroupName'] = as_group if policy_names: self.build_list_params(params, policy_names, 'PolicyNames') if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token return self.get_list(...
'Returns scaling process types for use in the ResumeProcesses and SuspendProcesses actions.'
def get_all_scaling_process_types(self):
return self.get_list('DescribeScalingProcessTypes', {}, [('member', ProcessType)])
'Suspends Auto Scaling processes for an Auto Scaling group. :type as_group: string :param as_group: The auto scaling group to suspend processes on. :type scaling_processes: list :param scaling_processes: Processes you want to suspend. If omitted, all processes will be suspended.'
def suspend_processes(self, as_group, scaling_processes=None):
params = {'AutoScalingGroupName': as_group} if scaling_processes: self.build_list_params(params, scaling_processes, 'ScalingProcesses') return self.get_status('SuspendProcesses', params)
'Resumes Auto Scaling processes for an Auto Scaling group. :type as_group: string :param as_group: The auto scaling group to resume processes on. :type scaling_processes: list :param scaling_processes: Processes you want to resume. If omitted, all processes will be resumed.'
def resume_processes(self, as_group, scaling_processes=None):
params = {'AutoScalingGroupName': as_group} if scaling_processes: self.build_list_params(params, scaling_processes, 'ScalingProcesses') return self.get_status('ResumeProcesses', params)
'Creates a scheduled scaling action for a Auto Scaling group. If you leave a parameter unspecified, the corresponding value remains unchanged in the affected Auto Scaling group. :type as_group: string :param as_group: The auto scaling group to get activities on. :type name: string :param name: Scheduled action name. :t...
def create_scheduled_group_action(self, as_group, name, time=None, desired_capacity=None, min_size=None, max_size=None, start_time=None, end_time=None, recurrence=None):
params = {'AutoScalingGroupName': as_group, 'ScheduledActionName': name} if (start_time is not None): params['StartTime'] = start_time.isoformat() if (end_time is not None): params['EndTime'] = end_time.isoformat() if (recurrence is not None): params['Recurrence'] = recurrence ...
'Disables monitoring of group metrics for the Auto Scaling group specified in AutoScalingGroupName. You can specify the list of affected metrics with the Metrics parameter.'
def disable_metrics_collection(self, as_group, metrics=None):
params = {'AutoScalingGroupName': as_group} if metrics: self.build_list_params(params, metrics, 'Metrics') return self.get_status('DisableMetricsCollection', params)
'Enables monitoring of group metrics for the Auto Scaling group specified in AutoScalingGroupName. You can specify the list of enabled metrics with the Metrics parameter. Auto scaling metrics collection can be turned on only if the InstanceMonitoring.Enabled flag, in the Auto Scaling group\'s launch configuration, is s...
def enable_metrics_collection(self, as_group, granularity, metrics=None):
params = {'AutoScalingGroupName': as_group, 'Granularity': granularity} if metrics: self.build_list_params(params, metrics, 'Metrics') return self.get_status('EnableMetricsCollection', params)
'Configures an Auto Scaling group to send notifications when specified events take place. :type autoscale_group: str or :class:`boto.ec2.autoscale.group.AutoScalingGroup` object :param autoscale_group: The Auto Scaling group to put notification configuration on. :type topic: str :param topic: The Amazon Resource Name (...
def put_notification_configuration(self, autoscale_group, topic, notification_types):
name = autoscale_group if isinstance(autoscale_group, AutoScalingGroup): name = autoscale_group.name params = {'AutoScalingGroupName': name, 'TopicARN': topic} self.build_list_params(params, notification_types, 'NotificationTypes') return self.get_status('PutNotificationConfiguration', param...
'Deletes notifications created by put_notification_configuration. :type autoscale_group: str or :class:`boto.ec2.autoscale.group.AutoScalingGroup` object :param autoscale_group: The Auto Scaling group to put notification configuration on. :type topic: str :param topic: The Amazon Resource Name (ARN) of the Amazon Simpl...
def delete_notification_configuration(self, autoscale_group, topic):
name = autoscale_group if isinstance(autoscale_group, AutoScalingGroup): name = autoscale_group.name params = {'AutoScalingGroupName': name, 'TopicARN': topic} return self.get_status('DeleteNotificationConfiguration', params)
'Explicitly set the health status of an instance. :type instance_id: str :param instance_id: The identifier of the EC2 instance. :type health_status: str :param health_status: The health status of the instance. "Healthy" means that the instance is healthy and should remain in service. "Unhealthy" means that the instanc...
def set_instance_health(self, instance_id, health_status, should_respect_grace_period=True):
params = {'InstanceId': instance_id, 'HealthStatus': health_status} if should_respect_grace_period: params['ShouldRespectGracePeriod'] = 'true' else: params['ShouldRespectGracePeriod'] = 'false' return self.get_status('SetInstanceHealth', params)
'Adjusts the desired size of the AutoScalingGroup by initiating scaling activities. When reducing the size of the group, it is not possible to define which Amazon EC2 instances will be terminated. This applies to any Auto Scaling decisions that might result in terminating instances. :type group_name: string :param grou...
def set_desired_capacity(self, group_name, desired_capacity, honor_cooldown=False):
params = {'AutoScalingGroupName': group_name, 'DesiredCapacity': desired_capacity} if honor_cooldown: params['HonorCooldown'] = 'true' return self.get_status('SetDesiredCapacity', params)
'Lists the Auto Scaling group tags. This action supports pagination by returning a token if there are more pages to retrieve. To get the next page, call this action again with the returned token as the NextToken parameter. :type filters: dict :param filters: The value of the filter type used to identify the tags to be ...
def get_all_tags(self, filters=None, max_records=None, next_token=None):
params = {} if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token return self.get_list('DescribeTags', params, [('member', Tag)])
'Creates new tags or updates existing tags for an Auto Scaling group. :type tags: List of :class:`boto.ec2.autoscale.tag.Tag` :param tags: The new or updated tags.'
def create_or_update_tags(self, tags):
params = {} for (i, tag) in enumerate(tags): tag.build_params(params, (i + 1)) return self.get_status('CreateOrUpdateTags', params, verb='POST')
'Deletes existing tags for an Auto Scaling group. :type tags: List of :class:`boto.ec2.autoscale.tag.Tag` :param tags: The new or updated tags.'
def delete_tags(self, tags):
params = {} for (i, tag) in enumerate(tags): tag.build_params(params, (i + 1)) return self.get_status('DeleteTags', params, verb='POST')
'Scaling Policy :type name: str :param name: Name of scaling policy. :type adjustment_type: str :param adjustment_type: Specifies the type of adjustment. Valid values are `ChangeInCapacity`, `ExactCapacity` and `PercentChangeInCapacity`. :type as_name: str or int :param as_name: Name or ARN of the Auto Scaling Group. :...
def __init__(self, connection=None, **kwargs):
self.name = kwargs.get('name', None) self.adjustment_type = kwargs.get('adjustment_type', None) self.as_name = kwargs.get('as_name', None) self.scaling_adjustment = kwargs.get('scaling_adjustment', None) self.cooldown = kwargs.get('cooldown', None) self.connection = connection self.min_adjus...
'A launch configuration. :type name: str :param name: Name of the launch configuration to create. :type image_id: str :param image_id: Unique ID of the Amazon Machine Image (AMI) which was assigned during registration. :type key_name: str :param key_name: The name of the EC2 key pair. :type security_groups: list :param...
def __init__(self, connection=None, name=None, image_id=None, key_name=None, security_groups=None, user_data=None, instance_type='m1.small', kernel_id=None, ramdisk_id=None, block_device_mappings=None, instance_monitoring=False, spot_price=None, instance_profile_name=None, ebs_optimized=False, associate_public_ip_addre...
self.connection = connection self.name = name self.instance_type = instance_type self.block_device_mappings = block_device_mappings self.key_name = key_name sec_groups = (security_groups or []) self.security_groups = ListElement(sec_groups) self.image_id = image_id self.ramdisk_id = ...
'Delete this launch configuration.'
def delete(self):
return self.connection.delete_launch_configuration(self.name)
'Init method to create a new connection to EC2.'
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, host=None, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', api_version=None, security_token=None, validate_certs=True, profile_name=None):
if (not region): region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint) self.region = region super(EC2Connection, self).__init__(aws_access_key_id, aws_secret_access_key, is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, self.region.endpoint, debug, https_connection_...
'Returns a dictionary containing the value of all of the keyword arguments passed when constructing this connection.'
def get_params(self):
param_names = ['aws_access_key_id', 'aws_secret_access_key', 'is_secure', 'port', 'proxy', 'proxy_port', 'proxy_user', 'proxy_pass', 'debug', 'https_connection_factory'] params = {} for name in param_names: params[name] = getattr(self, name) return params
'Retrieve all the EC2 images available on your account. :type image_ids: list :param image_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs, the special strings \'self\', \'amazon\', and \'aws-marketplace\', may be used to describe images owned by you, Amazon or AWS...
def get_all_images(self, image_ids=None, owners=None, executable_by=None, filters=None, dry_run=False):
params = {} if image_ids: self.build_list_params(params, image_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') if executable_by: self.build_list_params(params, executable_by, 'ExecutableBy') if filters: self.build_filter_params(params, filte...
'Retrieve all the EC2 kernels available on your account. Constructs a filter to allow the processing to happen server side. :type kernel_ids: list :param kernel_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs :type dry_run: bool :param dry_run: Set to True if the o...
def get_all_kernels(self, kernel_ids=None, owners=None, dry_run=False):
params = {} if kernel_ids: self.build_list_params(params, kernel_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') filter = {'image-type': 'kernel'} self.build_filter_params(params, filter) if dry_run: params['DryRun'] = 'true' return self.get...
'Retrieve all the EC2 ramdisks available on your account. Constructs a filter to allow the processing to happen server side. :type ramdisk_ids: list :param ramdisk_ids: A list of strings with the image IDs wanted :type owners: list :param owners: A list of owner IDs :type dry_run: bool :param dry_run: Set to True if th...
def get_all_ramdisks(self, ramdisk_ids=None, owners=None, dry_run=False):
params = {} if ramdisk_ids: self.build_list_params(params, ramdisk_ids, 'ImageId') if owners: self.build_list_params(params, owners, 'Owner') filter = {'image-type': 'ramdisk'} self.build_filter_params(params, filter) if dry_run: params['DryRun'] = 'true' return self....
'Shortcut method to retrieve a specific image (AMI). :type image_id: string :param image_id: the ID of the Image to retrieve :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: :class:`boto.ec2.image.Image` :return: The EC2 Image specified or None if the image is not found'...
def get_image(self, image_id, dry_run=False):
try: return self.get_all_images(image_ids=[image_id], dry_run=dry_run)[0] except IndexError: return None
'Register an image. :type name: string :param name: The name of the AMI. Valid only for EBS-based images. :type description: string :param description: The description of the AMI. :type image_location: string :param image_location: Full path to your AMI manifest in Amazon S3 storage. Only used for S3-based AMI\'s. :t...
def register_image(self, name=None, description=None, image_location=None, architecture=None, kernel_id=None, ramdisk_id=None, root_device_name=None, block_device_map=None, dry_run=False, virtualization_type=None, sriov_net_support=None, snapshot_id=None, delete_root_volume_on_termination=False):
params = {} if name: params['Name'] = name if description: params['Description'] = description if architecture: params['Architecture'] = architecture if kernel_id: params['KernelId'] = kernel_id if ramdisk_id: params['RamdiskId'] = ramdisk_id if image_...
'Unregister an AMI. :type image_id: string :param image_id: the ID of the Image to unregister :type delete_snapshot: bool :param delete_snapshot: Set to True if we should delete the snapshot associated with an EBS volume mounted at /dev/sda1 :type dry_run: bool :param dry_run: Set to True if the operation should not ac...
def deregister_image(self, image_id, delete_snapshot=False, dry_run=False):
snapshot_id = None if delete_snapshot: image = self.get_image(image_id) for key in image.block_device_mapping: if (key == '/dev/sda1'): snapshot_id = image.block_device_mapping[key].snapshot_id break params = {'ImageId': image_id} if dry_run: ...
'Will create an AMI from the instance in the running or stopped state. :type instance_id: string :param instance_id: the ID of the instance to image. :type name: string :param name: The name of the new image :type description: string :param description: An optional human-readable string describing the contents and purp...
def create_image(self, instance_id, name, description=None, no_reboot=False, block_device_mapping=None, dry_run=False):
params = {'InstanceId': instance_id, 'Name': name} if description: params['Description'] = description if no_reboot: params['NoReboot'] = 'true' if block_device_mapping: block_device_mapping.ec2_build_list_params(params) if dry_run: params['DryRun'] = 'true' img =...
'Gets an attribute from an image. :type image_id: string :param image_id: The Amazon image id for which you want info about :type attribute: string :param attribute: The attribute you need information about. Valid choices are: * launchPermission * productCodes * blockDeviceMapping :type dry_run: bool :param dry_run: Se...
def get_image_attribute(self, image_id, attribute='launchPermission', dry_run=False):
params = {'ImageId': image_id, 'Attribute': attribute} if dry_run: params['DryRun'] = 'true' return self.get_object('DescribeImageAttribute', params, ImageAttribute, verb='POST')
'Changes an attribute of an image. :type image_id: string :param image_id: The image id you wish to change :type attribute: string :param attribute: The attribute you wish to change :type operation: string :param operation: Either add or remove (this is required for changing launchPermissions) :type user_ids: list :par...
def modify_image_attribute(self, image_id, attribute='launchPermission', operation='add', user_ids=None, groups=None, product_codes=None, dry_run=False):
params = {'ImageId': image_id, 'Attribute': attribute, 'OperationType': operation} if user_ids: self.build_list_params(params, user_ids, 'UserId') if groups: self.build_list_params(params, groups, 'UserGroup') if product_codes: self.build_list_params(params, product_codes, 'Produ...
'Resets an attribute of an AMI to its default value. :type image_id: string :param image_id: ID of the AMI for which an attribute will be described :type attribute: string :param attribute: The attribute to reset :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: bool :ret...
def reset_image_attribute(self, image_id, attribute='launchPermission', dry_run=False):
params = {'ImageId': image_id, 'Attribute': attribute} if dry_run: params['DryRun'] = 'true' return self.get_status('ResetImageAttribute', params, verb='POST')
'Retrieve all the instance reservations associated with your account. .. note:: This method\'s current behavior is deprecated in favor of :meth:`get_all_reservations`. A future major release will change :meth:`get_all_instances` to return a list of :class:`boto.ec2.instance.Instance` objects as its name suggests. To o...
def get_all_instances(self, instance_ids=None, filters=None, dry_run=False, max_results=None):
warnings.warn('The current get_all_instances implementation will be replaced with get_all_reservations.', PendingDeprecationWarning) return self.get_all_reservations(instance_ids=instance_ids, filters=filters, dry_run=dry_run, max_results=max_results)
'Retrieve all the instances associated with your account. :type instance_ids: list :param instance_ids: A list of strings of instance IDs :type filters: dict :param filters: Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary consisting of filter names as t...
def get_only_instances(self, instance_ids=None, filters=None, dry_run=False, max_results=None):
next_token = None retval = [] while True: reservations = self.get_all_reservations(instance_ids=instance_ids, filters=filters, dry_run=dry_run, max_results=max_results, next_token=next_token) retval.extend([instance for reservation in reservations for instance in reservation.instances]) ...
'Retrieve all the instance reservations associated with your account. :type instance_ids: list :param instance_ids: A list of strings of instance IDs :type filters: dict :param filters: Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary consisting of filte...
def get_all_reservations(self, instance_ids=None, filters=None, dry_run=False, max_results=None, next_token=None):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if filters: if ('group-id' in filters): gid = filters.get('group-id') if ((not gid.startswith('sg-')) or (len(gid) != 11)): warnings.warn("The group-id filter...
'Retrieve all the instances in your account scheduled for maintenance. :type instance_ids: list :param instance_ids: A list of strings of instance IDs :type max_results: int :param max_results: The maximum number of paginated instance items per response. :type next_token: str :param next_token: A string specifying the ...
def get_all_instance_status(self, instance_ids=None, max_results=None, next_token=None, filters=None, dry_run=False, include_all_instances=False):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if max_results: params['MaxResults'] = max_results if next_token: params['NextToken'] = next_token if filters: self.build_filter_params(params, filters) if dry_run: par...
'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 ...
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_initi...
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: ...
'Terminate the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to terminate :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: list :return: A list of the instances terminated'
def terminate_instances(self, instance_ids=None, dry_run=False):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if dry_run: params['DryRun'] = 'true' return self.get_list('TerminateInstances', params, [('item', Instance)], verb='POST')
'Stop the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to stop :type force: bool :param force: Forces the instance to stop :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: list :return: A list of the instances st...
def stop_instances(self, instance_ids=None, force=False, dry_run=False):
params = {} if force: params['Force'] = 'true' if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if dry_run: params['DryRun'] = 'true' return self.get_list('StopInstances', params, [('item', Instance)], verb='POST')
'Start the instances specified :type instance_ids: list :param instance_ids: A list of strings of the Instance IDs to start :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: list :return: A list of the instances started'
def start_instances(self, instance_ids=None, dry_run=False):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if dry_run: params['DryRun'] = 'true' return self.get_list('StartInstances', params, [('item', Instance)], verb='POST')
'Retrieves the console output for the specified instance. :type instance_id: string :param instance_id: The instance ID of a running instance on the cloud. :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: :class:`boto.ec2.instance.ConsoleOutput` :return: The console outp...
def get_console_output(self, instance_id, dry_run=False):
params = {} self.build_list_params(params, [instance_id], 'InstanceId') if dry_run: params['DryRun'] = 'true' return self.get_object('GetConsoleOutput', params, ConsoleOutput, verb='POST')
'Reboot the specified instances. :type instance_ids: list :param instance_ids: The instances to terminate and reboot :type dry_run: bool :param dry_run: Set to True if the operation should not actually run.'
def reboot_instances(self, instance_ids=None, dry_run=False):
params = {} if instance_ids: self.build_list_params(params, instance_ids, 'InstanceId') if dry_run: params['DryRun'] = 'true' return self.get_status('RebootInstances', params)
':type dry_run: bool :param dry_run: Set to True if the operation should not actually run.'
def confirm_product_instance(self, product_code, instance_id, dry_run=False):
params = {'ProductCode': product_code, 'InstanceId': instance_id} if dry_run: params['DryRun'] = 'true' rs = self.get_object('ConfirmProductInstance', params, ResultSet, verb='POST') return (rs.status, rs.ownerId)
'Gets an attribute from an instance. :type instance_id: string :param instance_id: The Amazon id of the instance :type attribute: string :param attribute: The attribute you need information about Valid choices are: * instanceType * kernel * ramdisk * userData * disableApiTermination * instanceInitiatedShutdownBehavior ...
def get_instance_attribute(self, instance_id, attribute, dry_run=False):
params = {'InstanceId': instance_id} if attribute: params['Attribute'] = attribute if dry_run: params['DryRun'] = 'true' return self.get_object('DescribeInstanceAttribute', params, InstanceAttribute, verb='POST')
'Changes an attribute of a network interface. :type interface_id: string :param interface_id: The interface id. Looks like \'eni-xxxxxxxx\' :type attr: string :param attr: The attribute you wish to change. Learn more at http://docs.aws.amazon.com/AWSEC2/latest/API Reference/ApiReference-query-ModifyNetworkIn...
def modify_network_interface_attribute(self, interface_id, attr, value, attachment_id=None, dry_run=False):
bool_reqs = ('deleteontermination', 'sourcedestcheck') if (attr.lower() in bool_reqs): if isinstance(value, bool): if value: value = 'true' else: value = 'false' elif (value not in ['true', 'false']): raise ValueError(('%s mu...
'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 - Base6...
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.lowe...
'Resets an attribute of an instance to its default value. :type instance_id: string :param instance_id: ID of the instance :type attribute: string :param attribute: The attribute to reset. Valid values are: kernel|ramdisk :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: ...
def reset_instance_attribute(self, instance_id, attribute, dry_run=False):
params = {'InstanceId': instance_id, 'Attribute': attribute} if dry_run: params['DryRun'] = 'true' return self.get_status('ResetInstanceAttribute', params, verb='POST')
'Retrieve all the spot instances requests associated with your account. :type request_ids: list :param request_ids: A list of strings of spot instance request IDs :type filters: dict :param filters: Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary consis...
def get_all_spot_instance_requests(self, request_ids=None, filters=None, dry_run=False):
params = {} if request_ids: self.build_list_params(params, request_ids, 'SpotInstanceRequestId') if filters: if ('launch.group-id' in filters): lgid = filters.get('launch.group-id') if ((not lgid.startswith('sg-')) or (len(lgid) != 11)): warnings.warn(...
'Retrieve the recent history of spot instances pricing. :type start_time: str :param start_time: An indication of how far back to provide price changes for. An ISO8601 DateTime string. :type end_time: str :param end_time: An indication of how far forward to provide price changes for. An ISO8601 DateTime string. :type ...
def get_spot_price_history(self, start_time=None, end_time=None, instance_type=None, product_description=None, availability_zone=None, dry_run=False, max_results=None, next_token=None, filters=None):
params = {} if start_time: params['StartTime'] = start_time if end_time: params['EndTime'] = end_time if instance_type: params['InstanceType'] = instance_type if product_description: params['ProductDescription'] = product_description if availability_zone: ...
'Request instances on the spot market at a particular price. :type price: str :param price: The maximum price of your bid :type image_id: string :param image_id: The ID of the image to run :type count: int :param count: The of instances to requested :type type: str :param type: Type of request. Can be \'one-time\' or \...
def request_spot_instances(self, price, image_id, count=1, type='one-time', valid_from=None, valid_until=None, launch_group=None, availability_zone_group=None, 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...
ls = 'LaunchSpecification' params = {('%s.ImageId' % ls): image_id, 'Type': type, 'SpotPrice': price} if count: params['InstanceCount'] = count if valid_from: params['ValidFrom'] = valid_from if valid_until: params['ValidUntil'] = valid_until if launch_group: para...
'Cancel the specified Spot Instance Requests. :type request_ids: list :param request_ids: A list of strings of the Request IDs to terminate :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: list :return: A list of the instances terminated'
def cancel_spot_instance_requests(self, request_ids, dry_run=False):
params = {} if request_ids: self.build_list_params(params, request_ids, 'SpotInstanceRequestId') if dry_run: params['DryRun'] = 'true' return self.get_list('CancelSpotInstanceRequests', params, [('item', SpotInstanceRequest)], verb='POST')
'Return the current spot instance data feed subscription associated with this account, if any. :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: :class:`boto.ec2.spotdatafeedsubscription.SpotDatafeedSubscription` :return: The datafeed subscription object or None'
def get_spot_datafeed_subscription(self, dry_run=False):
params = {} if dry_run: params['DryRun'] = 'true' return self.get_object('DescribeSpotDatafeedSubscription', params, SpotDatafeedSubscription, verb='POST')
'Create a spot instance datafeed subscription for this account. :type bucket: str or unicode :param bucket: The name of the bucket where spot instance data will be written. The account issuing this request must have FULL_CONTROL access to the bucket specified in the request. :type prefix: str or unicode :param prefix:...
def create_spot_datafeed_subscription(self, bucket, prefix, dry_run=False):
params = {'Bucket': bucket} if prefix: params['Prefix'] = prefix if dry_run: params['DryRun'] = 'true' return self.get_object('CreateSpotDatafeedSubscription', params, SpotDatafeedSubscription, verb='POST')
'Delete the current spot instance data feed subscription associated with this account :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: bool :return: True if successful'
def delete_spot_datafeed_subscription(self, dry_run=False):
params = {} if dry_run: params['DryRun'] = 'true' return self.get_status('DeleteSpotDatafeedSubscription', params, verb='POST')
'Get all Availability Zones associated with the current region. :type zones: list :param zones: Optional list of zones. If this list is present, only the Zones associated with these zone names will be returned. :type filters: dict :param filters: Optional filters that can be used to limit the results returned. Filter...
def get_all_zones(self, zones=None, filters=None, dry_run=False):
params = {} if zones: self.build_list_params(params, zones, 'ZoneName') if filters: self.build_filter_params(params, filters) if dry_run: params['DryRun'] = 'true' return self.get_list('DescribeAvailabilityZones', params, [('item', Zone)], verb='POST')
'Get all EIP\'s associated with the current credentials. :type addresses: list :param addresses: Optional list of addresses. If this list is present, only the Addresses associated with these addresses will be returned. :type filters: dict :param filters: Optional filters that can be used to limit the results returned....
def get_all_addresses(self, addresses=None, filters=None, allocation_ids=None, dry_run=False):
params = {} if addresses: self.build_list_params(params, addresses, 'PublicIp') if allocation_ids: self.build_list_params(params, allocation_ids, 'AllocationId') if filters: self.build_filter_params(params, filters) if dry_run: params['DryRun'] = 'true' return sel...
'Allocate a new Elastic IP address and associate it with your account. :type domain: string :param domain: Optional string. If domain is set to "vpc" the address will be allocated to VPC . Will return address object with allocation_id. :type dry_run: bool :param dry_run: Set to True if the operation should not actually...
def allocate_address(self, domain=None, dry_run=False):
params = {} if (domain is not None): params['Domain'] = domain if dry_run: params['DryRun'] = 'true' return self.get_object('AllocateAddress', params, Address, verb='POST')
'Assigns one or more secondary private IP addresses to a network interface in Amazon VPC. :type network_interface_id: string :param network_interface_id: The network interface to which the IP address will be assigned. :type private_ip_addresses: list :param private_ip_addresses: Assigns the specified IP addresses as se...
def assign_private_ip_addresses(self, network_interface_id=None, private_ip_addresses=None, secondary_private_ip_address_count=None, allow_reassignment=False, dry_run=False):
params = {} if (network_interface_id is not None): params['NetworkInterfaceId'] = network_interface_id if (private_ip_addresses is not None): self.build_list_params(params, private_ip_addresses, 'PrivateIpAddress') elif (secondary_private_ip_address_count is not None): params['Se...
'Associate an Elastic IP address with a currently running instance. This requires one of ``public_ip`` or ``allocation_id`` depending on if you\'re associating a VPC address or a plain EC2 address. When using an Allocation ID, make sure to pass ``None`` for ``public_ip`` as EC2 expects a single parameter and if ``publi...
def associate_address(self, instance_id=None, public_ip=None, allocation_id=None, network_interface_id=None, private_ip_address=None, allow_reassociation=False, dry_run=False):
return self._associate_address(True, instance_id=instance_id, public_ip=public_ip, allocation_id=allocation_id, network_interface_id=network_interface_id, private_ip_address=private_ip_address, allow_reassociation=allow_reassociation, dry_run=dry_run)
'Associate an Elastic IP address with a currently running instance. This requires one of ``public_ip`` or ``allocation_id`` depending on if you\'re associating a VPC address or a plain EC2 address. When using an Allocation ID, make sure to pass ``None`` for ``public_ip`` as EC2 expects a single parameter and if ``publi...
def associate_address_object(self, instance_id=None, public_ip=None, allocation_id=None, network_interface_id=None, private_ip_address=None, allow_reassociation=False, dry_run=False):
return self._associate_address(False, instance_id=instance_id, public_ip=public_ip, allocation_id=allocation_id, network_interface_id=network_interface_id, private_ip_address=private_ip_address, allow_reassociation=allow_reassociation, dry_run=dry_run)
'Disassociate an Elastic IP address from a currently running instance. :type public_ip: string :param public_ip: The public IP address for EC2 elastic IPs. :type association_id: string :param association_id: The association ID for a VPC based elastic ip. :type dry_run: bool :param dry_run: Set to True if the operation ...
def disassociate_address(self, public_ip=None, association_id=None, dry_run=False):
params = {} if (association_id is not None): params['AssociationId'] = association_id elif (public_ip is not None): params['PublicIp'] = public_ip if dry_run: params['DryRun'] = 'true' return self.get_status('DisassociateAddress', params, verb='POST')
'Free up an Elastic IP address. Pass a public IP address to release an EC2 Elastic IP address and an AllocationId to release a VPC Elastic IP address. You should only pass one value. This requires one of ``public_ip`` or ``allocation_id`` depending on if you\'re associating a VPC address or a plain EC2 address. When ...
def release_address(self, public_ip=None, allocation_id=None, dry_run=False):
params = {} if (public_ip is not None): params['PublicIp'] = public_ip elif (allocation_id is not None): params['AllocationId'] = allocation_id if dry_run: params['DryRun'] = 'true' return self.get_status('ReleaseAddress', params, verb='POST')
'Unassigns one or more secondary private IP addresses from a network interface in Amazon VPC. :type network_interface_id: string :param network_interface_id: The network interface from which the secondary private IP address will be unassigned. :type private_ip_addresses: list :param private_ip_addresses: Specifies the ...
def unassign_private_ip_addresses(self, network_interface_id=None, private_ip_addresses=None, dry_run=False):
params = {} if (network_interface_id is not None): params['NetworkInterfaceId'] = network_interface_id if (private_ip_addresses is not None): self.build_list_params(params, private_ip_addresses, 'PrivateIpAddress') if dry_run: params['DryRun'] = 'true' return self.get_status(...
'Get all Volumes associated with the current credentials. :type volume_ids: list :param volume_ids: Optional list of volume ids. If this list is present, only the volumes associated with these volume ids will be returned. :type filters: dict :param filters: Optional filters that can be used to limit the results return...
def get_all_volumes(self, volume_ids=None, filters=None, dry_run=False):
params = {} if volume_ids: self.build_list_params(params, volume_ids, 'VolumeId') if filters: self.build_filter_params(params, filters) if dry_run: params['DryRun'] = 'true' return self.get_list('DescribeVolumes', params, [('item', Volume)], verb='POST')
'Retrieve the status of one or more volumes. :type volume_ids: list :param volume_ids: A list of strings of volume IDs :type max_results: int :param max_results: The maximum number of paginated instance items per response. :type next_token: str :param next_token: A string specifying the next paginated set of results to...
def get_all_volume_status(self, volume_ids=None, max_results=None, next_token=None, filters=None, dry_run=False):
params = {} if volume_ids: self.build_list_params(params, volume_ids, 'VolumeId') if max_results: params['MaxResults'] = max_results if next_token: params['NextToken'] = next_token if filters: self.build_filter_params(params, filters) if dry_run: params['D...
'Enables I/O operations for a volume that had I/O operations disabled because the data on the volume was potentially inconsistent. :type volume_id: str :param volume_id: The ID of the volume. :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: bool :return: True if successf...
def enable_volume_io(self, volume_id, dry_run=False):
params = {'VolumeId': volume_id} if dry_run: params['DryRun'] = 'true' return self.get_status('EnableVolumeIO', params, verb='POST')
'Describes attribute of the volume. :type volume_id: str :param volume_id: The ID of the volume. :type attribute: str :param attribute: The requested attribute. Valid values are: * autoEnableIO :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: list of :class:`boto.ec2.vo...
def get_volume_attribute(self, volume_id, attribute='autoEnableIO', dry_run=False):
params = {'VolumeId': volume_id, 'Attribute': attribute} if dry_run: params['DryRun'] = 'true' return self.get_object('DescribeVolumeAttribute', params, VolumeAttribute, verb='POST')
'Changes an attribute of an Volume. :type volume_id: string :param volume_id: The volume id you wish to change :type attribute: string :param attribute: The attribute you wish to change. Valid values are: AutoEnableIO. :type new_value: string :param new_value: The new value of the attribute. :type dry_run: bool :param...
def modify_volume_attribute(self, volume_id, attribute, new_value, dry_run=False):
params = {'VolumeId': volume_id} if (attribute == 'AutoEnableIO'): params['AutoEnableIO.Value'] = new_value if dry_run: params['DryRun'] = 'true' return self.get_status('ModifyVolumeAttribute', params, verb='POST')
'Create a new EBS Volume. :type size: int :param size: The size of the new volume, in GiB :type zone: string or :class:`boto.ec2.zone.Zone` :param zone: The availability zone in which the Volume will be created. :type snapshot: string or :class:`boto.ec2.snapshot.Snapshot` :param snapshot: The snapshot from which the n...
def create_volume(self, size, zone, snapshot=None, volume_type=None, iops=None, encrypted=False, kms_key_id=None, dry_run=False):
if isinstance(zone, Zone): zone = zone.name params = {'AvailabilityZone': zone} if size: params['Size'] = size if snapshot: if isinstance(snapshot, Snapshot): snapshot = snapshot.id params['SnapshotId'] = snapshot if volume_type: params['VolumeType...
'Delete an EBS volume. :type volume_id: str :param volume_id: The ID of the volume to be delete. :type dry_run: bool :param dry_run: Set to True if the operation should not actually run. :rtype: bool :return: True if successful'
def delete_volume(self, volume_id, dry_run=False):
params = {'VolumeId': volume_id} if dry_run: params['DryRun'] = 'true' return self.get_status('DeleteVolume', params, verb='POST')
'Attach an EBS volume to an EC2 instance. :type volume_id: str :param volume_id: The ID of the EBS volume to be attached. :type instance_id: str :param instance_id: The ID of the EC2 instance to which it will be attached. :type device: str :param device: The device on the instance through which the volume will be expos...
def attach_volume(self, volume_id, instance_id, device, dry_run=False):
params = {'InstanceId': instance_id, 'VolumeId': volume_id, 'Device': device} if dry_run: params['DryRun'] = 'true' return self.get_status('AttachVolume', params, verb='POST')
'Detach an EBS volume from an EC2 instance. :type volume_id: str :param volume_id: The ID of the EBS volume to be attached. :type instance_id: str :param instance_id: The ID of the EC2 instance from which it will be detached. :type device: str :param device: The device on the instance through which the volume is expost...
def detach_volume(self, volume_id, instance_id=None, device=None, force=False, dry_run=False):
params = {'VolumeId': volume_id} if instance_id: params['InstanceId'] = instance_id if device: params['Device'] = device if force: params['Force'] = 'true' if dry_run: params['DryRun'] = 'true' return self.get_status('DetachVolume', params, verb='POST')