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

Class: Aws::AutoScaling::AutoScalingGroup

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(name, options = {}) ⇒ Object

    Parameters:

    • name (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :name (required, String)
    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#auto_scaling_group_arnString (readonly)

The Amazon Resource Name (ARN) of the Auto Scaling group.

Returns:

  • (String)

    The Amazon Resource Name (ARN) of the Auto Scaling group.

#auto_scaling_group_nameString (readonly)

The name of the Auto Scaling group.

Returns:

  • (String)

    The name of the Auto Scaling group.

#availability_zonesArray<String> (readonly)

One or more Availability Zones for the group.

Returns:

  • (Array<String>)

    One or more Availability Zones for the group.

#capacity_rebalanceBoolean (readonly)

Indicates whether Capacity Rebalancing is enabled.

Returns:

  • (Boolean)

    Indicates whether Capacity Rebalancing is enabled.

#created_timeTime (readonly)

The date and time the group was created.

Returns:

  • (Time)

    The date and time the group was created.

#default_cooldownInteger (readonly)

The duration of the default cooldown period, in seconds.

Returns:

  • (Integer)

    The duration of the default cooldown period, in seconds.

#desired_capacityInteger (readonly)

The desired size of the group.

Returns:

  • (Integer)

    The desired size of the group.

#enabled_metricsArray<Types::EnabledMetric> (readonly)

The metrics enabled for the group.

Returns:

#health_check_grace_periodInteger (readonly)

The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service.

Returns:

  • (Integer)

    The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service.

#health_check_typeString (readonly)

The service to use for the health checks. The valid values are EC2 and ELB. If you configure an Auto Scaling group to use ELB health checks, it considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.

Returns:

  • (String)

    The service to use for the health checks.

#launch_configuration_nameString (readonly)

The name of the associated launch configuration.

Returns:

  • (String)

    The name of the associated launch configuration.

#launch_templateTypes::LaunchTemplateSpecification (readonly)

The launch template for the group.

Returns:

#load_balancer_namesArray<String> (readonly)

One or more load balancers associated with the group.

Returns:

  • (Array<String>)

    One or more load balancers associated with the group.

#max_instance_lifetimeInteger (readonly)

The maximum amount of time, in seconds, that an instance can be in service.

Valid Range: Minimum value of 0.

Returns:

  • (Integer)

    The maximum amount of time, in seconds, that an instance can be in service.

#max_sizeInteger (readonly)

The maximum size of the group.

Returns:

  • (Integer)

    The maximum size of the group.

#min_sizeInteger (readonly)

The minimum size of the group.

Returns:

  • (Integer)

    The minimum size of the group.

#mixed_instances_policyTypes::MixedInstancesPolicy (readonly)

The mixed instances policy for the group.

Returns:

#nameString (readonly)

Returns:

  • (String)

#new_instances_protected_from_scale_inBoolean (readonly)

Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.

Returns:

  • (Boolean)

    Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.

#placement_groupString (readonly)

The name of the placement group into which to launch your instances, if any.

Returns:

  • (String)

    The name of the placement group into which to launch your instances, if any.

#service_linked_role_arnString (readonly)

The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other AWS services on your behalf.

Returns:

  • (String)

    The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other AWS services on your behalf.

#statusString (readonly)

The current state of the group when the DeleteAutoScalingGroup operation is in progress.

Returns:

#suspended_processesArray<Types::SuspendedProcess> (readonly)

The suspended processes associated with the group.

Returns:

#target_group_arnsArray<String> (readonly)

The Amazon Resource Names (ARN) of the target groups for your load balancer.

Returns:

  • (Array<String>)

    The Amazon Resource Names (ARN) of the target groups for your load balancer.

#termination_policiesArray<String> (readonly)

The termination policies for the group.

Returns:

  • (Array<String>)

    The termination policies for the group.

#vpc_zone_identifierString (readonly)

One or more subnet IDs, if applicable, separated by commas.

Returns:

  • (String)

    One or more subnet IDs, if applicable, separated by commas.

Instance Method Details

#activities(options = {}) ⇒ Collection<Activity>

Returns a Collection of Aws::AutoScaling::Activity resources. No API requests are made until you call an enumerable method on the collection. Client#describe_scaling_activities will be called multiple times until every Aws::AutoScaling::Activity has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.activities({
  activity_ids: ["XmlString"],
  max_records: 1,
  next_token: "XmlString",
})

