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/request.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/group_collection.rb,
lib/aws/auto_scaling/scheduled_action.rb,
lib/aws/auto_scaling/activity_collection.rb,
lib/aws/auto_scaling/instance_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-east-1a us-east-1b),
  :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

#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
163
# File 'lib/aws/auto_scaling.rb', line 70

class AutoScaling

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

  include Core::ServiceInterface

  # @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:



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

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.



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

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

#groupsGroupCollection

Returns:



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

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

#launch_configurationsLaunchConfigurationCollection



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

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.



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

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.



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

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

#notification_configurationsNotificationConfigurationCollection



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

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>)


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

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.



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

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

#scheduled_actionsScheduledActionCollection



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

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

#tagsTagCollection

Returns:



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

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