Class: AWS::AutoScaling::Group
- Inherits:
-
Core::Resource
- Object
- Core::Resource
- AWS::AutoScaling::Group
- Defined in:
- lib/aws/auto_scaling/group.rb
Instance Attribute Summary (collapse)
-
- (Array<String>) availability_zone_names
readonly
The current value of availability_zone_names.
-
- (Time) created_time
readonly
The current value of created_time.
-
- (Integer) default_cooldown
readonly
The current value of default_cooldown.
-
- (Integer) desired_capacity
readonly
The current value of desired_capacity.
-
- (Array<Hash>) enabled_metrics
readonly
Returns a hash of enabled metric names (keys) and granularities (values).
-
- (Integer) health_check_grace_period
readonly
The current value of health_check_grace_period.
-
- (Symbol) health_check_type
readonly
Returns :ec2 or :vpc.
-
- (String) launch_configuration_name
readonly
The current value of launch_configuration_name.
-
- (Array<String>) load_balancer_names
readonly
The current value of load_balancer_names.
-
- (Integer) max_size
readonly
The current value of max_size.
-
- (Integer) min_size
readonly
The current value of min_size.
- - (String) name readonly
-
- (String?) placement_group
readonly
The current value of placement_group.
-
- (Hash) suspended_processes
readonly
A hash of suspended process names (keys) and reasons (values).
Instance Method Summary (collapse)
- - (ActivityCollection) activities
- - (Array<AutoScaling::Instance>) auto_scaling_instances
- - (Array<EC2::AvailabilityZone>) availability_zones
-
- (nil) delete(options = {})
Deletes the Auto Scaling group.
-
- (nil) delete!
Deletes the Auto Scaling group along with all instances associated with the group, without waiting for all instances to be terminated.
-
- (nil) delete_all_tags
Removes all tags from this Auto Scaling group.
-
- (nil) delete_tags(*tags)
Deletes specific tags from this Auto Scaling group.
-
- (nil) disable_all_metrics_collection
Disables all metrics collection for the Auto Scaling group.
- - (nil) disable_metrics_collection(*metrics)
-
- (EC2::InstanceCollection) ec2_instances
Returns a collection that represents the instances belonging to this Auto Scaling group.
-
- (nil) enable_all_metrics_collection
Enables all metrics collection for the Auto Scaling group.
- - (nil) enable_metrics_collection(*metrics)
- - (Boolean) exists?
-
- (Group) initialize(name, options = {})
constructor
A new instance of Group.
- - (LaunchConfiguration) launch_configuration
- - (Array, <ELB::LoadBalancer>) load_balancers
- - (NotificationConfigurationCollection) notification_configurations
-
- (nil) resume_all_processes
Resumes all processes for this Auto Scaling group.
-
- (nil) resume_processes(*processes)
Resumes processes for this Auto Scaling group.
- - (ScalingPolicyCollection) scaling_policies
- - (ScheduledActionCollection) scheduled_actions
-
- (nil) set_desired_capacity(capacity, options = {})
Adjusts the desired size of the Auto Scaling group by initiating scaling activities.
- - (Array<EC2::Subnet>) subnets
-
- (nil) suspend_all_processes
Suspends all processes for this Auto Scaling group.
-
- (nil) suspend_processes(*processes)
Suspends processes for this Auto Scaling group.
- - (Tag) tags
-
- (nil) update(options = {})
Update one or more attributes on the Auto Scaling group.
Constructor Details
- (Group) initialize(name, options = {})
A new instance of Group
51 52 53 54 |
# File 'lib/aws/auto_scaling/group.rb', line 51 def initialize name, = {} @name = name super end |
Instance Attribute Details
- (Array<String>) availability_zone_names (readonly)
The current value of availability_zone_names
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def availability_zone_names @availability_zone_names end |
- (Time) created_time (readonly)
The current value of created_time
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def created_time @created_time end |
- (Integer) default_cooldown (readonly)
The current value of default_cooldown
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def default_cooldown @default_cooldown end |
- (Integer) desired_capacity (readonly)
The current value of desired_capacity
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def desired_capacity @desired_capacity end |
- (Array<Hash>) enabled_metrics (readonly)
Returns a hash of enabled metric names (keys) and granularities (values).
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def enabled_metrics @enabled_metrics end |
- (Integer) health_check_grace_period (readonly)
The current value of health_check_grace_period
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def health_check_grace_period @health_check_grace_period end |
- (Symbol) health_check_type (readonly)
Returns :ec2 or :vpc.
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def health_check_type @health_check_type end |
- (String) launch_configuration_name (readonly)
The current value of launch_configuration_name
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def launch_configuration_name @launch_configuration_name end |
- (Array<String>) load_balancer_names (readonly)
The current value of load_balancer_names
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def load_balancer_names @load_balancer_names end |
- (Integer) max_size (readonly)
The current value of max_size
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def max_size @max_size end |
- (Integer) min_size (readonly)
The current value of min_size
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def min_size @min_size end |
- (String) name (readonly)
57 58 59 |
# File 'lib/aws/auto_scaling/group.rb', line 57 def name @name end |
- (String?) placement_group (readonly)
The current value of placement_group
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def placement_group @placement_group end |
- (Hash) suspended_processes (readonly)
A hash of suspended process names (keys) and reasons (values).
47 48 49 |
# File 'lib/aws/auto_scaling/group.rb', line 47 def suspended_processes @suspended_processes end |
Instance Method Details
- (ActivityCollection) activities
146 147 148 |
# File 'lib/aws/auto_scaling/group.rb', line 146 def activities ActivityCollection.new(:group => self) end |
- (Array<AutoScaling::Instance>) auto_scaling_instances
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/aws/auto_scaling/group.rb', line 151 def auto_scaling_instances instances.collect do |details| Instance.new_from( :describe_auto_scaling_groups, details, details.instance_id, :auto_scaling_group_name => name, # not provided by the response :config => config) end end |
- (Array<EC2::AvailabilityZone>) availability_zones
187 188 189 190 191 |
# File 'lib/aws/auto_scaling/group.rb', line 187 def availability_zones availability_zone_names.collect do |az_name| EC2::AvailabilityZone.new(az_name, :config => config) end end |
- (nil) delete(options = {})
Deletes the Auto Scaling group. If you pass :force as true
then all the instances associated with this group will also
be terminated.
382 383 384 385 386 387 388 |
# File 'lib/aws/auto_scaling/group.rb', line 382 def delete = {} client_opts = {} client_opts[:force_delete] = [:force] == true client_opts[:auto_scaling_group_name] = name client.delete_auto_scaling_group(client_opts) nil end |
- (nil) delete!
Deletes the Auto Scaling group along with all instances associated with the group, without waiting for all instances to be terminated.
394 395 396 397 |
# File 'lib/aws/auto_scaling/group.rb', line 394 def delete! delete(:force => true) nil end |
- (nil) delete_all_tags
Removes all tags from this Auto Scaling group.
363 364 365 366 |
# File 'lib/aws/auto_scaling/group.rb', line 363 def (self.) nil end |
- (nil) delete_tags(*tags)
Deletes specific tags from this Auto Scaling group.
group.([
{ :key => 'role', :value => 'webserver' },
])
You may also pass Tag objects.
351 352 353 354 355 356 357 358 359 |
# File 'lib/aws/auto_scaling/group.rb', line 351 def * = .flatten.collect do |tag| tag.to_hash.merge( :resource_type => 'auto-scaling-group', :resource_id => name) end client.(:tags => ) nil end |
- (nil) disable_all_metrics_collection
Disables all metrics collection for the Auto Scaling group.
299 300 301 |
# File 'lib/aws/auto_scaling/group.rb', line 299 def disable_all_metrics_collection disable_metrics_collection end |
- (nil) disable_metrics_collection(*metrics)
289 290 291 292 293 294 295 |
# File 'lib/aws/auto_scaling/group.rb', line 289 def disable_metrics_collection *metrics client_opts = {} client_opts[:auto_scaling_group_name] = name client_opts[:metrics] = metrics.flatten client.disable_metrics_collection(client_opts) nil end |
- (EC2::InstanceCollection) ec2_instances
Returns a collection that represents the instances belonging to this Auto Scaling group. You can use this collection to further refine the instances you are interested in:
group.ec2_instances.filter('availability-zone', 'us-west-2a').each do |i|
puts instance.id
end
174 175 176 177 |
# File 'lib/aws/auto_scaling/group.rb', line 174 def ec2_instances instances = EC2::InstanceCollection.new(:config => config) instances.tagged('aws:autoscaling:groupName').tagged_values(name) end |
- (nil) enable_all_metrics_collection
Enables all metrics collection for the Auto Scaling group.
283 284 285 |
# File 'lib/aws/auto_scaling/group.rb', line 283 def enable_all_metrics_collection enable_metrics_collection end |
- (nil) enable_metrics_collection(*metrics)
272 273 274 275 276 277 278 279 |
# File 'lib/aws/auto_scaling/group.rb', line 272 def enable_metrics_collection *metrics client_opts = {} client_opts[:auto_scaling_group_name] = name client_opts[:granularity] = '1Minute' client_opts[:metrics] = metrics.flatten client.enable_metrics_collection(client_opts) nil end |
- (Boolean) exists?
400 401 402 403 404 405 |
# File 'lib/aws/auto_scaling/group.rb', line 400 def exists? client_opts = {} client_opts[:auto_scaling_group_names] = [name] resp = client.describe_auto_scaling_groups(client_opts) !resp.auto_scaling_groups.empty? end |
- (LaunchConfiguration) launch_configuration
141 142 143 |
# File 'lib/aws/auto_scaling/group.rb', line 141 def launch_configuration LaunchConfiguration.new(launch_configuration_name, :config => config) end |
- (Array, <ELB::LoadBalancer>) load_balancers
194 195 196 197 198 |
# File 'lib/aws/auto_scaling/group.rb', line 194 def load_balancers load_balancer_names.collect do |name| ELB::LoadBalancer.new(name, :config => config) end end |
- (NotificationConfigurationCollection) notification_configurations
123 124 125 |
# File 'lib/aws/auto_scaling/group.rb', line 123 def notification_configurations NotificationConfigurationCollection.new(:group => self) end |
- (nil) resume_all_processes
Resumes all processes for this Auto Scaling group.
266 267 268 |
# File 'lib/aws/auto_scaling/group.rb', line 266 def resume_all_processes resume_processes end |
- (nil) resume_processes(*processes)
Resumes processes for this Auto Scaling group.
# resume two processes by name
auto_scaling_group.suspend_processes 'Launch', 'AZRebalance'
256 257 258 259 260 261 262 |
# File 'lib/aws/auto_scaling/group.rb', line 256 def resume_processes *processes client_opts = {} client_opts[:auto_scaling_group_name] = name client_opts[:scaling_processes] = processes.flatten client.resume_processes(client_opts) nil end |
- (ScalingPolicyCollection) scaling_policies
118 119 120 |
# File 'lib/aws/auto_scaling/group.rb', line 118 def scaling_policies ScalingPolicyCollection.new(self) end |
- (ScheduledActionCollection) scheduled_actions
128 129 130 131 |
# File 'lib/aws/auto_scaling/group.rb', line 128 def scheduled_actions actions = ScheduledActionCollection.new(:config => config) actions.filter(:group => self) end |
- (nil) set_desired_capacity(capacity, options = {})
Adjusts the desired size of the Auto Scaling group by initiating scaling activities. When reducing the size of the group, it is not possible to define which Amazon EC2 instances will be terminated. This applies to any Auto Scaling decisions that might result in terminating instances.
215 216 217 218 219 220 221 222 |
# File 'lib/aws/auto_scaling/group.rb', line 215 def set_desired_capacity capacity, = {} client_opts = {} client_opts[:auto_scaling_group_name] = name client_opts[:desired_capacity] = capacity client_opts[:honor_cooldown] = [:honor_cooldown] == true client.set_desired_capacity(client_opts) nil end |
- (Array<EC2::Subnet>) subnets
180 181 182 183 184 |
# File 'lib/aws/auto_scaling/group.rb', line 180 def subnets vpc_zone_identifier.to_s.split(/,/).collect do |subnet_id| EC2::Subnet.new(subnet_id, :config => config) end end |
- (nil) suspend_all_processes
Suspends all processes for this Auto Scaling group.
243 244 245 |
# File 'lib/aws/auto_scaling/group.rb', line 243 def suspend_all_processes suspend_processes end |
- (nil) suspend_processes(*processes)
Suspends processes for this Auto Scaling group.
# suspend two processes by name
auto_scaling_group.suspend_processes 'Launch', 'AZRebalance'
233 234 235 236 237 238 239 |
# File 'lib/aws/auto_scaling/group.rb', line 233 def suspend_processes *processes client_opts = {} client_opts[:auto_scaling_group_name] = name client_opts[:scaling_processes] = processes.flatten client.suspend_processes(client_opts) nil end |
- (Tag) tags
134 135 136 137 138 |
# File 'lib/aws/auto_scaling/group.rb', line 134 def tag_details.collect do |tag| Tag.new(tag.to_hash.merge(:config => config)) end end |
- (nil) update(options = {})
Update one or more attributes on the Auto Scaling group.
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/aws/auto_scaling/group.rb', line 311 def update = {} group_opts = () # tags must be updated using a separate request from the # other attributes, *sigh* if = group_opts.delete(:tags) .map(&:to_hash).each do |tag| tag[:resource_type] = 'auto-scaling-group' tag[:resource_id] = name end client.(:tags => ) end unless group_opts.empty? client_opts = group_opts.merge(:auto_scaling_group_name => name) client.update_auto_scaling_group(client_opts) end nil end |