You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::AutoScaling

Inherits:
Object
  • Object
show all
Includes:
Core::ServiceInterface
Defined in:
lib/aws/auto_scaling.rb,
lib/aws/auto_scaling/tag.rb,
lib/aws/auto_scaling/group.rb,
lib/aws/auto_scaling/client.rb,
lib/aws/auto_scaling/errors.rb,
lib/aws/auto_scaling/activity.rb,
lib/aws/auto_scaling/instance.rb,
lib/aws/auto_scaling/group_options.rb,
lib/aws/auto_scaling/scaling_policy.rb,
lib/aws/auto_scaling/tag_collection.rb,
lib/aws/auto_scaling/scheduled_action.rb,
lib/aws/auto_scaling/group_collection.rb,
lib/aws/auto_scaling/instance_collection.rb,
lib/aws/auto_scaling/activity_collection.rb,
lib/aws/auto_scaling/launch_configuration.rb,
lib/aws/auto_scaling/scaling_policy_options.rb,
lib/aws/auto_scaling/scaling_policy_collection.rb,
lib/aws/auto_scaling/notification_configuration.rb,
lib/aws/auto_scaling/scheduled_action_collection.rb,
lib/aws/auto_scaling/launch_configuration_collection.rb,
lib/aws/auto_scaling/notification_configuration_collection.rb

Overview

This class is the starting point for working with Auto Scaling.

To use Auto Scaling you must first sign up here.

For more information about Auto Scaling:

Credentials

You can setup default credentials for all AWS services via AWS.config:

