EC2¶
boto.ec2¶
This module provides an interface to the Elastic Compute Cloud (EC2) service from AWS.
-
boto.ec2.
connect_to_region
(region_name, **kw_params)¶ Given a valid region name, return a
boto.ec2.connection.EC2Connection
.Type: str Parameters: region_name – The name of the region to connect to. Return type: boto.ec2.connection.EC2Connection
orNone
Returns: A connection to the given region, or None if an invalid region name is given
-
boto.ec2.
get_region
(region_name, **kw_params)¶ Find and return a
boto.ec2.regioninfo.RegionInfo
object given a region name.Type: str Param: The name of the region. Return type: boto.ec2.regioninfo.RegionInfo
Returns: The RegionInfo object for the given region or None if an invalid region name is provided.
-
boto.ec2.
regions
(**kw_params)¶ Get all available regions for the EC2 service. You may pass any of the arguments accepted by the EC2Connection object’s constructor as keyword arguments and they will be passed along to the EC2Connection object.
Return type: list Returns: A list of boto.ec2.regioninfo.RegionInfo
boto.ec2.address¶
Represents an EC2 Elastic IP Address
boto.ec2.autoscale¶
This module provides an interface to the Elastic Compute Cloud (EC2) Auto Scaling service.
-
class
boto.ec2.autoscale.
AutoScaleConnection
(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=1, https_connection_factory=None, region=None, path='/')¶ 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.
-
APIVersion
= '2010-08-01'¶
-
DefaultRegionEndpoint
= 'autoscaling.amazonaws.com'¶
-
DefaultRegionName
= 'us-east-1'¶
-
build_list_params
(params, items, label)¶ - items is a list of dictionaries or strings:
- [{‘Protocol’ : ‘HTTP’,
- ‘LoadBalancerPort’ : ‘80’, ‘InstancePort’ : ‘80’},..] etc.
- or
- [‘us-east-1b’,...]
-
create_auto_scaling_group
(as_group)¶ Create auto scaling group.
-
create_launch_configuration
(launch_config)¶ Creates a new Launch Configuration.
Parameters: launch_config ( boto.ec2.autoscale.launchconfig.LaunchConfiguration
) – LaunchConfiguration object.
-
create_scaling_policy
(scaling_policy)¶ Creates a new Scaling Policy.
Parameters: scaling_policy ( boto.ec2.autoscale.policy.ScalingPolicy
) – ScalingPolicy object.
-
create_scheduled_group_action
(as_group, name, time, desired_capacity=None, min_size=None, max_size=None)¶ 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.
Parameters: - as_group (string) – The auto scaling group to get activities on.
- name (string) – Scheduled action name.
- time (datetime.datetime) – The time for this action to start.
- desired_capacity (int) – The number of EC2 instances that should be running in this group.
- min_size (int) – The minimum size for the new auto scaling group.
- max_size (int) – The minimum size for the new auto scaling group.
-
delete_auto_scaling_group
(name)¶ Deletes the specified auto scaling group if the group has no instances and no scaling activities in progress.
-
delete_launch_configuration
(launch_config_name)¶ 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.
-
delete_policy
(policy_name, autoscale_group=None)¶
-
delete_scheduled_action
(scheduled_action_name, autoscale_group=None)¶
-
disable_metrics_collection
(as_group, metrics=None)¶ 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.
-
enable_metrics_collection
(as_group, granularity, metrics=None)¶ 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 set to true.
Parameters: - autoscale_group (string) – The auto scaling group to get activities on.
- granularity (string) – The granularity to associate with the metrics to collect. Currently, the only legal granularity is “1Minute”.
- metrics (string list) – The list of metrics to collect. If no metrics are specified, all metrics are enabled.
-
execute_policy
(policy_name, as_group=None, honor_cooldown=None)¶
-
get_all_activities
(autoscale_group, activity_ids=None, max_records=None, next_token=None)¶ 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
Parameters: - autoscale_group (str or
boto.ec2.autoscale.group.AutoScalingGroup
object) – The auto scaling group to get activities on. - max_records (int) – Maximum amount of activities to return.
Return type: Returns: List of
boto.ec2.autoscale.activity.Activity
instances.- autoscale_group (str or
-
get_all_adjustment_types
()¶
-
get_all_autoscaling_instances
(instance_ids=None, max_records=None, next_token=None)¶ 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 with the returned token as the NextToken parameter.
Parameters: Return type: Returns: List of
boto.ec2.autoscale.activity.Activity
instances.
-
get_all_groups
(names=None, max_records=None, next_token=None)¶ 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 pages to retrieve. To get the next page, call this action again with the returned token as the NextToken parameter.
Parameters: Return type: Returns: List of
boto.ec2.autoscale.group.AutoScalingGroup
instances.
-
get_all_launch_configurations
(**kwargs)¶ 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.
Parameters: Return type: Returns: List of
boto.ec2.autoscale.launchconfig.LaunchConfiguration
instances.
-
get_all_metric_collection_types
()¶ Returns a list of metrics and a corresponding list of granularities for each metric.
-
get_all_policies
(as_group=None, policy_names=None, max_records=None, next_token=None)¶ 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 policies are returned.
Parameters: - as_name (str) – the name of the
boto.ec2.autoscale.group.AutoScalingGroup
to filter for. - names (list) – List of policy names which should be searched for.
- max_records (int) – Maximum amount of groups to return.
- as_name (str) – the name of the
-
get_all_scaling_process_types
()¶ Returns scaling process types for use in the ResumeProcesses and SuspendProcesses actions.
-
get_all_scheduled_actions
(as_group=None, start_time=None, end_time=None, scheduled_actions=None, max_records=None, next_token=None)¶
-
resume_processes
(as_group, scaling_processes=None)¶ Resumes Auto Scaling processes for an Auto Scaling group.
Parameters:
-
set_instance_health
(instance_id, health_status, should_respect_grace_period=True)¶ Explicitly set the health status of an instance.
Parameters: - instance_id (str) – The identifier of the EC2 instance.
- health_status (str) – The health status of the instance. “Healthy” means that the instance is healthy and should remain in service. “Unhealthy” means that the instance is unhealthy. Auto Scaling should terminate and replace it.
- should_respect_grace_period (bool) – If True, this call should respect the grace period associated with the group.
-
suspend_processes
(as_group, scaling_processes=None)¶ Suspends Auto Scaling processes for an Auto Scaling group.
Parameters:
-
terminate_instance
(instance_id, decrement_capacity=True)¶
-
boto.ec2.autoscale.
connect_to_region
(region_name, **kw_params)¶ Given a valid region name, return a
boto.ec2.autoscale.AutoScaleConnection
.Parameters: region_name (str) – The name of the region to connect to. Return type: boto.ec2.AutoScaleConnection
orNone
Returns: A connection to the given region, or None if an invalid region name is given
boto.ec2.autoscale.activity¶
boto.ec2.autoscale.group¶
-
class
boto.ec2.autoscale.group.
AutoScalingGroup
(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, **kwargs)¶ 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.
Parameters: - name (str) – Name of autoscaling group (required).
- availability_zones (list) – List of availability zones (required).
- default_cooldown (int) – Number of seconds after a Scaling Activity completes before any further scaling activities can start.
- desired_capacity (int) – The desired capacity for the group.
- health_check_period (str) – Length of time in seconds after a new EC2 instance comes into service that Auto Scaling starts checking its health.
- health_check_type (str) – The service you want the health status from, Amazon EC2 or Elastic Load Balancer.
- launch_config (str or LaunchConfiguration) – Name of launch configuration (required).
- load_balancers (list) – List of load balancers.
- maxsize – Maximum size of group (required).
- minsize – Minimum size of group (required).
- placement_group (str) – Physical location of your cluster placement group created in Amazon EC2.
- vpc_zone_identifier (str) – The subnet identifier of the Virtual Private Cloud.
Return type: Returns: An autoscale group.
-
cooldown
¶
-
delete
()¶ Delete this auto-scaling group if no instances attached or no scaling activities in progress.
-
endElement
(name, value, connection)¶
-
get_activities
(activity_ids=None, max_records=50)¶ Get all activies for this group.
-
resume_processes
(scaling_processes=None)¶ Resumes Auto Scaling processes for an Auto Scaling group.
-
set_capacity
(capacity)¶ Set the desired capacity for the group.
-
shutdown_instances
()¶ Convenience method which shuts down all instances associated with this group.
-
startElement
(name, attrs, connection)¶
-
suspend_processes
(scaling_processes=None)¶ Suspends Auto Scaling processes for an Auto Scaling group.
-
update
()¶ Sync local changes with AutoScaling group.
-
class
boto.ec2.autoscale.group.
AutoScalingGroupMetric
(connection=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.group.
EnabledMetric
(connection=None, metric=None, granularity=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.autoscale.instance¶
boto.ec2.autoscale.launchconfig¶
-
class
boto.ec2.autoscale.launchconfig.
BlockDeviceMapping
(connection=None, device_name=None, virtual_name=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.launchconfig.
Ebs
(connection=None, snapshot_id=None, volume_size=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.launchconfig.
InstanceMonitoring
(connection=None, enabled='false')¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.launchconfig.
LaunchConfiguration
(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)¶ A launch configuration.
Parameters: - name (str) – Name of the launch configuration to create.
- image_id (str) – Unique ID of the Amazon Machine Image (AMI) which was assigned during registration.
- key_name (str) – The name of the EC2 key pair.
- security_groups (list) – Names of the security groups with which to associate the EC2 instances.
- user_data (str) – The user data available to launched EC2 instances.
- instance_type (str) – The instance type
- kern_id (str) – Kernel id for instance
- ramdisk_id (str) – RAM disk id for instance
- block_device_mappings (list) – Specifies how block devices are exposed for instances
- instance_monitoring (bool) – Whether instances in group are launched with detailed monitoring.
-
delete
()¶ Delete this launch configuration.
-
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
boto.ec2.autoscale.policy¶
-
class
boto.ec2.autoscale.policy.
AdjustmentType
(connection=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.policy.
Alarm
(connection=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.autoscale.policy.
MetricCollectionTypes
(connection=None)¶ -
class
BaseType
(connection)¶ -
arg
= ''¶
-
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
MetricCollectionTypes.
endElement
(name, value, connection)¶
-
MetricCollectionTypes.
startElement
(name, attrs, connection)¶
-
class
-
class
boto.ec2.autoscale.policy.
ScalingPolicy
(connection=None, **kwargs)¶ Scaling Policy
Parameters: - name (str) – Name of scaling policy.
- adjustment_type (str) – Specifies the type of adjustment. Valid values are ChangeInCapacity, ExactCapacity and PercentChangeInCapacity.
- as_name (str or int) – Name or ARN of the Auto Scaling Group.
- scaling_adjustment (int) – Value of adjustment (type specified in adjustment_type).
- cooldown (int) – Time (in seconds) before Alarm related Scaling Activities can start after the previous Scaling Activity ends.
-
delete
()¶
-
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
boto.ec2.autoscale.request¶
boto.ec2.autoscale.scheduled¶
boto.ec2.buyreservation¶
boto.ec2.cloudwatch¶
This module provides an interface to the Elastic Compute Cloud (EC2) CloudWatch service from AWS.
The 5 Minute How-To Guide¶
First, make sure you have something to monitor. You can either create a LoadBalancer or enable monitoring on an existing EC2 instance. To enable monitoring, you can either call the monitor_instance method on the EC2Connection object or call the monitor method on the Instance object.
It takes a while for the monitoring data to start accumulating but once it does, you can do this:
>>> import boto
>>> c = boto.connect_cloudwatch()
>>> metrics = c.list_metrics()
>>> metrics
[Metric:NetworkIn,
Metric:NetworkOut,
Metric:NetworkOut(InstanceType,m1.small),
Metric:NetworkIn(InstanceId,i-e573e68c),
Metric:CPUUtilization(InstanceId,i-e573e68c),
Metric:DiskWriteBytes(InstanceType,m1.small),
Metric:DiskWriteBytes(ImageId,ami-a1ffb63),
Metric:NetworkOut(ImageId,ami-a1ffb63),
Metric:DiskWriteOps(InstanceType,m1.small),
Metric:DiskReadBytes(InstanceType,m1.small),
Metric:DiskReadOps(ImageId,ami-a1ffb63),
Metric:CPUUtilization(InstanceType,m1.small),
Metric:NetworkIn(ImageId,ami-a1ffb63),
Metric:DiskReadOps(InstanceType,m1.small),
Metric:DiskReadBytes,
Metric:CPUUtilization,
Metric:DiskWriteBytes(InstanceId,i-e573e68c),
Metric:DiskWriteOps(InstanceId,i-e573e68c),
Metric:DiskWriteOps,
Metric:DiskReadOps,
Metric:CPUUtilization(ImageId,ami-a1ffb63),
Metric:DiskReadOps(InstanceId,i-e573e68c),
Metric:NetworkOut(InstanceId,i-e573e68c),
Metric:DiskReadBytes(ImageId,ami-a1ffb63),
Metric:DiskReadBytes(InstanceId,i-e573e68c),
Metric:DiskWriteBytes,
Metric:NetworkIn(InstanceType,m1.small),
Metric:DiskWriteOps(ImageId,ami-a1ffb63)]
The list_metrics call will return a list of all of the available metrics that you can query against. Each entry in the list is a Metric object. As you can see from the list above, some of the metrics are generic metrics and some have Dimensions associated with them (e.g. InstanceType=m1.small). The Dimension can be used to refine your query. So, for example, I could query the metric Metric:CPUUtilization which would create the desired statistic by aggregating cpu utilization data across all sources of information available or I could refine that by querying the metric Metric:CPUUtilization(InstanceId,i-e573e68c) which would use only the data associated with the instance identified by the instance ID i-e573e68c.
Because for this example, I’m only monitoring a single instance, the set of metrics available to me are fairly limited. If I was monitoring many instances, using many different instance types and AMI’s and also several load balancers, the list of available metrics would grow considerably.
Once you have the list of available metrics, you can actually query the CloudWatch system for that metric. Let’s choose the CPU utilization metric for our instance.
>>> m = metrics[5]
>>> m
Metric:CPUUtilization(InstanceId,i-e573e68c)
The Metric object has a query method that lets us actually perform the query against the collected data in CloudWatch. To call that, we need a start time and end time to control the time span of data that we are interested in. For this example, let’s say we want the data for the previous hour:
>>> import datetime
>>> end = datetime.datetime.now()
>>> start = end - datetime.timedelta(hours=1)
We also need to supply the Statistic that we want reported and the Units to use for the results. The Statistic can be one of these values:
[‘Minimum’, ‘Maximum’, ‘Sum’, ‘Average’, ‘SampleCount’]
And Units must be one of the following:
[‘Seconds’, ‘Percent’, ‘Bytes’, ‘Bits’, ‘Count’, ‘Bytes/Second’, ‘Bits/Second’, ‘Count/Second’]
The query method also takes an optional parameter, period. This parameter controls the granularity (in seconds) of the data returned. The smallest period is 60 seconds and the value must be a multiple of 60 seconds. So, let’s ask for the average as a percent:
>>> datapoints = m.query(start, end, 'Average', 'Percent')
>>> len(datapoints)
60
Our period was 60 seconds and our duration was one hour so we should get 60 data points back and we can see that we did. Each element in the datapoints list is a DataPoint object which is a simple subclass of a Python dict object. Each Datapoint object contains all of the information available about that particular data point.
>>> d = datapoints[0]
>>> d
{u'Average': 0.0,
u'SampleCount': 1.0,
u'Timestamp': u'2009-05-21T19:55:00Z',
u'Unit': u'Percent'}
My server obviously isn’t very busy right now!
-
class
boto.ec2.cloudwatch.
CloudWatchConnection
(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='/')¶ Init method to create a new connection to EC2 Monitoring Service.
B{Note:} The host argument is overridden by the host specified in the boto configuration file.
-
APIVersion
= '2010-08-01'¶
-
DefaultRegionEndpoint
= 'monitoring.amazonaws.com'¶
-
DefaultRegionName
= 'us-east-1'¶
-
build_list_params
(params, items, label)¶
-
create_alarm
(alarm)¶ Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.
When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.
When updating an existing alarm, its StateValue is left unchanged.
Parameters: alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
-
delete_alarms
(alarms)¶ Deletes all specified alarms. In the event of an error, no alarms are deleted.
Parameters: alarms (list) – List of alarm names.
-
describe_alarm_history
(alarm_name=None, start_date=None, end_date=None, max_records=None, history_item_type=None, next_token=None)¶ Retrieves history for the specified alarm. Filter alarms by date range or item type. If an alarm name is not specified, Amazon CloudWatch returns histories for all of the owner’s alarms.
Amazon CloudWatch retains the history of deleted alarms for a period of six weeks. If an alarm has been deleted, its history can still be queried.
Parameters: - alarm_name (string) – The name of the alarm.
- start_date (datetime) – The starting date to retrieve alarm history.
- end_date (datetime) – The starting date to retrieve alarm history.
- history_item_type (string) – The type of alarm histories to retreive (ConfigurationUpdate | StateUpdate | Action)
- max_records (int) – The maximum number of alarm descriptions to retrieve.
- next_token (string) – The token returned by a previous call to indicate that there is more data.
:rtype list
-
describe_alarms
(action_prefix=None, alarm_name_prefix=None, alarm_names=None, max_records=None, state_value=None, next_token=None)¶ Retrieves alarms with the specified names. If no name is specified, all alarms for the user are returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.
Parameters: - action_name – The action name prefix.
- alarm_name_prefix (string) – The alarm name prefix. AlarmNames cannot be specified if this parameter is specified.
- alarm_names (list) – A list of alarm names to retrieve information for.
- max_records (int) – The maximum number of alarm descriptions to retrieve.
- state_value (string) – The state value to be used in matching alarms.
- next_token (string) – The token returned by a previous call to indicate that there is more data.
:rtype list
-
describe_alarms_for_metric
(metric_name, namespace, period=None, statistic=None, dimensions=None, unit=None)¶ Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the set of alarms further.
Parameters: :rtype list
-
disable_alarm_actions
(alarm_names)¶ Disables actions for the specified alarms.
Parameters: alarms (list) – List of alarm names.
-
enable_alarm_actions
(alarm_names)¶ Enables actions for the specified alarms.
Parameters: alarms (list) – List of alarm names.
-
get_metric_statistics
(period, start_time, end_time, metric_name, namespace, statistics, dimensions=None, unit=None)¶ Get time-series data for one or more statistics of a given metric.
Parameters: - period (integer) – The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
- start_time (datetime) – The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified.
- end_time (datetime) – The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
- metric_name (string) – The metric name.
Return type:
-
list_metrics
(next_token=None)¶ Returns a list of the valid metrics for which there is recorded data available.
Parameters: next_token (string) – A maximum of 500 metrics will be returned at one time. If more results are available, the ResultSet returned will contain a non-Null next_token attribute. Passing that token as a parameter to list_metrics will retrieve the next page of metrics.
-
put_metric_alarm
(alarm)¶ Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.
When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.
When updating an existing alarm, its StateValue is left unchanged.
Parameters: alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
-
put_metric_data
(namespace, name, value=None, timestamp=None, unit=None, dimensions=None, statistics=None)¶ Publishes metric data points to Amazon CloudWatch. Amazon Cloudwatch associates the data points with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates the metric.
Parameters: - namespace (string) – The namespace of the metric.
- name (string) – The name of the metric.
- value (int) – The value for the metric.
- timestamp (datetime) – The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
- unit (string) – The unit of the metric. Valid Values: Seconds | Microseconds | Milliseconds | Bytes | Kilobytes | Megabytes | Gigabytes | Terabytes | Bits | Kilobits | Megabits | Gigabits | Terabits | Percent | Count | Bytes/Second | Kilobytes/Second | Megabytes/Second | Gigabytes/Second | Terabytes/Second | Bits/Second | Kilobits/Second | Megabits/Second | Gigabits/Second | Terabits/Second | Count/Second | None
- dimensions (dict) – Add extra name value pairs to associate with the metric, i.e.: {‘name1’: value1, ‘name2’: value2}
- statistics (dict) –
Use a statistic set instead of a value, for example {‘maximum’: 30, ‘minimum’: 1,
‘samplecount’: 100, ‘sum’: 10000}
-
set_alarm_state
(alarm_name, state_reason, state_value, state_reason_data=None)¶ Temporarily sets the state of an alarm. When the updated StateValue differs from the previous value, the action configured for the appropriate state is invoked. This is not a permanent change. The next periodic alarm check (in about a minute) will set the alarm to its actual state.
Parameters:
-
update_alarm
(alarm)¶ Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.
When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.
When updating an existing alarm, its StateValue is left unchanged.
Parameters: alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
-
-
boto.ec2.cloudwatch.
connect_to_region
(region_name, **kw_params)¶ Given a valid region name, return a
boto.ec2.cloudwatch.CloudWatchConnection
.Parameters: region_name (str) – The name of the region to connect to. Return type: boto.ec2.CloudWatchConnection
orNone
Returns: A connection to the given region, or None if an invalid region name is given
boto.ec2.cloudwatch.datapoint¶
boto.ec2.cloudwatch.metric¶
-
class
boto.ec2.cloudwatch.metric.
Dimensions
¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.cloudwatch.metric.
Metric
(connection=None)¶ -
Statistics
= ['Minimum', 'Maximum', 'Sum', 'Average', 'SampleCount']¶
-
Units
= ['Seconds', 'Percent', 'Bytes', 'Bits', 'Count', 'Bytes/Second', 'Bits/Second', 'Count/Second']¶
-
describe_alarms
(period=None, statistic=None, dimensions=None, unit=None)¶
-
endElement
(name, value, connection)¶
-
query
(start_time, end_time, statistic, unit=None, period=60)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.connection¶
Represents a connection to the EC2 service.
-
class
boto.ec2.connection.
EC2Connection
(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)¶ Init method to create a new connection to EC2.
- B{Note:} The host argument is overridden by the host specified in the
- boto configuration file.
-
APIVersion
= '2011-01-01'¶
-
DefaultRegionEndpoint
= 'ec2.amazonaws.com'¶
-
DefaultRegionName
= 'us-east-1'¶
-
ResponseError
¶ alias of
EC2ResponseError
-
allocate_address
()¶ Allocate a new Elastic IP address and associate it with your account.
Return type: boto.ec2.address.Address
Returns: The newly allocated Address
-
associate_address
(instance_id, public_ip)¶ Associate an Elastic IP address with a currently running instance.
Parameters: Return type: Returns: True if successful
-
attach_volume
(volume_id, instance_id, device)¶ Attach an EBS volume to an EC2 instance.
Parameters: Return type: Returns: True if successful
Add a new rule to an existing security group. You need to pass in either src_security_group_name and src_security_group_owner_id OR ip_protocol, from_port, to_port, and cidr_ip. In other words, either you are authorizing another group or you are authorizing some ip-based rule.
Parameters: - group_name (string) – The name of the security group you are adding the rule to.
- src_security_group_name (string) – The name of the security group you are granting access to.
- src_security_group_owner_id (string) – The ID of the owner of the security group you are granting access to.
- ip_protocol (string) – Either tcp | udp | icmp
- from_port (int) – The beginning port number you are enabling
- to_port (int) – The ending port number you are enabling
- cidr_ip (string) – The CIDR block you are providing access to. See http://goo.gl/Yj5QC
Return type: Returns: True if successful.
- NOTE: This method uses the old-style request parameters
- that did not allow a port to be specified when authorizing a group.
Parameters: - group_name (string) – The name of the security group you are adding the rule to.
- src_security_group_name (string) – The name of the security group you are granting access to.
- src_security_group_owner_id (string) – The ID of the owner of the security group you are granting access to.
- ip_protocol (string) – Either tcp | udp | icmp
- from_port (int) – The beginning port number you are enabling
- to_port (string) – The ending port number you are enabling
- to_port – The CIDR block you are providing access to. See http://goo.gl/Yj5QC
Return type: Returns: True if successful.
-
build_filter_params
(params, filters)¶
-
build_tag_param_list
(params, tags)¶
-
bundle_instance
(instance_id, s3_bucket, s3_prefix, s3_upload_policy)¶ Bundle Windows instance.
Parameters: - instance_id (string) – The instance id
- s3_bucket (string) – The bucket in which the AMI should be stored.
- s3_prefix (string) – The beginning of the file name for the AMI.
- s3_upload_policy (string) – Base64 encoded policy that specifies condition and permissions for Amazon EC2 to upload the user’s image into Amazon S3.
-
cancel_bundle_task
(bundle_id)¶ Cancel a previously submitted bundle task
Parameters: bundle_id (string) – The identifier of the bundle task to cancel.
-
cancel_spot_instance_requests
(request_ids)¶ Cancel the specified Spot Instance Requests.
Parameters: request_ids (list) – A list of strings of the Request IDs to terminate Return type: list Returns: A list of the instances terminated
-
confirm_product_instance
(product_code, instance_id)¶
-
create_image
(instance_id, name, description=None, no_reboot=False)¶ Will create an AMI from the instance in the running or stopped state.
Parameters: - instance_id (string) – the ID of the instance to image.
- name (string) – The name of the new image
- description (string) – An optional human-readable string describing the contents and purpose of the AMI.
- no_reboot (bool) – An optional flag indicating that the bundling process should not attempt to shutdown the instance before bundling. If this flag is True, the responsibility of maintaining file system integrity is left to the owner of the instance.
Return type: Returns: The new image id
-
create_key_pair
(key_name)¶ Create a new key pair for your account. This will create the key pair within the region you are currently connected to.
Parameters: key_name (string) – The name of the new keypair Return type: boto.ec2.keypair.KeyPair
Returns: The newly created boto.ec2.keypair.KeyPair
. The material attribute of the new KeyPair object will contain the the unencrypted PEM encoded RSA private key.
-
create_placement_group
(name, strategy='cluster')¶ Create a new placement group for your account. This will create the placement group within the region you are currently connected to.
Parameters: Return type: boto.ec2.placementgroup.PlacementGroup
Returns: The newly created
boto.ec2.keypair.KeyPair
.
-
create_security_group
(name, description)¶ Create a new security group for your account. This will create the security group within the region you are currently connected to.
Parameters: Return type: Returns: The newly created
boto.ec2.keypair.KeyPair
.
-
create_snapshot
(volume_id, description=None)¶ Create a snapshot of an existing EBS Volume.
Parameters: Return type: Returns: True if successful
-
create_spot_datafeed_subscription
(bucket, prefix)¶ Create a spot instance datafeed subscription for this account.
Parameters: - bucket (str or unicode) – 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.
- prefix (str or unicode) – An optional prefix that will be pre-pended to all data files written to the bucket.
Return type: boto.ec2.spotdatafeedsubscription.SpotDatafeedSubscription
Returns: The datafeed subscription object or None
Create new metadata tags for the specified resource ids.
Parameters:
-
create_volume
(size, zone, snapshot=None)¶ Create a new EBS Volume.
Parameters: - size (int) – The size of the new volume, in GiB
- zone (string or
boto.ec2.zone.Zone
) – The availability zone in which the Volume will be created. - snapshot (string or
boto.ec2.snapshot.Snapshot
) – The snapshot from which the new Volume will be created.
-
delete_key_pair
(key_name)¶ Delete a key pair from your account.
Parameters: key_name (string) – The name of the keypair to delete
-
delete_placement_group
(name)¶ Delete a placement group from your account.
Parameters: key_name (string) – The name of the keypair to delete
-
delete_security_group
(name)¶ Delete a security group from your account.
Parameters: key_name (string) – The name of the keypair to delete
-
delete_snapshot
(snapshot_id)¶
-
delete_spot_datafeed_subscription
()¶ Delete the current spot instance data feed subscription associated with this account
Return type: bool Returns: True if successful
Delete metadata tags for the specified resource ids.
Parameters: - resource_ids (list) – List of strings
- tags (dict or list) – Either a dictionary containing name/value pairs or a list containing just tag names. If you pass in a dictionary, the values must match the actual tag values or the tag will not be deleted.
-
delete_volume
(volume_id)¶ Delete an EBS volume.
Parameters: volume_id (str) – The ID of the volume to be delete. Return type: bool Returns: True if successful
-
deregister_image
(image_id, delete_snapshot=False)¶ Unregister an AMI.
Parameters: Return type: Returns: True if successful
-
detach_volume
(volume_id, instance_id=None, device=None, force=False)¶ Detach an EBS volume from an EC2 instance.
Parameters: - volume_id (str) – The ID of the EBS volume to be attached.
- instance_id (str) – The ID of the EC2 instance from which it will be detached.
- device (str) – The device on the instance through which the volume is exposted (e.g. /dev/sdh)
- force (bool) – Forces detachment if the previous detachment attempt did not occur cleanly. This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures.
Return type: Returns: True if successful
-
disassociate_address
(public_ip)¶ Disassociate an Elastic IP address from a currently running instance.
Parameters: public_ip (string) – The public IP address Return type: bool Returns: True if successful
-
get_all_addresses
(addresses=None, filters=None)¶ Get all EIP’s associated with the current credentials.
Parameters: - addresses (list) – Optional list of addresses. If this list is present, only the Addresses associated with these addresses will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: list of
boto.ec2.address.Address
Returns: The requested Address objects
-
get_all_bundle_tasks
(bundle_ids=None, filters=None)¶ Retrieve current bundling tasks. If no bundle id is specified, all tasks are retrieved.
Parameters: - bundle_ids (list) – A list of strings containing identifiers for previously created bundling tasks.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
-
get_all_images
(image_ids=None, owners=None, executable_by=None, filters=None)¶ Retrieve all the EC2 images available on your account.
Parameters: - image_ids (list) – A list of strings with the image IDs wanted
- owners (list) – A list of owner IDs
- executable_by (list) – Returns AMIs for which the specified user ID has explicit launch permissions
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.image.Image
-
get_all_instances
(instance_ids=None, filters=None)¶ Retrieve all the instances associated with your account.
Parameters: - instance_ids (list) – A list of strings of instance IDs
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.instance.Reservation
-
get_all_kernels
(kernel_ids=None, owners=None)¶ Retrieve all the EC2 kernels available on your account. Constructs a filter to allow the processing to happen server side.
Parameters: Return type: Returns: A list of
boto.ec2.image.Image
-
get_all_key_pairs
(keynames=None, filters=None)¶ Get all key pairs associated with your account.
Parameters: - keynames (list) – A list of the names of keypairs to retrieve. If not provided, all key pairs will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.keypair.KeyPair
-
get_all_placement_groups
(groupnames=None, filters=None)¶ Get all placement groups associated with your account in a region.
Parameters: - groupnames (list) – A list of the names of placement groups to retrieve. If not provided, all placement groups will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.placementgroup.PlacementGroup
-
get_all_ramdisks
(ramdisk_ids=None, owners=None)¶ Retrieve all the EC2 ramdisks available on your account. Constructs a filter to allow the processing to happen server side.
Parameters: Return type: Returns: A list of
boto.ec2.image.Image
-
get_all_regions
(region_names=None, filters=None)¶ Get all available regions for the EC2 service.
Parameters: - region_names (list of str) – Names of regions to limit output
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.regioninfo.RegionInfo
-
get_all_reserved_instances
(reserved_instances_id=None, filters=None)¶ Describes Reserved Instance offerings that are available for purchase.
Parameters: - reserved_instance_ids (list) – A list of the reserved instance ids that will be returned. If not provided, all reserved instances will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns:
-
get_all_reserved_instances_offerings
(reserved_instances_id=None, instance_type=None, availability_zone=None, product_description=None, filters=None)¶ Describes Reserved Instance offerings that are available for purchase.
Parameters: - reserved_instances_id (str) – Displays Reserved Instances with the specified offering IDs.
- instance_type (str) – Displays Reserved Instances of the specified instance type.
- availability_zone (str) – Displays Reserved Instances within the specified Availability Zone.
- product_description (str) – Displays Reserved Instances with the specified product description.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.reservedinstance.ReservedInstancesOffering
-
get_all_security_groups
(groupnames=None, filters=None)¶ Get all security groups associated with your account in a region.
Parameters: - groupnames (list) – A list of the names of security groups to retrieve. If not provided, all security groups will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.securitygroup.SecurityGroup
-
get_all_snapshots
(snapshot_ids=None, owner=None, restorable_by=None, filters=None)¶ Get all EBS Snapshots associated with the current credentials.
Parameters: - snapshot_ids (list) – Optional list of snapshot ids. If this list is present, only the Snapshots associated with these snapshot ids will be returned.
- owner (str) –
If present, only the snapshots owned by the specified user will be returned. Valid values are:
- self
- amazon
- AWS Account ID
- restorable_by (str) – If present, only the snapshots that are restorable by the specified account id will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: list of
boto.ec2.snapshot.Snapshot
Returns: The requested Snapshot objects
-
get_all_spot_instance_requests
(request_ids=None, filters=None)¶ Retrieve all the spot instances requests associated with your account.
Parameters: - request_ids (list) – A list of strings of spot instance request IDs
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: Returns: A list of
boto.ec2.spotinstancerequest.SpotInstanceRequest
Retrieve all the metadata tags associated with your account.
Parameters: filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details. Return type: dict Returns: A dictionary containing metadata tags
-
get_all_volumes
(volume_ids=None, filters=None)¶ Get all Volumes associated with the current credentials.
Parameters: - volume_ids (list) – Optional list of volume ids. If this list is present, only the volumes associated with these volume ids will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: list of
boto.ec2.volume.Volume
Returns: The requested Volume objects
-
get_all_zones
(zones=None, filters=None)¶ Get all Availability Zones associated with the current region.
Parameters: - zones (list) – Optional list of zones. If this list is present, only the Zones associated with these zone names will be returned.
- filters (dict) – 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 the key and filter values as the value. The set of allowable filter names/values is dependent on the request being performed. Check the EC2 API guide for details.
Return type: list of
boto.ec2.zone.Zone
Returns: The requested Zone objects
-
get_console_output
(instance_id)¶ Retrieves the console output for the specified instance.
Parameters: instance_id (string) – The instance ID of a running instance on the cloud. Return type: boto.ec2.instance.ConsoleOutput
Returns: The console output as a ConsoleOutput object
-
get_image
(image_id)¶ Shortcut method to retrieve a specific image (AMI).
Parameters: image_id (string) – the ID of the Image to retrieve Return type: boto.ec2.image.Image
Returns: The EC2 Image specified or None if the image is not found
-
get_image_attribute
(image_id, attribute='launchPermission')¶ Gets an attribute from an image.
Parameters: Return type: Returns: An ImageAttribute object representing the value of the attribute requested
-
get_instance_attribute
(instance_id, attribute)¶ Gets an attribute from an instance.
Parameters: Return type: boto.ec2.image.InstanceAttribute
Returns: An InstanceAttribute object representing the value of the attribute requested
-
get_key_pair
(keyname)¶ Convenience method to retrieve a specific keypair (KeyPair).
Parameters: image_id (string) – the ID of the Image to retrieve Return type: boto.ec2.keypair.KeyPair
Returns: The KeyPair specified or None if it is not found
-
get_params
()¶ Returns a dictionary containing the value of of all of the keyword arguments passed when constructing this connection.
-
get_password_data
(instance_id)¶ Get encrypted administrator password for a Windows instance.
Parameters: instance_id (string) – The identifier of the instance to retrieve the password for.
-
get_snapshot_attribute
(snapshot_id, attribute='createVolumePermission')¶ Get information about an attribute of a snapshot. Only one attribute can be specified per call.
Parameters: Return type: list of
boto.ec2.snapshotattribute.SnapshotAttribute
Returns: The requested Snapshot attribute
-
get_spot_datafeed_subscription
()¶ Return the current spot instance data feed subscription associated with this account, if any.
Return type: boto.ec2.spotdatafeedsubscription.SpotDatafeedSubscription
Returns: The datafeed subscription object or None
-
get_spot_price_history
(start_time=None, end_time=None, instance_type=None, product_description=None)¶ Retrieve the recent history of spot instances pricing.
Parameters: - start_time (str) – An indication of how far back to provide price changes for. An ISO8601 DateTime string.
- end_time (str) – An indication of how far forward to provide price changes for. An ISO8601 DateTime string.
- instance_type (str) – Filter responses to a particular instance type.
- product_descripton – Filter responses to a particular platform. Valid values are currently: Linux
Return type: Returns: A list tuples containing price and timestamp.
-
import_key_pair
(key_name, public_key_material)¶ mports the public key from an RSA key pair that you created with a third-party tool.
Supported formats:
- OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys)
- Base64 encoded DER format
- SSH public key file format as specified in RFC4716
DSA keys are not supported. Make sure your key generator is set up to create RSA keys.
Supported lengths: 1024, 2048, and 4096.
Parameters: Return type: Returns: The newly created
boto.ec2.keypair.KeyPair
. The material attribute of the new KeyPair object will contain the the unencrypted PEM encoded RSA private key.
-
modify_image_attribute
(image_id, attribute='launchPermission', operation='add', user_ids=None, groups=None, product_codes=None)¶ Changes an attribute of an image.
Parameters: - image_id (string) – The image id you wish to change
- attribute (string) – The attribute you wish to change
- operation (string) – Either add or remove (this is required for changing launchPermissions)
- user_ids (list) – The Amazon IDs of users to add/remove attributes
- groups (list) – The groups to add/remove attributes
- product_codes (list) – Amazon DevPay product code. Currently only one product code can be associated with an AMI. Once set, the product code cannot be changed or reset.
-
modify_instance_attribute
(instance_id, attribute, value)¶ Changes an attribute of an instance
Parameters: - instance_id (string) – The instance id you wish to change
- attribute (string) –
The attribute you wish to change.
- AttributeName - Expected value (default)
- 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
- rootDeviceName - device name (None)
- value (string) – The new value for the attribute
Return type: Returns: Whether the operation succeeded or not
-
modify_snapshot_attribute
(snapshot_id, attribute='createVolumePermission', operation='add', user_ids=None, groups=None)¶ Changes an attribute of an image.
Parameters: - snapshot_id (string) – The snapshot id you wish to change
- attribute (string) – The attribute you wish to change. Valid values are: createVolumePermission
- operation (string) – Either add or remove (this is required for changing snapshot ermissions)
- user_ids (list) – The Amazon IDs of users to add/remove attributes
- groups (list) – The groups to add/remove attributes. The only valid value at this time is ‘all’.
-
monitor_instance
(instance_id)¶ Deprecated Version, maintained for backward compatibility. Enable CloudWatch monitoring for the supplied instance.
Parameters: instance_id (string) – The instance id Return type: list Returns: A list of boto.ec2.instanceinfo.InstanceInfo
-
monitor_instances
(instance_ids)¶ Enable CloudWatch monitoring for the supplied instances.
Parameters: instance_id (list of strings) – The instance ids Return type: list Returns: A list of boto.ec2.instanceinfo.InstanceInfo
-
purchase_reserved_instance_offering
(reserved_instances_offering_id, instance_count=1)¶ Purchase a Reserved Instance for use with your account. ** CAUTION ** This request can result in large amounts of money being charged to your AWS account. Use with caution!
Parameters: Return type: Returns: The newly created Reserved Instance
-
reboot_instances
(instance_ids=None)¶ Reboot the specified instances.
Parameters: instance_ids (list) – The instances to terminate and reboot
-
register_image
(name=None, description=None, image_location=None, architecture=None, kernel_id=None, ramdisk_id=None, root_device_name=None, block_device_map=None)¶ Register an image.
Parameters: - name (string) – The name of the AMI. Valid only for EBS-based images.
- description (string) – The description of the AMI.
- image_location (string) – Full path to your AMI manifest in Amazon S3 storage. Only used for S3-based AMI’s.
- architecture (string) – The architecture of the AMI. Valid choices are: i386 | x86_64
- kernel_id (string) – The ID of the kernel with which to launch the instances
- root_device_name (string) – The root device name (e.g. /dev/sdh)
- block_device_map (
boto.ec2.blockdevicemapping.BlockDeviceMapping
) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image.
Return type: Returns: The new image id
-
release_address
(public_ip)¶ Free up an Elastic IP address
Parameters: public_ip (string) – The public IP address Return type: bool Returns: True if successful
-
request_spot_instances
(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_enabled=False, subnet_id=None, block_device_map=None)¶ Request instances on the spot market at a particular price.
Parameters: - price (str) – The maximum price of your bid
- image_id (string) – The ID of the image to run
- count (int) – The of instances to requested
- type (str) – Type of request. Can be ‘one-time’ or ‘persistent’. Default is one-time.
- valid_from (str) – Start date of the request. An ISO8601 time string.
- valid_until (str) – End date of the request. An ISO8601 time string.
- launch_group (str) – If supplied, all requests will be fulfilled as a group.
- availability_zone_group (str) – If supplied, all requests will be fulfilled within a single availability zone.
- key_name (string) – The name of the key pair with which to launch instances
- security_groups (list of strings) – The names of the security groups with which to associate instances
- user_data (string) – The user data passed to the launched instances
- instance_type (string) –
The type of instance to run:
- m1.small
- m1.large
- m1.xlarge
- c1.medium
- c1.xlarge
- m2.xlarge
- m2.2xlarge
- m2.4xlarge
- cc1.4xlarge
- t1.micro
- placement (string) – The availability zone in which to launch the instances
- kernel_id (string) – The ID of the kernel with which to launch the instances
- ramdisk_id (string) – The ID of the RAM disk with which to launch the instances
- monitoring_enabled (bool) – Enable CloudWatch monitoring on the instance.
- subnet_id (string) – The subnet ID within which to launch the instances for VPC.
- block_device_map (
boto.ec2.blockdevicemapping.BlockDeviceMapping
) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image.
Return type: Returns: The
boto.ec2.spotinstancerequest.SpotInstanceRequest
associated with the request for machines
-
reset_image_attribute
(image_id, attribute='launchPermission')¶ Resets an attribute of an AMI to its default value.
Parameters: Return type: Returns: Whether the operation succeeded or not
-
reset_instance_attribute
(instance_id, attribute)¶ Resets an attribute of an instance to its default value.
Parameters: Return type: Returns: Whether the operation succeeded or not
-
reset_snapshot_attribute
(snapshot_id, attribute='createVolumePermission')¶ Resets an attribute of a snapshot to its default value.
Parameters: Return type: Returns: Whether the operation succeeded or not
-
revoke_security_group
(group_name, src_security_group_name=None, src_security_group_owner_id=None, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None)¶ Remove an existing rule from an existing security group. You need to pass in either src_security_group_name and src_security_group_owner_id OR ip_protocol, from_port, to_port, and cidr_ip. In other words, either you are revoking another group or you are revoking some ip-based rule.
Parameters: - group_name (string) – The name of the security group you are removing the rule from.
- src_security_group_name (string) – The name of the security group you are revoking access to.
- src_security_group_owner_id (string) – The ID of the owner of the security group you are revoking access to.
- ip_protocol (string) – Either tcp | udp | icmp
- from_port (int) – The beginning port number you are disabling
- to_port (int) – The ending port number you are disabling
- cidr_ip (string) – The CIDR block you are revoking access to. See http://goo.gl/Yj5QC
Return type: Returns: True if successful.
-
revoke_security_group_deprecated
(group_name, src_security_group_name=None, src_security_group_owner_id=None, ip_protocol=None, from_port=None, to_port=None, cidr_ip=None)¶ - NOTE: This method uses the old-style request parameters
- that did not allow a port to be specified when authorizing a group.
Remove an existing rule from an existing security group. You need to pass in either src_security_group_name and src_security_group_owner_id OR ip_protocol, from_port, to_port, and cidr_ip. In other words, either you are revoking another group or you are revoking some ip-based rule.
Parameters: - group_name (string) – The name of the security group you are removing the rule from.
- src_security_group_name (string) – The name of the security group you are revoking access to.
- src_security_group_owner_id (string) – The ID of the owner of the security group you are revoking access to.
- ip_protocol (string) – Either tcp | udp | icmp
- from_port (int) – The beginning port number you are disabling
- to_port (string) – The ending port number you are disabling
- to_port – The CIDR block you are revoking access to. http://goo.gl/Yj5QC
Return type: Returns: True if successful.
-
run_instances
(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)¶ Runs an image on EC2.
Parameters: - image_id (string) – The ID of the image to run
- min_count (int) – The minimum number of instances to launch
- max_count (int) – The maximum number of instances to launch
- key_name (string) – The name of the key pair with which to launch instances
- security_groups (list of strings) – The names of the security groups with which to associate instances
- user_data (string) – The user data passed to the launched instances
- instance_type (string) –
The type of instance to run:
- m1.small
- m1.large
- m1.xlarge
- c1.medium
- c1.xlarge
- m2.xlarge
- m2.2xlarge
- m2.4xlarge
- cc1.4xlarge
- t1.micro
- placement (string) – The availability zone in which to launch the instances
- kernel_id (string) – The ID of the kernel with which to launch the instances
- ramdisk_id (string) – The ID of the RAM disk with which to launch the instances
- monitoring_enabled (bool) – Enable CloudWatch monitoring on the instance.
- subnet_id (string) – The subnet ID within which to launch the instances for VPC.
- private_ip_address (string) – 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).
- block_device_map (
boto.ec2.blockdevicemapping.BlockDeviceMapping
) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image. - disable_api_termination (bool) – If True, the instances will be locked and will not be able to be terminated via the API.
- instance_initiated_shutdown_behavior (string) –
Specifies whether the instance stops or terminates on instance-initiated shutdown. Valid values are:
- stop
- terminate
- placement_group (string) – If specified, this is the name of the placement group in which the instance(s) will be launched.
- client_token (string) – Unique, case-sensitive identifier you provide to ensure idempotency of the request. Maximum 64 ASCII characters
- security_group_ids (list of strings) – The ID of the VPC security groups with which to associate instances
Return type: Returns: The
boto.ec2.instance.Reservation
associated with the request for machines
-
start_instances
(instance_ids=None)¶ Start the instances specified
Parameters: instance_ids (list) – A list of strings of the Instance IDs to start Return type: list Returns: A list of the instances started
-
stop_instances
(instance_ids=None, force=False)¶ Stop the instances specified
Parameters: Return type: Returns: A list of the instances stopped
-
terminate_instances
(instance_ids=None)¶ Terminate the instances specified
Parameters: instance_ids (list) – A list of strings of the Instance IDs to terminate Return type: list Returns: A list of the instances terminated
-
trim_snapshots
(hourly_backups=8, daily_backups=7, weekly_backups=4)¶ Trim excess snapshots, based on when they were taken. More current snapshots are retained, with the number retained decreasing as you move back in time.
If ebs volumes have a ‘Name’ tag with a value, their snapshots will be assigned the same tag when they are created. The values of the ‘Name’ tags for snapshots are used by this function to group snapshots taken from the same volume (or from a series of like-named volumes over time) for trimming.
For every group of like-named snapshots, this function retains the newest and oldest snapshots, as well as, by default, the first snapshots taken in each of the last eight hours, the first snapshots taken in each of the last seven days, the first snapshots taken in the last 4 weeks (counting Midnight Sunday morning as the start of the week), and the first snapshot from the first Sunday of each month forever.
Parameters:
-
unmonitor_instance
(instance_id)¶ Deprecated Version, maintained for backward compatibility. Disable CloudWatch monitoring for the supplied instance.
Parameters: instance_id (string) – The instance id Return type: list Returns: A list of boto.ec2.instanceinfo.InstanceInfo
-
unmonitor_instances
(instance_ids)¶ Disable CloudWatch monitoring for the supplied instance.
Parameters: instance_id (list of string) – The instance id Return type: list Returns: A list of boto.ec2.instanceinfo.InstanceInfo
boto.ec2.ec2object¶
Represents an EC2 Object
-
class
boto.ec2.ec2object.
EC2Object
(connection=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.ec2object.
TaggedEC2Object
(connection=None)¶ Any EC2 resource that can be tagged should be represented by a Python object that subclasses this class. This class has the mechanism in place to handle the tagSet element in the Describe* responses. If tags are found, it will create a TagSet object and allow it to parse and collect the tags into a dict that is stored in the “tags” attribute of the object.
-
add_tag
(key, value=None)¶ Add a tag to this object. Tag’s are stored by AWS and can be used to organize and filter resources. Adding a tag involves a round-trip to the EC2 service.
Parameters:
-
remove_tag
(key, value=None)¶ Remove a tag from this object. Removing a tag involves a round-trip to the EC2 service.
Parameters:
-
startElement
(name, attrs, connection)¶
-
boto.ec2.elb¶
This module provides an interface to the Elastic Compute Cloud (EC2) load balancing service from AWS.
-
class
boto.ec2.elb.
ELBConnection
(aws_access_key_id=None, aws_secret_access_key=None, is_secure=False, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/')¶ Init method to create a new connection to EC2 Load Balancing Service.
B{Note:} The region argument is overridden by the region specified in the boto configuration file.
-
APIVersion
= '2011-04-05'¶
-
DefaultRegionEndpoint
= 'elasticloadbalancing.amazonaws.com'¶
-
DefaultRegionName
= 'us-east-1'¶
-
build_list_params
(params, items, label)¶
-
configure_health_check
(name, health_check)¶ Define a health check for the EndPoints.
Parameters: - name (string) – The mnemonic name associated with the load balancer
- health_check (
boto.ec2.elb.healthcheck.HealthCheck
) – A HealthCheck object populated with the desired values.
Return type: Returns: The updated
boto.ec2.elb.healthcheck.HealthCheck
Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This policy can only be associated with HTTP listeners.
This policy is similar to the policy created by CreateLBCookieStickinessPolicy, except that the lifetime of the special Elastic Load Balancing cookie follows the lifetime of the application-generated cookie specified in the policy configuration. The load balancer only inserts a new stickiness cookie when the application response includes a new application cookie.
If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.
Generates a stickiness policy with sticky session lifetimes controlled by the lifetime of the browser (user-agent) or a specified expiration period. This policy can only be associated only with HTTP listeners.
When a load balancer implements this policy, the load balancer uses a special cookie to track the backend server instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If so, the load balancer sends the request to the application server specified in the cookie. If not, the load balancer sends the request to a server that is chosen based on the existing load balancing algorithm.
A cookie is inserted into the response for binding subsequent requests from the same user to that server. The validity of the cookie is based on the cookie expiration time, which is specified in the policy configuration.
-
create_load_balancer
(name, zones, listeners)¶ Create a new load balancer for your account.
Parameters: - name (string) – The mnemonic name associated with the new load balancer
- zones (List of strings) – The names of the availability zone(s) to add.
- listeners (List of tuples) – Each tuple contains three or four values, (LoadBalancerPortNumber, InstancePortNumber, Protocol, [SSLCertificateId]) where LoadBalancerPortNumber and InstancePortNumber are integer values between 1 and 65535, Protocol is a string containing either ‘TCP’, ‘HTTP’ or ‘HTTPS’; SSLCertificateID is the ARN of a AWS AIM certificate, and must be specified when doing HTTPS.
Return type: Returns: The newly created
boto.ec2.elb.loadbalancer.LoadBalancer
-
create_load_balancer_listeners
(name, listeners)¶ Creates a Listener (or group of listeners) for an existing Load Balancer
Parameters: - name (string) – The name of the load balancer to create the listeners for
- listeners (List of tuples) – Each tuple contains three values, (LoadBalancerPortNumber, InstancePortNumber, Protocol, [SSLCertificateId]) where LoadBalancerPortNumber and InstancePortNumber are integer values between 1 and 65535, Protocol is a string containing either ‘TCP’, ‘HTTP’ or ‘HTTPS’; SSLCertificateID is the ARN of a AWS AIM certificate, and must be specified when doing HTTPS.
Returns: The status of the request
-
delete_lb_policy
(lb_name, policy_name)¶ Deletes a policy from the LoadBalancer. The specified policy must not be enabled for any listeners.
-
delete_load_balancer
(name)¶ Delete a Load Balancer from your account.
Parameters: name (string) – The name of the Load Balancer to delete
-
delete_load_balancer_listeners
(name, ports)¶ Deletes a load balancer listener (or group of listeners)
Parameters: - name (string) – The name of the load balancer to create the listeners for
- ports (List int) – Each int represents the port on the ELB to be removed
Returns: The status of the request
-
deregister_instances
(load_balancer_name, instances)¶ Remove Instances from an existing Load Balancer.
Parameters: - load_balancer_name (string) – The name of the Load Balancer
- instances (List of strings) – The instance ID’s of the EC2 instances to remove.
Return type: List of strings
Returns: An updated list of instances for this Load Balancer.
-
describe_instance_health
(load_balancer_name, instances=None)¶ Get current state of all Instances registered to an Load Balancer.
Parameters: - load_balancer_name (string) – The name of the Load Balancer
- instances (List of strings) – The instance ID’s of the EC2 instances to return status for. If not provided, the state of all instances will be returned.
Return type: Returns: list of state info for instances in this Load Balancer.
-
disable_availability_zones
(load_balancer_name, zones_to_remove)¶ Remove availability zones from an existing Load Balancer. All zones must be in the same region as the Load Balancer. Removing zones that are not registered with the Load Balancer has no effect. You cannot remove all zones from an Load Balancer.
Parameters: - load_balancer_name (string) – The name of the Load Balancer
- zones (List of strings) – The name of the zone(s) to remove.
Return type: List of strings
Returns: An updated list of zones for this Load Balancer.
-
enable_availability_zones
(load_balancer_name, zones_to_add)¶ Add availability zones to an existing Load Balancer All zones must be in the same region as the Load Balancer Adding zones that are already registered with the Load Balancer has no effect.
Parameters: - load_balancer_name (string) – The name of the Load Balancer
- zones (List of strings) – The name of the zone(s) to add.
Return type: List of strings
Returns: An updated list of zones for this Load Balancer.
-
get_all_load_balancers
(load_balancer_names=None)¶ Retrieve all load balancers associated with your account.
Parameters: load_balancer_names (list) – An optional list of load balancer names Return type: list Returns: A list of boto.ec2.elb.loadbalancer.LoadBalancer
-
register_instances
(load_balancer_name, instances)¶ Add new Instances to an existing Load Balancer.
Parameters: - load_balancer_name (string) – The name of the Load Balancer
- instances (List of strings) – The instance ID’s of the EC2 instances to add.
Return type: List of strings
Returns: An updated list of instances for this Load Balancer.
-
set_lb_listener_SSL_certificate
(lb_name, lb_port, ssl_certificate_id)¶ Sets the certificate that terminates the specified listener’s SSL connections. The specified certificate replaces any prior certificate that was used on the same LoadBalancer and port.
-
set_lb_policies_of_listener
(lb_name, lb_port, policies)¶ Associates, updates, or disables a policy with a listener on the load balancer. Currently only zero (0) or one (1) policy can be associated with a listener.
-
-
boto.ec2.elb.
connect_to_region
(region_name, **kw_params)¶ Given a valid region name, return a
boto.ec2.elb.ELBConnection
.Parameters: region_name (str) – The name of the region to connect to. Return type: boto.ec2.ELBConnection
orNone
Returns: A connection to the given region, or None if an invalid region name is given
boto.ec2.elb.healthcheck¶
boto.ec2.elb.instancestate¶
boto.ec2.elb.listelement¶
boto.ec2.elb.listener¶
boto.ec2.elb.loadbalancer¶
-
class
boto.ec2.elb.loadbalancer.
LoadBalancer
(connection=None, name=None, endpoints=None)¶ Represents an EC2 Load Balancer
-
configure_health_check
(health_check)¶
-
create_listener
(inPort, outPort=None, proto='tcp')¶
-
create_listeners
(listeners)¶
-
delete
()¶ Delete this load balancer
-
delete_listener
(inPort, outPort=None, proto='tcp')¶
-
delete_listeners
(listeners)¶
-
delete_policy
(policy_name)¶ Deletes a policy from the LoadBalancer. The specified policy must not be enabled for any listeners.
-
deregister_instances
(instances)¶ Remove instances from this Load Balancer. Removing instances that are not registered with the Load Balancer has no effect.
Parameters: zones (string or List of instance id's) – The name of the endpoint(s) to add.
-
disable_zones
(zones)¶ Disable availability zones from this Access Point.
Parameters: zones (string or List of strings) – The name of the zone(s) to add.
-
enable_zones
(zones)¶ Enable availability zones to this Access Point. All zones must be in the same region as the Access Point.
Parameters: zones (string or List of strings) – The name of the zone(s) to add.
-
endElement
(name, value, connection)¶
-
get_instance_health
(instances=None)¶
-
register_instances
(instances)¶ Add instances to this Load Balancer All instances must be in the same region as the Load Balancer. Adding endpoints that are already registered with the Load Balancer has no effect.
Parameters: zones (string or List of instance id's) – The name of the endpoint(s) to add.
-
set_listener_SSL_certificate
(lb_port, ssl_certificate_id)¶
-
set_policies_of_listener
(lb_port, policies)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.image¶
-
class
boto.ec2.image.
Image
(connection=None)¶ Represents an EC2 Image
-
deregister
(delete_snapshot=False)¶
-
endElement
(name, value, connection)¶
-
get_kernel
()¶
-
get_launch_permissions
()¶
-
get_ramdisk
()¶
-
remove_launch_permissions
(user_ids=None, group_names=None)¶
-
reset_launch_attributes
()¶
-
run
(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, security_group_ids=None)¶ Runs this instance.
Parameters: - min_count (int) – The minimum number of instances to start
- max_count (int) – The maximum number of instances to start
- key_name (string) – The name of the keypair to run this instance with.
- security_groups –
- user_data –
- daddressing_type –
- instance_type (string) – The type of instance to run. Current choices are: m1.small | m1.large | m1.xlarge | c1.medium | c1.xlarge | m2.xlarge | m2.2xlarge | m2.4xlarge | cc1.4xlarge
- placement (string) – The availability zone in which to launch the instances
- kernel_id (string) – The ID of the kernel with which to launch the instances
- ramdisk_id (string) – The ID of the RAM disk with which to launch the instances
- monitoring_enabled (bool) – Enable CloudWatch monitoring on the instance.
- subnet_id (string) – The subnet ID within which to launch the instances for VPC.
- private_ip_address (string) – 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).
- block_device_map (
boto.ec2.blockdevicemapping.BlockDeviceMapping
) – A BlockDeviceMapping data structure describing the EBS volumes associated with the Image. - disable_api_termination (bool) – If True, the instances will be locked and will not be able to be terminated via the API.
- instance_initiated_shutdown_behavior (string) – Specifies whether the instance stops or terminates on instance-initiated shutdown. Valid values are: stop | terminate
- placement_group (string) – If specified, this is the name of the placement group in which the instance(s) will be launched.
- security_group_ids –
Return type: Returns: The
boto.ec2.instance.Reservation
associated with the request for machines
-
set_launch_permissions
(user_ids=None, group_names=None)¶
-
startElement
(name, attrs, connection)¶
-
update
(validate=False)¶ Update the image’s state information by making a call to fetch the current image attributes from the service.
Parameters: validate (bool) – By default, if EC2 returns no data about the image the update method returns quietly. If the validate param is True, however, it will raise a ValueError exception if no data is returned from EC2.
-
boto.ec2.instance¶
Represents an EC2 Instance
-
class
boto.ec2.instance.
ConsoleOutput
(parent=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.instance.
Group
(parent=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.instance.
Instance
(connection=None)¶ -
confirm_product
(product_code)¶
-
endElement
(name, value, connection)¶
-
get_attribute
(attribute)¶ Gets an attribute from this instance.
Parameters: attribute (string) – The attribute you need information about Valid choices are: instanceType|kernel|ramdisk|userData| disableApiTermination| instanceInitiatedShutdownBehavior| rootDeviceName|blockDeviceMapping Return type: boto.ec2.image.InstanceAttribute
Returns: An InstanceAttribute object representing the value of the attribute requested
-
get_console_output
()¶ Retrieves the console output for the instance.
Return type: boto.ec2.instance.ConsoleOutput
Returns: The console output as a ConsoleOutput object
-
modify_attribute
(attribute, value)¶ Changes an attribute of this instance
Parameters: - attribute (string) – The attribute you wish to change. AttributeName - Expected value (default) 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 rootDeviceName - device name (None)
- value (string) – The new value for the attribute
Return type: Returns: Whether the operation succeeded or not
-
monitor
()¶
-
reboot
()¶
-
reset_attribute
(attribute)¶ Resets an attribute of this instance to its default value.
Parameters: attribute (string) – The attribute to reset. Valid values are: kernel|ramdisk Return type: bool Returns: Whether the operation succeeded or not
-
start
()¶ Start the instance.
-
startElement
(name, attrs, connection)¶
-
stop
(force=False)¶ Stop the instance
Parameters: force (bool) – Forces the instance to stop Return type: list Returns: A list of the instances stopped
-
terminate
()¶ Terminate the instance
-
unmonitor
()¶
-
update
(validate=False)¶ Update the instance’s state information by making a call to fetch the current instance attributes from the service.
Parameters: validate (bool) – By default, if EC2 returns no data about the instance the update method returns quietly. If the validate param is True, however, it will raise a ValueError exception if no data is returned from EC2.
-
use_ip
(ip_address)¶
-
-
class
boto.ec2.instance.
InstanceAttribute
(parent=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.instanceinfo¶
boto.ec2.keypair¶
Represents an EC2 Keypair
-
class
boto.ec2.keypair.
KeyPair
(connection=None)¶ -
copy_to_region
(region)¶ Create a new key pair of the same new in another region. Note that the new key pair will use a different ssh cert than the this key pair. After doing the copy, you will need to save the material associated with the new key pair (use the save method) to a local file.
Parameters: region ( boto.ec2.regioninfo.RegionInfo
) – The region to which this security group will be copied.Return type: boto.ec2.keypair.KeyPair
Returns: The new key pair
-
endElement
(name, value, connection)¶
-
save
(directory_path)¶ Save the material (the unencrypted PEM encoded RSA private key) of a newly created KeyPair to a local file.
Parameters: directory_path (string) – The fully qualified path to the directory in which the keypair will be saved. The keypair file will be named using the name of the keypair as the base name and .pem for the file extension. If a file of that name already exists in the directory, an exception will be raised and the old file will not be overwritten. Return type: bool Returns: True if successful.
-
boto.ec2.regioninfo¶
-
class
boto.ec2.regioninfo.
EC2RegionInfo
(connection=None, name=None, endpoint=None)¶ Represents an EC2 Region
boto.ec2.reservedinstance¶
-
class
boto.ec2.reservedinstance.
ReservedInstance
(connection=None, id=None, instance_type=None, availability_zone=None, duration=None, fixed_price=None, usage_price=None, description=None, instance_count=None, state=None)¶ -
endElement
(name, value, connection)¶
-
-
class
boto.ec2.reservedinstance.
ReservedInstancesOffering
(connection=None, id=None, instance_type=None, availability_zone=None, duration=None, fixed_price=None, usage_price=None, description=None)¶ -
describe
()¶
-
endElement
(name, value, connection)¶
-
purchase
(instance_count=1)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.securitygroup¶
Represents an EC2 Security Group
-
class
boto.ec2.securitygroup.
GroupOrCIDR
(parent=None)¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.securitygroup.
IPPermissions
(parent=None)¶ -
add_grant
(name=None, owner_id=None, cidr_ip=None)¶
-
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.securitygroup.
SecurityGroup
(connection=None, owner_id=None, name=None, description=None, id=None)¶ -
add_rule
(ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip)¶ Add a rule to the SecurityGroup object. Note that this method only changes the local version of the object. No information is sent to EC2.
Add a new rule to this security group. You need to pass in either src_group_name OR ip_protocol, from_port, to_port, and cidr_ip. In other words, either you are authorizing another group or you are authorizing some ip-based rule.
Parameters: - ip_protocol (string) – Either tcp | udp | icmp
- from_port (int) – The beginning port number you are enabling
- to_port (int) – The ending port number you are enabling
- cidr_ip (string) – The CIDR block you are providing access to. See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
- src_group (
boto.ec2.securitygroup.SecurityGroup
orboto.ec2.securitygroup.GroupOrCIDR
) – The Security Group you are granting access to.
Return type: Returns: True if successful.
-
copy_to_region
(region, name=None)¶ Create a copy of this security group in another region. Note that the new security group will be a separate entity and will not stay in sync automatically after the copy operation.
Parameters: - region (
boto.ec2.regioninfo.RegionInfo
) – The region to which this security group will be copied. - name (string) – The name of the copy. If not supplied, the copy will have the same name as this security group.
Return type: Returns: The new security group.
- region (
-
delete
()¶
-
endElement
(name, value, connection)¶
-
instances
()¶ Find all of the current instances that are running within this security group.
Return type: list of boto.ec2.instance.Instance
Returns: A list of Instance objects
-
remove_rule
(ip_protocol, from_port, to_port, src_group_name, src_group_owner_id, cidr_ip)¶ Remove a rule to the SecurityGroup object. Note that this method only changes the local version of the object. No information is sent to EC2.
-
revoke
(ip_protocol=None, from_port=None, to_port=None, cidr_ip=None, src_group=None)¶
-
startElement
(name, attrs, connection)¶
-
boto.ec2.snapshot¶
Represents an EC2 Elastic IP Snapshot
-
class
boto.ec2.snapshot.
Snapshot
(connection=None)¶ -
delete
()¶
-
endElement
(name, value, connection)¶
-
get_permissions
()¶
-
reset_permissions
()¶
-
update
(validate=False)¶ Update the data associated with this snapshot by querying EC2.
Parameters: validate (bool) – By default, if EC2 returns no data about the snapshot the update method returns quietly. If the validate param is True, however, it will raise a ValueError exception if no data is returned from EC2.
-
boto.ec2.volume¶
Represents an EC2 Elastic Block Storage Volume
-
class
boto.ec2.volume.
AttachmentSet
¶ -
endElement
(name, value, connection)¶
-
startElement
(name, attrs, connection)¶
-
-
class
boto.ec2.volume.
Volume
(connection=None)¶ -
attach
(instance_id, device)¶ Attach this EBS volume to an EC2 instance.
Parameters: Return type: Returns: True if successful
-
attachment_state
()¶ Get the attachment state.
-
create_snapshot
(description=None)¶ Create a snapshot of this EBS Volume.
Parameters: description (str) – A description of the snapshot. Limited to 256 characters. Return type: bool Returns: True if successful
-
detach
(force=False)¶ Detach this EBS volume from an EC2 instance.
Parameters: force (bool) – Forces detachment if the previous detachment attempt did not occur cleanly. This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. Return type: bool Returns: True if successful
-
endElement
(name, value, connection)¶
-
snapshots
(owner=None, restorable_by=None)¶ Get all snapshots related to this volume. Note that this requires that all available snapshots for the account be retrieved from EC2 first and then the list is filtered client-side to contain only those for this volume.
Parameters: Return type: list of L{boto.ec2.snapshot.Snapshot}
Returns: The requested Snapshot objects
-
startElement
(name, attrs, connection)¶
-
update
(validate=False)¶ Update the data associated with this volume by querying EC2.
Parameters: validate (bool) – By default, if EC2 returns no data about the volume the update method returns quietly. If the validate param is True, however, it will raise a ValueError exception if no data is returned from EC2.
-
volume_state
()¶ Returns the state of the volume. Same value as the status attribute.
-