Enumerating Aws::AutoScaling::Activity resources.

autoscalinggroup.activities.each do |activity|
  # yields each activity
end

Enumerating Aws::AutoScaling::Activity resources with a limit.

autoscalinggroup.activities.limit(10).each do |activity|
  # yields at most 10 activities
end

Options Hash (options):

  • :activity_ids (Array<String>)

    The activity IDs of the desired scaling activities. You can specify up to 50 IDs. If you omit this parameter, all activities for the past six weeks are described. If unknown activities are requested, they are ignored with no error. If you specify an Auto Scaling group, the results are limited to that group.

  • :max_records (Integer)

    The maximum number of items to return with this call. The default value is 100 and the maximum value is 100.

  • :next_token (String)

    The token for the next set of items to return. (You received this token from a previous call.)

Returns:

See Also:

#attach_instances(options = {}) ⇒ Struct

Attaches one or more EC2 instances to the specified Auto Scaling group.

When you attach instances, Amazon EC2 Auto Scaling increases the desired capacity of the group by the number of instances being attached. If the number of instances being attached plus the desired capacity of the group exceeds the maximum size of the group, the operation fails.

If there is a Classic Load Balancer attached to your Auto Scaling group, the instances are also registered with the load balancer. If there are target groups attached to your Auto Scaling group, the instances are also registered with the target groups.

For more information, see Attach EC2 instances to your Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

Examples:

Request syntax example with placeholder values


autoscalinggroup.attach_instances({
  instance_ids: ["XmlStringMaxLen19"],
})

Options Hash (options):

  • :instance_ids (Array<String>)

    The IDs of the instances. You can specify up to 20 instances.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#delete(options = {}) ⇒ Struct

Deletes the specified Auto Scaling group.

If the group has instances or scaling activities in progress, you must specify the option to force the deletion in order for it to succeed.

If the group has policies, deleting the group deletes the policies, the underlying alarm actions, and any alarm that no longer has an associated action.

To remove instances from the Auto Scaling group before deleting it, call the DetachInstances API with the list of instances and the option to decrement the desired capacity. This ensures that Amazon EC2 Auto Scaling does not launch replacement instances.

To terminate all instances before deleting the Auto Scaling group, call the UpdateAutoScalingGroup API and set the minimum size and desired capacity of the Auto Scaling group to zero.

Examples:

Request syntax example with placeholder values


autoscalinggroup.delete({
  force_delete: false,
})

Options Hash (options):

  • :force_delete (Boolean)

    Specifies that the group is to be deleted along with all instances associated with the group, without waiting for all instances to be terminated. This parameter also deletes any lifecycle actions associated with the group.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#detach_instances(options = {}) ⇒ Array<Activity>

Examples:

Request syntax example with placeholder values


autoscalinggroup.detach_instances({
  instance_ids: ["XmlStringMaxLen19"],
  should_decrement_desired_capacity: false, # required
})

Basic usage

activitys = autoscalinggroup.detach_instances(options)
activitys.map(&:id)
#=> ["activity-id", ...]

Options Hash (options):

  • :instance_ids (Array<String>)

    The IDs of the instances. You can specify up to 20 instances.

  • :should_decrement_desired_capacity (required, Boolean)

    Indicates whether the Auto Scaling group decrements the desired capacity value by the number of instances detached.

Returns:

See Also:

#disable_metrics_collection(options = {}) ⇒ Struct

Disables group metrics for the specified Auto Scaling group.

Examples:

Request syntax example with placeholder values


autoscalinggroup.disable_metrics_collection({
  metrics: ["XmlStringMaxLen255"],
})