AWS.config(
  :access_key_id => 'YOUR_ACCESS_KEY_ID',
  :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')

Or you can set them directly on the AWS::AutoScaling interface:

auto_scaling = AWS::AutoScaling.new(
  :access_key_id => 'YOUR_ACCESS_KEY_ID',
  :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')

Launch Configurations

You need to create a launch configuration before you can create an Auto Scaling Group.

# needs a name, image id, and instance type
launch_config = auto_scaling.launch_configurations.create(
  'launch-config-name', 'ami-12345', 'm1.small')

If you have previously created a launch configuration you can reference using the LaunchConfigurationCollection.

launch_config = auto_scaling.launch_configurations['launch-config-name']

Auto Scaling Groups

Given a launch configuration, you can now create an Auto Scaling Group.

group = auto_scaling.groups.create('group-name',
  :launch_configuration => launch_config,
  :availability_zones => %w(us-west-2a us-west-2b),
  :min_size => 1,
  :max_size => 4)

Defined Under Namespace

Modules: Errors Classes: Activity, ActivityCollection, Client, Group, GroupCollection, Instance, InstanceCollection, LaunchConfiguration, LaunchConfigurationCollection, NotificationConfiguration, NotificationConfigurationCollection, ScalingPolicy, ScalingPolicyCollection, ScheduledAction, ScheduledActionCollection, Tag, TagCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::ServiceInterface

included, #initialize, #inspect

Instance Attribute Details

#clientClient (readonly)

Returns the low-level AutoScaling client object

Returns:

  • (Client)

    the low-level AutoScaling client object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/aws/auto_scaling.rb', line 70

class AutoScaling

  autoload :Activity, 'aws/auto_scaling/activity'
  autoload :ActivityCollection, 'aws/auto_scaling/activity_collection'
  autoload :Client, 'aws/auto_scaling/client'
  autoload :Errors, 'aws/auto_scaling/errors'
  autoload :Group, 'aws/auto_scaling/group'
  autoload :GroupCollection, 'aws/auto_scaling/group_collection'
  autoload :GroupOptions, 'aws/auto_scaling/group_options'
  autoload :Instance, 'aws/auto_scaling/instance'
  autoload :InstanceCollection, 'aws/auto_scaling/instance_collection'
  autoload :LaunchConfiguration, 'aws/auto_scaling/launch_configuration'
  autoload :LaunchConfigurationCollection, 'aws/auto_scaling/launch_configuration_collection'
  autoload :NotificationConfiguration, 'aws/auto_scaling/notification_configuration'
  autoload :NotificationConfigurationCollection, 'aws/auto_scaling/notification_configuration_collection'
  autoload :ScalingPolicy, 'aws/auto_scaling/scaling_policy'
  autoload :ScalingPolicyCollection, 'aws/auto_scaling/scaling_policy_collection'
  autoload :ScalingPolicyOptions, 'aws/auto_scaling/scaling_policy_options'
  autoload :ScheduledAction, 'aws/auto_scaling/scheduled_action'
  autoload :ScheduledActionCollection, 'aws/auto_scaling/scheduled_action_collection'
  autoload :Tag, 'aws/auto_scaling/tag'
  autoload :TagCollection, 'aws/auto_scaling/tag_collection'

  include Core::ServiceInterface

  endpoint_prefix 'autoscaling'

  # @return [LaunchConfigurationCollection]
  def launch_configurations
    LaunchConfigurationCollection.new(:config => config)
  end

  # @return [GroupCollection]
  def groups
    GroupCollection.new(:config => config)
  end

  # @return [TagCollection]
  def tags
    TagCollection.new(:config => config)
  end

  # @return [NotificationConfigurationCollection]
  def notification_configurations
    NotificationConfigurationCollection.new(:config => config)
  end

  # @return [AutoScaling::InstancesCollection] Returns a collection of
  #   {AutoScaling::Instance} objects.  Each of these is a small
  #   wrapper around an {EC2::Instance} with additional attributes.
  def instances
    InstanceCollection.new(:config => config)
  end

  # @return [ActivityCollection]
  def activities
    ActivityCollection.new(:config => config)
  end

  # @return [ScheduledActionCollection]
  def scheduled_actions
    ScheduledActionCollection.new(:config => config)
  end

  # Returns a list of all notification types that are supported by
  # Auto Scaling.
  # @return [Array<String>]
  def notification_types
    resp = client.describe_auto_scaling_notification_types
    resp.auto_scaling_notification_types
  end

  # @return [Array<String>] Returns the list of valid adjustment types.
  def adjustment_types
    client.describe_adjustment_types.adjustment_types.map(&:adjustment_type)
  end

  # @return [Array<String>] Returns the list of valid scaling process types.
  def scaling_process_types
    client.describe_scaling_process_types.processes.map(&:process_name)
  end

  # @return [Array<String>] Returns the list of valid metric collection types.
  def metric_collection_types
    client.describe_metric_collection_types.metrics.map(&:metric)
  end

  # @return [Array<String>] Returns the list of valid metric granularities.
  def metric_collection_granularities
    client.describe_metric_collection_types.granularities.map(&:granularity)
  end

end

Instance Method Details

#activitiesActivityCollection

Returns:



125
126
127
# File 'lib/aws/auto_scaling.rb', line 125

def activities
  ActivityCollection.new(:config => config)
end

#adjustment_typesArray<String>

Returns the list of valid adjustment types.

Returns:

  • (Array<String>)

    Returns the list of valid adjustment types.



143
144
145
# File 'lib/aws/auto_scaling.rb', line 143

def adjustment_types
  client.describe_adjustment_types.adjustment_types.map(&:adjustment_type)
end

#groupsGroupCollection

Returns:



103
104
105
# File 'lib/aws/auto_scaling.rb', line 103

def groups
  GroupCollection.new(:config => config)
end

#instancesAutoScaling::InstancesCollection

Returns a collection of Instance objects. Each of these is a small wrapper around an EC2::Instance with additional attributes.

Returns:

  • (AutoScaling::InstancesCollection)

    Returns a collection of Instance objects. Each of these is a small wrapper around an EC2::Instance with additional attributes.



120
121
122
# File 'lib/aws/auto_scaling.rb', line 120

def instances
  InstanceCollection.new(:config => config)
end

#launch_configurationsLaunchConfigurationCollection



98
99
100
# File 'lib/aws/auto_scaling.rb', line 98

def launch_configurations
  LaunchConfigurationCollection.new(:config => config)
end

#metric_collection_granularitiesArray<String>

Returns the list of valid metric granularities.

Returns:

  • (Array<String>)

    Returns the list of valid metric granularities.



158
159
160
# File 'lib/aws/auto_scaling.rb', line 158

def metric_collection_granularities
  client.describe_metric_collection_types.granularities.map(&:granularity)
end

#metric_collection_typesArray<String>

Returns the list of valid metric collection types.

Returns:

  • (Array<String>)

    Returns the list of valid metric collection types.



153
154
155
# File 'lib/aws/auto_scaling.rb', line 153

def metric_collection_types
  client.describe_metric_collection_types.metrics.map(&:metric)
end

#notification_configurationsNotificationConfigurationCollection



113
114
115
# File 'lib/aws/auto_scaling.rb', line 113

def notification_configurations
  NotificationConfigurationCollection.new(:config => config)
end

#notification_typesArray<String>

Returns a list of all notification types that are supported by Auto Scaling.

Returns:

  • (Array<String>)


137
138
139
140
# File 'lib/aws/auto_scaling.rb', line 137

def notification_types
  resp = client.describe_auto_scaling_notification_types
  resp.auto_scaling_notification_types
end

#scaling_process_typesArray<String>

Returns the list of valid scaling process types.

Returns:

  • (Array<String>)

    Returns the list of valid scaling process types.



148
149
150
# File 'lib/aws/auto_scaling.rb', line 148

def scaling_process_types
  client.describe_scaling_process_types.processes.map(&:process_name)
end

#scheduled_actionsScheduledActionCollection



130
131
132
# File 'lib/aws/auto_scaling.rb', line 130

def scheduled_actions
  ScheduledActionCollection.new(:config => config)
end

#tagsTagCollection

Returns:



108
109
110
# File 'lib/aws/auto_scaling.rb', line 108

def tags
  TagCollection.new(:config => config)
end