Auto Scaling Reference

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=0, 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 = '2011-01-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_or_update_tags(tags)

Creates new tags or updates existing tags for an Auto Scaling group.

Parameters:tags (List of boto.ec2.autoscale.tag.Tag) – The new or updated tags.
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, force_delete=False)

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 a policy.

Parameters:
  • policy_name (str) – The name or ARN of the policy to delete.
  • autoscale_group (str) – The name of the autoscale group.
delete_scheduled_action(scheduled_action_name, autoscale_group=None)

Deletes a previously scheduled action.

Parameters:
  • scheduled_action_name (str) – The name of the action you want to delete.
  • autoscale_group (str) – The name of the autoscale group.
delete_tags(tags)

Deletes existing tags for an Auto Scaling group.

Parameters:tags (List of boto.ec2.autoscale.tag.Tag) – The new or updated tags.
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:
Return type:

list

Returns:

List of boto.ec2.autoscale.activity.Activity instances.

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:
  • instance_ids (list) – List of Autoscaling Instance IDs which should be searched for.
  • max_records (int) – Maximum number of results to return.
Return type:

list

Returns:

List of boto.ec2.autoscale.activity.Activity objects.

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:
  • names (list) – List of group names which should be searched for.
  • max_records (int) – Maximum amount of groups to return.
Return type:

list

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:
  • names (list) – List of configuration names which should be searched for.
  • max_records (int) – Maximum amount of configurations to return.
  • next_token (str) – If you have more results than can be returned at once, pass in this parameter to page through all results.
Return type:

list

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:
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)
get_all_tags(filters=None, max_records=None, next_token=None)

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.

Parameters:
  • filters (dict) – The value of the filter type used to identify the tags to be returned. NOT IMPLEMENTED YET.
  • max_records (int) – Maximum number of tags to return.
Return type:

list

Returns:

List of boto.ec2.autoscale.tag.Tag instances.

resume_processes(as_group, scaling_processes=None)

Resumes Auto Scaling processes for an Auto Scaling group.

Parameters:
  • as_group (string) – The auto scaling group to resume processes on.
  • scaling_processes (list) – Processes you want to resume. If omitted, all processes will be resumed.
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:
  • as_group (string) – The auto scaling group to suspend processes on.
  • scaling_processes (list) – Processes you want to suspend. If omitted, all processes will be suspended.
terminate_instance(instance_id, decrement_capacity=True)

Terminates the specified instance. The desired group size can also be adjusted, if desired.

Parameters:
  • instance_id (str) – The ID of the instance to be terminated.
  • decrement_capacity – Whether to decrement the size of the autoscaling group or not.
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 or None
Returns:A connection to the given region, or None if an invalid region name is given
boto.ec2.autoscale.regions()

Get all available regions for the Auto Scaling service.

Return type:list
Returns:A list of boto.RegionInfo instances

boto.ec2.autoscale.activity

class boto.ec2.autoscale.activity.Activity(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

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:

boto.ec2.autoscale.group.AutoScalingGroup

Returns:

An autoscale group.

cooldown
delete(force_delete=False)

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)
class boto.ec2.autoscale.group.ProcessType(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.ec2.autoscale.group.SuspendedProcess(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.ec2.autoscale.instance

class boto.ec2.autoscale.instance.Instance(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

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)
class MetricCollectionTypes.Granularity(connection)
arg = 'Granularity'
class MetricCollectionTypes.Metric(connection)
arg = 'Metric'
MetricCollectionTypes.endElement(name, value, connection)
MetricCollectionTypes.startElement(name, attrs, connection)
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

class boto.ec2.autoscale.request.Request(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.ec2.autoscale.scheduled

class boto.ec2.autoscale.scheduled.ScheduledUpdateGroupAction(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)