Options Hash (options):

  • :metrics (Array<String>)

    Specifies one or more of the following metrics:

    • GroupMinSize

    • GroupMaxSize

    • GroupDesiredCapacity

    • GroupInServiceInstances

    • GroupPendingInstances

    • GroupStandbyInstances

    • GroupTerminatingInstances

    • GroupTotalInstances

    • GroupInServiceCapacity

    • GroupPendingCapacity

    • GroupStandbyCapacity

    • GroupTerminatingCapacity

    • GroupTotalCapacity

    If you omit this parameter, all metrics are disabled.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#enable_metrics_collection(options = {}) ⇒ Struct

Enables group metrics for the specified Auto Scaling group. For more information, see Monitoring CloudWatch metrics for your Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.

Examples:

Request syntax example with placeholder values


autoscalinggroup.enable_metrics_collection({
  metrics: ["XmlStringMaxLen255"],
  granularity: "XmlStringMaxLen255", # required
})

Options Hash (options):

  • :metrics (Array<String>)

    Specifies which group-level metrics to start collecting. You can specify one or more of the following metrics:

    • GroupMinSize

    • GroupMaxSize

    • GroupDesiredCapacity

    • GroupInServiceInstances

    • GroupPendingInstances

    • GroupStandbyInstances

    • GroupTerminatingInstances

    • GroupTotalInstances

    The instance weighting feature supports the following additional metrics:

    • GroupInServiceCapacity

    • GroupPendingCapacity

    • GroupStandbyCapacity

    • GroupTerminatingCapacity

    • GroupTotalCapacity

    If you omit this parameter, all metrics are enabled.

  • :granularity (required, String)

    The granularity to associate with the metrics to collect. The only valid value is 1Minute.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#exists?Boolean

Returns true if this AutoScalingGroup exists. Returns false otherwise.

Returns:

  • (Boolean)

    Returns true if this AutoScalingGroup exists. Returns false otherwise.

#instancesArray<Instance>?

Returns:

#launch_configurationLaunchConfiguration?

Returns:

#lifecycle_hook(name) ⇒ LifecycleHook

Parameters:

Returns:

See Also:

#lifecycle_hooks(options = {}) ⇒ Collection<LifecycleHook>

Returns a Collection of LifecycleHook resources. No API requests are made until you call an enumerable method on the collection. Client#describe_lifecycle_hooks will be called multiple times until every LifecycleHook has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.lifecycle_hooks({
  lifecycle_hook_names: ["AsciiStringMaxLen255"],
})

Enumerating LifecycleHook resources.

autoscalinggroup.lifecycle_hooks.each do |lifecyclehook|
  # yields each lifecyclehook
end

Enumerating LifecycleHook resources with a limit.

autoscalinggroup.lifecycle_hooks.limit(10).each do |lifecyclehook|
  # yields at most 10 lifecycle_hooks
end

Options Hash (options):

  • :lifecycle_hook_names (Array<String>)

    The names of one or more lifecycle hooks. If you omit this parameter, all lifecycle hooks are described.

Returns:

See Also:

#load_balancer(name) ⇒ LoadBalancer

Parameters:

Returns:

See Also:

#load_balancers(options = {}) ⇒ Collection<LoadBalancer>

Returns a Collection of LoadBalancer resources. No API requests are made until you call an enumerable method on the collection. Client#describe_load_balancers will be called multiple times until every LoadBalancer has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.load_balancers({
  next_token: "XmlString",
  max_records: 1,
})

Enumerating LoadBalancer resources.

autoscalinggroup.load_balancers.each do |loadbalancer|
  # yields each loadbalancer
end

Enumerating LoadBalancer resources with a limit.

autoscalinggroup.load_balancers.limit(10).each do |loadbalancer|
  # yields at most 10 load_balancers
end

Batch operations callable on the returned collection


# calls Client#attach_load_balancers on each batch
autoscalinggroup.load_balancers.batch_attach

# calls Client#detach_load_balancers on each batch
autoscalinggroup.load_balancers.batch_detach

Options Hash (options):

  • :next_token (String)

    The token for the next set of items to return. (You received this token from a previous call.)

  • :max_records (Integer)

    The maximum number of items to return with this call. The default value is 100 and the maximum value is 100.

Returns:

See Also:

#notification_configurations(options = {}) ⇒ Collection<NotificationConfiguration>

Returns a Collection of NotificationConfiguration resources. No API requests are made until you call an enumerable method on the collection. Client#describe_notification_configurations will be called multiple times until every NotificationConfiguration has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.notification_configurations({
  next_token: "XmlString",
  max_records: 1,
})

Enumerating NotificationConfiguration resources.

autoscalinggroup.notification_configurations.each do |notificationconfiguration|
  # yields each notificationconfiguration
end

Enumerating NotificationConfiguration resources with a limit.

autoscalinggroup.notification_configurations.limit(10).each do |notificationconfiguration|
  # yields at most 10 notification_configurations
end

Batch operations callable on the returned collection


# calls Client#put_notification_configuration on each batch
autoscalinggroup.notification_configurations.batch_put

Options Hash (options):

  • :next_token (String)

    The token for the next set of items to return. (You received this token from a previous call.)

  • :max_records (Integer)

    The maximum number of items to return with this call. The default value is 50 and the maximum value is 100.

Returns:

See Also:

#policies(options = {}) ⇒ Collection<ScalingPolicy>

Returns a Collection of ScalingPolicy resources. No API requests are made until you call an enumerable method on the collection. Client#describe_policies will be called multiple times until every ScalingPolicy has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.policies({
  policy_names: ["ResourceName"],
  policy_types: ["XmlStringMaxLen64"],
  next_token: "XmlString",
  max_records: 1,
})

Enumerating ScalingPolicy resources.

autoscalinggroup.policies.each do |scalingpolicy|
  # yields each scalingpolicy
end

Enumerating ScalingPolicy resources with a limit.

autoscalinggroup.policies.limit(10).each do |scalingpolicy|
  # yields at most 10 policies
end

Options Hash (options):

  • :policy_names (Array<String>)

    The names of one or more policies. If you omit this parameter, all policies are described. If a group name is provided, the results are limited to that group. This list is limited to 50 items. If you specify an unknown policy name, it is ignored with no error.

  • :policy_types (Array<String>)

    One or more policy types. The valid values are SimpleScaling, StepScaling, and TargetTrackingScaling.

  • :next_token (String)

    The token for the next set of items to return. (You received this token from a previous call.)

  • :max_records (Integer)

    The maximum number of items to be returned with each call. The default value is 50 and the maximum value is 100.

Returns:

See Also:

#put_scaling_policy(options = {}) ⇒ ScalingPolicy

Examples:

Request syntax example with placeholder values


autoscalinggroup.put_scaling_policy({
  policy_name: "XmlStringMaxLen255", # required
  policy_type: "XmlStringMaxLen64",
  adjustment_type: "XmlStringMaxLen255",
  min_adjustment_step: 1,
  min_adjustment_magnitude: 1,
  scaling_adjustment: 1,
  cooldown: 1,
  metric_aggregation_type: "XmlStringMaxLen32",
  step_adjustments: [
    {
      metric_interval_lower_bound: 1.0,
      metric_interval_upper_bound: 1.0,
      scaling_adjustment: 1, # required
    },
  ],
  estimated_instance_warmup: 1,
  target_tracking_configuration: {
    predefined_metric_specification: {
      predefined_metric_type: "ASGAverageCPUUtilization", # required, accepts ASGAverageCPUUtilization, ASGAverageNetworkIn, ASGAverageNetworkOut, ALBRequestCountPerTarget
      resource_label: "XmlStringMaxLen1023",
    },
    customized_metric_specification: {
      metric_name: "MetricName", # required
      namespace: "MetricNamespace", # required
      dimensions: [
        {
          name: "MetricDimensionName", # required
          value: "MetricDimensionValue", # required
        },
      ],
      statistic: "Average", # required, accepts Average, Minimum, Maximum, SampleCount, Sum
      unit: "MetricUnit",
    },
    target_value: 1.0, # required
    disable_scale_in: false,
  },
  enabled: false,
})

Basic usage

scalingpolicy = autoscalinggroup.put_scaling_policy(options)
scalingpolicy.name
#=> "scalingpolicy-name"

Options Hash (options):

  • :policy_name (required, String)

    The name of the policy.

  • :policy_type (String)

    One of the following policy types:

    • TargetTrackingScaling

    • StepScaling

    • SimpleScaling (default)

  • :adjustment_type (String)

    Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

    Required if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide.

  • :min_adjustment_step (Integer)

    Available for backward compatibility. Use MinAdjustmentMagnitude instead.

  • :min_adjustment_magnitude (Integer)

    The minimum value to scale by when the adjustment type is PercentChangeInCapacity. For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.

    Valid only if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide.

    Some Auto Scaling groups use instance weights. In this case, set the MinAdjustmentMagnitude to a value that is at least as large as your largest instance weight.

  • :scaling_adjustment (Integer)

    The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a positive value.

    Required if the policy type is SimpleScaling. (Not used with any other policy type.)

  • :cooldown (Integer)

    The duration of the policy\'s cooldown period, in seconds. When a cooldown period is specified here, it overrides the default cooldown period defined for the Auto Scaling group.

    Valid only if the policy type is SimpleScaling. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

  • :metric_aggregation_type (String)

    The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average.

    Valid only if the policy type is StepScaling.

  • :step_adjustments (Array<Types::StepAdjustment>)

    A set of adjustments that enable you to scale based on the size of the alarm breach.

    Required if the policy type is StepScaling. (Not used with any other policy type.)

  • :estimated_instance_warmup (Integer)

    The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. If not provided, the default is to use the value from the default cooldown period for the Auto Scaling group.

    Valid only if the policy type is TargetTrackingScaling or StepScaling.

  • :target_tracking_configuration (Types::TargetTrackingConfiguration)

    A target tracking scaling policy. Includes support for predefined or customized metrics.

    The following predefined metrics are available:

    • ASGAverageCPUUtilization

    • ASGAverageNetworkIn

    • ASGAverageNetworkOut

    • ALBRequestCountPerTarget

    If you specify ALBRequestCountPerTarget for the metric, you must specify the ResourceLabel parameter with the PredefinedMetricSpecification.

    For more information, see TargetTrackingConfiguration in the Amazon EC2 Auto Scaling API Reference.

    Required if the policy type is TargetTrackingScaling.

  • :enabled (Boolean)

    Indicates whether the scaling policy is enabled or disabled. The default is enabled. For more information, see Disabling a scaling policy for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

Returns:

See Also:

#put_scheduled_update_group_action(options = {}) ⇒ ScheduledAction

Examples:

Request syntax example with placeholder values


autoscalinggroup.put_scheduled_update_group_action({
  scheduled_action_name: "XmlStringMaxLen255", # required
  time: Time.now,
  start_time: Time.now,
  end_time: Time.now,
  recurrence: "XmlStringMaxLen255",
  min_size: 1,
  max_size: 1,
  desired_capacity: 1,
})

Basic usage

scheduledaction = autoscalinggroup.put_scheduled_update_group_action(options)
scheduledaction.name
#=> "scheduledaction-name"

Options Hash (options):

  • :scheduled_action_name (required, String)

    The name of this scaling action.

  • :time (Time)

    This parameter is no longer used.

  • :start_time (Time)

    The date and time for this action to start, in YYYY-MM-DDThh:mm:ssZ format in UTC/GMT only and in quotes (for example, "2019-06-01T00:00:00Z").

    If you specify Recurrence and StartTime, Amazon EC2 Auto Scaling performs the action at this time, and then performs the action based on the specified recurrence.

    If you try to schedule your action in the past, Amazon EC2 Auto Scaling returns an error message.

  • :end_time (Time)

    The date and time for the recurring schedule to end. Amazon EC2 Auto Scaling does not perform the action after this time.

  • :recurrence (String)

    The recurring schedule for this action, in Unix cron syntax format. This format consists of five fields separated by white spaces: [Minute] [Hour] [Day_of_Month] [Month_of_Year] [Day_of_Week]. The value must be in quotes (for example, "30 0 1 1,6,12 *"). For more information about this format, see Crontab.

    When StartTime and EndTime are specified with Recurrence, they form the boundaries of when the recurring action starts and stops.

  • :min_size (Integer)

    The minimum size of the Auto Scaling group.

  • :max_size (Integer)

    The maximum size of the Auto Scaling group.

  • :desired_capacity (Integer)

    The desired capacity is the initial capacity of the Auto Scaling group after the scheduled action runs and the capacity it attempts to maintain. It can scale beyond this capacity if you add more scaling conditions.

Returns:

See Also:

#resume_processes(options = {}) ⇒ Struct

Resumes the specified suspended auto scaling processes, or all suspended process, for the specified Auto Scaling group.

For more information, see Suspending and resuming scaling processes in the Amazon EC2 Auto Scaling User Guide.

Examples:

Request syntax example with placeholder values


autoscalinggroup.resume_processes({
  scaling_processes: ["XmlStringMaxLen255"],
})

Options Hash (options):

  • :scaling_processes (Array<String>)

    One or more of the following processes:

    • Launch

    • Terminate

    • AddToLoadBalancer

    • AlarmNotification

    • AZRebalance

    • HealthCheck

    • InstanceRefresh

    • ReplaceUnhealthy

    • ScheduledActions

    If you omit this parameter, all processes are specified.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#scheduled_actions(options = {}) ⇒ Collection<ScheduledAction>

Returns a Collection of ScheduledAction resources. No API requests are made until you call an enumerable method on the collection. Client#describe_scheduled_actions will be called multiple times until every ScheduledAction has been yielded.

Examples:

Request syntax example with placeholder values


autoscalinggroup.scheduled_actions({
  scheduled_action_names: ["ResourceName"],
  start_time: Time.now,
  end_time: Time.now,
  next_token: "XmlString",
  max_records: 1,
})

Enumerating ScheduledAction resources.

autoscalinggroup.scheduled_actions.each do |scheduledaction|
  # yields each scheduledaction
end

Enumerating ScheduledAction resources with a limit.

autoscalinggroup.scheduled_actions.limit(10).each do |scheduledaction|
  # yields at most 10 scheduled_actions
end

Options Hash (options):

  • :scheduled_action_names (Array<String>)

    The names of one or more scheduled actions. You can specify up to 50 actions. If you omit this parameter, all scheduled actions are described. If you specify an unknown scheduled action, it is ignored with no error.

  • :start_time (Time)

    The earliest scheduled start time to return. If scheduled action names are provided, this parameter is ignored.

  • :end_time (Time)

    The latest scheduled start time to return. If scheduled action names are provided, this parameter is ignored.

  • :next_token (String)

    The token for the next set of items to return. (You received this token from a previous call.)

  • :max_records (Integer)

    The maximum number of items to return with this call. The default value is 50 and the maximum value is 100.

Returns:

See Also:

#set_desired_capacity(options = {}) ⇒ Struct

Sets the size of the specified Auto Scaling group.

If a scale-in activity occurs as a result of a new DesiredCapacity value that is lower than the current size of the group, the Auto Scaling group uses its termination policy to determine which instances to terminate.

For more information, see Manual scaling in the Amazon EC2 Auto Scaling User Guide.

Examples:

Request syntax example with placeholder values


autoscalinggroup.set_desired_capacity({
  desired_capacity: 1, # required
  honor_cooldown: false,
})

Options Hash (options):

  • :desired_capacity (required, Integer)

    The desired capacity is the initial capacity of the Auto Scaling group after this operation completes and the capacity it attempts to maintain.

  • :honor_cooldown (Boolean)

    Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period to complete before initiating a scaling activity to set your Auto Scaling group to its new capacity. By default, Amazon EC2 Auto Scaling does not honor the cooldown period during manual scaling activities.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#suspend_processes(options = {}) ⇒ Struct

Suspends the specified auto scaling processes, or all processes, for the specified Auto Scaling group.

If you suspend either the Launch or Terminate process types, it can prevent other process types from functioning properly. For more information, see Suspending and resuming scaling processes in the Amazon EC2 Auto Scaling User Guide.

To resume processes that have been suspended, call the ResumeProcesses API.

Examples:

Request syntax example with placeholder values


autoscalinggroup.suspend_processes({
  scaling_processes: ["XmlStringMaxLen255"],
})

Options Hash (options):

  • :scaling_processes (Array<String>)

    One or more of the following processes:

    • Launch

    • Terminate

    • AddToLoadBalancer

    • AlarmNotification

    • AZRebalance

    • HealthCheck

    • InstanceRefresh

    • ReplaceUnhealthy

    • ScheduledActions

    If you omit this parameter, all processes are specified.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#tag(key) ⇒ Tag

Parameters:

  • key (String)

    The Tag#key identifier.

Returns:

See Also:

#tagsArray<Tag>?

Returns:

  • (Array<Tag>, nil)

See Also:

#update(options = {}) ⇒ AutoScalingGroup

Examples:

Request syntax example with placeholder values


autoscalinggroup.update({
  launch_configuration_name: "ResourceName",
  launch_template: {
    launch_template_id: "XmlStringMaxLen255",
    launch_template_name: "LaunchTemplateName",
    version: "XmlStringMaxLen255",
  },
  mixed_instances_policy: {
    launch_template: {
      launch_template_specification: {
        launch_template_id: "XmlStringMaxLen255",
        launch_template_name: "LaunchTemplateName",
        version: "XmlStringMaxLen255",
      },
      overrides: [
        {
          instance_type: "XmlStringMaxLen255",
          weighted_capacity: "XmlStringMaxLen32",
          launch_template_specification: {
            launch_template_id: "XmlStringMaxLen255",
            launch_template_name: "LaunchTemplateName",
            version: "XmlStringMaxLen255",
          },
        },
      ],
    },
    instances_distribution: {
      on_demand_allocation_strategy: "XmlString",
      on_demand_base_capacity: 1,
      on_demand_percentage_above_base_capacity: 1,
      spot_allocation_strategy: "XmlString",
      spot_instance_pools: 1,
      spot_max_price: "MixedInstanceSpotPrice",
    },
  },
  min_size: 1,
  max_size: 1,
  desired_capacity: 1,
  default_cooldown: 1,
  availability_zones: ["XmlStringMaxLen255"],
  health_check_type: "XmlStringMaxLen32",
  health_check_grace_period: 1,
  placement_group: "XmlStringMaxLen255",
  vpc_zone_identifier: "XmlStringMaxLen2047",
  termination_policies: ["XmlStringMaxLen1600"],
  new_instances_protected_from_scale_in: false,
  service_linked_role_arn: "ResourceName",
  max_instance_lifetime: 1,
  capacity_rebalance: false,
})

Basic usage

autoscalinggroup = autoscalinggroup.update(options)
autoscalinggroup.name
#=> "autoscalinggroup-name"

Options Hash (options):

  • :launch_configuration_name (String)

    The name of the launch configuration. If you specify LaunchConfigurationName in your update request, you can\'t specify LaunchTemplate or MixedInstancesPolicy.

  • :launch_template (Types::LaunchTemplateSpecification)

    The launch template and version to use to specify the updates. If you specify LaunchTemplate in your update request, you can\'t specify LaunchConfigurationName or MixedInstancesPolicy.

  • :mixed_instances_policy (Types::MixedInstancesPolicy)

    An embedded object that specifies a mixed instances policy. When you make changes to an existing policy, all optional parameters are left unchanged if not specified. For more information, see Auto Scaling groups with multiple instance types and purchase options in the Amazon EC2 Auto Scaling User Guide.

  • :min_size (Integer)

    The minimum size of the Auto Scaling group.

  • :max_size (Integer)

    The maximum size of the Auto Scaling group.

    With a mixed instances policy that uses instance weighting, Amazon EC2 Auto Scaling may need to go above MaxSize to meet your capacity requirements. In this event, Amazon EC2 Auto Scaling will never go above MaxSize by more than your largest instance weight (weights that define how many units each instance contributes to the desired capacity of the group).

  • :desired_capacity (Integer)

    The desired capacity is the initial capacity of the Auto Scaling group after this operation completes and the capacity it attempts to maintain. This number must be greater than or equal to the minimum size of the group and less than or equal to the maximum size of the group.

  • :default_cooldown (Integer)

    The amount of time, in seconds, after a scaling activity completes before another scaling activity can start. The default value is 300. This setting applies when using simple scaling policies, but not when using other scaling policies or scheduled scaling. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

  • :availability_zones (Array<String>)

    One or more Availability Zones for the group.

  • :health_check_type (String)

    The service to use for the health checks. The valid values are EC2 and ELB. If you configure an Auto Scaling group to use ELB health checks, it considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.

  • :health_check_grace_period (Integer)

    The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service. The default value is 0. For more information, see Health check grace period in the Amazon EC2 Auto Scaling User Guide.

    Conditional: Required if you are adding an ELB health check.

  • :placement_group (String)

    The name of an existing placement group into which to launch your instances, if any. A placement group is a logical grouping of instances within a single Availability Zone. You cannot specify multiple Availability Zones and a placement group. For more information, see Placement Groups in the Amazon EC2 User Guide for Linux Instances.

  • :vpc_zone_identifier (String)

    A comma-separated list of subnet IDs for a virtual private cloud (VPC). If you specify VPCZoneIdentifier with AvailabilityZones, the subnets that you specify for this parameter must reside in those Availability Zones.

  • :termination_policies (Array<String>)

    A policy or a list of policies that are used to select the instances to terminate. The policies are executed in the order that you list them. For more information, see Controlling which Auto Scaling instances terminate during scale in in the Amazon EC2 Auto Scaling User Guide.

  • :new_instances_protected_from_scale_in (Boolean)

    Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in. For more information about preventing instances from terminating on scale in, see Instance scale-in protection in the Amazon EC2 Auto Scaling User Guide.

  • :service_linked_role_arn (String)

    The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other AWS services on your behalf. For more information, see Service-linked roles in the Amazon EC2 Auto Scaling User Guide.

  • :max_instance_lifetime (Integer)

    The maximum amount of time, in seconds, that an instance can be in service. The default is null. If specified, the value must be either 0 or a number equal to or greater than 86,400 seconds (1 day). To clear a previously set value, specify a new value of 0. For more information, see Replacing Auto Scaling instances based on maximum instance lifetime in the Amazon EC2 Auto Scaling User Guide.

  • :capacity_rebalance (Boolean)

    Enables or disables Capacity Rebalancing. For more information, see Amazon EC2 Auto Scaling Capacity Rebalancing in the Amazon EC2 Auto Scaling User Guide.

Returns:

See Also:

#wait_until_exists {|waiter| ... } ⇒ AutoScalingGroup

Waits until this AutoScalingGroup is exists. This method waits by polling Client#describe_auto_scaling_groups until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 5
#max_attempts 10

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

autoscalinggroup.wait_until_exists

Yield Parameters:

Returns:

  • (AutoScalingGroup)

    Returns a copy of this AutoScalingGroup that is not loaded.

Raises:

See Also:

#wait_until_in_service {|waiter| ... } ⇒ AutoScalingGroup

Waits until this AutoScalingGroup is in_service. This method waits by polling Client#describe_auto_scaling_groups until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 15
#max_attempts 40

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

autoscalinggroup.wait_until_in_service

Yield Parameters:

Returns:

  • (AutoScalingGroup)

    Returns a copy of this AutoScalingGroup that is not loaded.

Raises:

See Also:

#wait_until_not_exists {|waiter| ... } ⇒ AutoScalingGroup

Waits until this AutoScalingGroup is not_exists. This method waits by polling Client#describe_auto_scaling_groups until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 15
#max_attempts 40

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

autoscalinggroup.wait_until_not_exists

Yield Parameters:

Returns:

  • (AutoScalingGroup)

    Returns a copy of this AutoScalingGroup that is not loaded.

Raises:

See Also: