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

Class: Aws::AutoScaling::AutoScalingGroup

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Associations collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AutoScalingGroup

Overloads:

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

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ AutoScalingGroup

    Options Hash (options):

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


19
20
21
22
23
24
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @name = extract_name(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#activities(options = {}) ⇒ Activity::Collection

Examples:

Request syntax with placeholder values


activities = auto_scaling_group.activities({
  activity_ids: ["XmlString"],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :activity_ids (Array<String>)

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

Returns:



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 774

def activities(options = {})
  batches = Enumerator.new do |y|
    options = options.merge(auto_scaling_group_name: @name)
    resp = @client.describe_scaling_activities(options)
    resp.each_page do |page|
      batch = []
      page.data.activities.each do |a|
        batch << Activity.new(
          id: a.activity_id,
          data: a,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  Activity::Collection.new(batches)
end

#attach_instances(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :instance_ids (Array<String>)

    One or more instance IDs.

Returns:

  • (EmptyStructure)


276
277
278
279
280
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 276

def attach_instances(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.attach_instances(options)
  resp.data
end

#auto_scaling_group_arnString

The Amazon Resource Name (ARN) of the group.

Returns:

  • (String)


36
37
38
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 36

def auto_scaling_group_arn
  data.auto_scaling_group_arn
end

#availability_zonesArray<String>

One or more Availability Zones for the group.

Returns:

  • (Array<String>)


73
74
75
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 73

def availability_zones
  data.availability_zones
end

#clientClient

Returns:



168
169
170
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 168

def client
  @client
end

#created_timeTime

The date and time the group was created.

Returns:

  • (Time)


107
108
109
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 107

def created_time
  data.created_time
end

#dataTypes::AutoScalingGroup



188
189
190
191
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 188

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



196
197
198
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 196

def data_loaded?
  !!@data
end

#default_cooldownInteger

The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.

Returns:

  • (Integer)


67
68
69
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 67

def default_cooldown
  data.default_cooldown
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


auto_scaling_group.delete({
  force_delete: false,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :force_delete (Boolean)

    Specifies that the group will 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:

  • (EmptyStructure)


294
295
296
297
298
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 294

def delete(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.delete_auto_scaling_group(options)
  resp.data
end

#desired_capacityInteger

The desired size of the group.

Returns:

  • (Integer)


60
61
62
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 60

def desired_capacity
  data.desired_capacity
end

#detach_instances(options = {}) ⇒ Activity::Collection

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :instance_ids (Array<String>)

    One or more instance IDs.

  • :should_decrement_desired_capacity (required, Boolean)

    If True, the Auto Scaling group decrements the desired capacity value by the number of instances detached.

Returns:



313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 313

def detach_instances(options = {})
  batch = []
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.detach_instances(options)
  resp.data.activities.each do |a|
    batch << Activity.new(
      id: a.activity_id,
      data: a,
      client: @client
    )
  end
  Activity::Collection.new([batch], size: batch.size)
end

#disable_metrics_collection(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :metrics (Array<String>)

    One or more of the following metrics. If you omit this parameter, all metrics are disabled.

    • GroupMinSize

    • GroupMaxSize

    • GroupDesiredCapacity

    • GroupInServiceInstances

    • GroupPendingInstances

    • GroupStandbyInstances

    • GroupTerminatingInstances

    • GroupTotalInstances

Returns:

  • (EmptyStructure)


353
354
355
356
357
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 353

def disable_metrics_collection(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.disable_metrics_collection(options)
  resp.data
end

#enable_metrics_collection(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :metrics (Array<String>)

    One or more of the following metrics. If you omit this parameter, all metrics are enabled.

    • GroupMinSize

    • GroupMaxSize

    • GroupDesiredCapacity

    • GroupInServiceInstances

    • GroupPendingInstances

    • GroupStandbyInstances

    • GroupTerminatingInstances

    • GroupTotalInstances

  • :granularity (required, String)

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

Returns:

  • (EmptyStructure)


389
390
391
392
393
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 389

def enable_metrics_collection(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.enable_metrics_collection(options)
  resp.data
end

#enabled_metricsArray<Types::EnabledMetric>

The metrics enabled for the group.

Returns:



141
142
143
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 141

def enabled_metrics
  data.enabled_metrics
end

#exists?(options = {}) ⇒ Boolean

Returns true if the AutoScalingGroup exists.

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (Boolean)

    Returns true if the AutoScalingGroup exists.



203
204
205
206
207
208
209
210
211
212
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 203

def exists?(options = {})
  begin
    wait_until_exists(options.merge(max_attempts: 1))
    true
  rescue Aws::Waiters::Errors::UnexpectedError => e
    raise e.error
  rescue Aws::Waiters::Errors::WaiterFailed
    false
  end
end

#health_check_grace_periodInteger

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

Returns:

  • (Integer)


101
102
103
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 101

def health_check_grace_period
  data.health_check_grace_period
end

#health_check_typeString

The service to use for the health checks. The valid values are EC2 and ELB.

Returns:

  • (String)


93
94
95
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 93

def health_check_type
  data.health_check_type
end

#instancesInstance::Collection



794
795
796
797
798
799
800
801
802
803
804
805
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 794

def instances
  batch = []
  data.instances.each do |i|
    batch << Instance.new(
      group_name: @name,
      id: i.instance_id,
      data: i,
      client: @client
    )
  end
  Instance::Collection.new([batch], size: batch.size)
end

#launch_configurationLaunchConfiguration?

Returns:



808
809
810
811
812
813
814
815
816
817
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 808

def launch_configuration
  if data.launch_configuration_name
    LaunchConfiguration.new(
      name: data.launch_configuration_name,
      client: @client
    )
  else
    nil
  end
end

#launch_configuration_nameString

The name of the associated launch configuration.

Returns:

  • (String)


42
43
44
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 42

def launch_configuration_name
  data.launch_configuration_name
end

#lifecycle_hook(name) ⇒ LifecycleHook

Parameters:

  • name (String)

Returns:



821
822
823
824
825
826
827
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 821

def lifecycle_hook(name)
  LifecycleHook.new(
    group_name: @name,
    name: name,
    client: @client
  )
end

#lifecycle_hooks(options = {}) ⇒ LifecycleHook::Collection

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

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:



839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 839

def lifecycle_hooks(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = options.merge(auto_scaling_group_name: @name)
    resp = @client.describe_lifecycle_hooks(options)
    resp.data.lifecycle_hooks.each do |l|
      batch << LifecycleHook.new(
        group_name: l.auto_scaling_group_name,
        name: l.lifecycle_hook_name,
        data: l,
        client: @client
      )
    end
    y.yield(batch)
  end
  LifecycleHook::Collection.new(batches)
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::AutoScaling::AutoScalingGroup. Returns self making it possible to chain methods.

auto_scaling_group.reload.data

Returns:

  • (self)


178
179
180
181
182
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 178

def load
  resp = @client.describe_auto_scaling_groups(auto_scaling_group_names: [@name])
  @data = resp.auto_scaling_groups[0]
  self
end

#load_balancer(name) ⇒ LoadBalancer

Parameters:

  • name (String)

Returns:



859
860
861
862
863
864
865
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 859

def load_balancer(name)
  LoadBalancer.new(
    group_name: @name,
    name: name,
    client: @client
  )
end

#load_balancer_namesArray<String>

One or more load balancers associated with the group.

Returns:

  • (Array<String>)


79
80
81
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 79

def load_balancer_names
  data.load_balancer_names
end

#load_balancers(options = {}) ⇒ LoadBalancer::Collection

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

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:



881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 881

def load_balancers(options = {})
  batches = Enumerator.new do |y|
    batch = []
    options = options.merge(auto_scaling_group_name: @name)
    resp = @client.describe_load_balancers(options)
    resp.data.load_balancers.each do |l|
      batch << LoadBalancer.new(
        group_name: @name,
        name: l.load_balancer_name,
        data: l,
        client: @client
      )
    end
    y.yield(batch)
  end
  LoadBalancer::Collection.new(batches)
end

#max_sizeInteger

The maximum size of the group.

Returns:

  • (Integer)


54
55
56
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 54

def max_size
  data.max_size
end

#min_sizeInteger

The minimum size of the group.

Returns:

  • (Integer)


48
49
50
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 48

def min_size
  data.min_size
end

#nameString Also known as: auto_scaling_group_name

Returns:

  • (String)


29
30
31
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 29

def name
  @name
end

#new_instances_protected_from_scale_inBoolean

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

Returns:

  • (Boolean)


161
162
163
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 161

def new_instances_protected_from_scale_in
  data.new_instances_protected_from_scale_in
end

#notification_configurations(options = {}) ⇒ NotificationConfiguration::Collection

Examples:

Request syntax with placeholder values


auto_scaling_group.notification_configurations()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:



904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 904

def notification_configurations(options = {})
  batches = Enumerator.new do |y|
    options = Aws::Util.deep_merge(options, auto_scaling_group_names: [@name])
    resp = @client.describe_notification_configurations(options)
    resp.each_page do |page|
      batch = []
      page.data.notification_configurations.each do |n|
        batch << NotificationConfiguration.new(
          group_name: n.auto_scaling_group_name,
          type: n.notification_type,
          topic_arn: n.topic_arn,
          data: n,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  NotificationConfiguration::Collection.new(batches)
end

#placement_groupString

The name of the placement group into which you'll launch your instances, if any. For more information, see Placement Groups in the Amazon Elastic Compute Cloud User Guide.

Returns:

  • (String)


125
126
127
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 125

def placement_group
  data.placement_group
end

#policies(options = {}) ⇒ ScalingPolicy::Collection

Examples:

Request syntax with placeholder values


policies = auto_scaling_group.policies({
  policy_names: ["ResourceName"],
  policy_types: ["XmlStringMaxLen64"],
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :policy_names (Array<String>)

    One or more policy names or policy ARNs to be described. If you omit this parameter, all policy names are described. If an 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. Valid values are SimpleScaling and StepScaling.

Returns:



942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 942

def policies(options = {})
  batches = Enumerator.new do |y|
    options = options.merge(auto_scaling_group_name: @name)
    resp = @client.describe_policies(options)
    resp.each_page do |page|
      batch = []
      page.data.scaling_policies.each do |s|
        batch << ScalingPolicy.new(
          name: s.policy_name,
          data: s,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  ScalingPolicy::Collection.new(batches)
end

#put_scaling_policy(options = {}) ⇒ ScalingPolicy

Examples:

Request syntax with placeholder values


scalingpolicy = auto_scaling_group.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,
  },
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :policy_name (required, String)

    The name of the policy.

  • :policy_type (String)

    The policy type. The valid values are SimpleScaling, StepScaling, and TargetTrackingScaling. If the policy type is null, the value is treated as SimpleScaling.

  • :adjustment_type (String)

    The adjustment type. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

    This parameter is supported if the policy type is SimpleScaling or StepScaling.

    For more information, see Dynamic Scaling in the Auto Scaling User Guide.

  • :min_adjustment_step (Integer)

    Available for backward compatibility. Use MinAdjustmentMagnitude instead.

  • :min_adjustment_magnitude (Integer)

    The minimum number of instances to scale. If the value of AdjustmentType is PercentChangeInCapacity, the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least this many instances. Otherwise, the error is ValidationError.

    This parameter is supported if the policy type is SimpleScaling or StepScaling.

  • :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.

    This parameter is required if the policy type is SimpleScaling and not supported otherwise.

  • :cooldown (Integer)

    The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. If this parameter is not specified, the default cooldown period for the group applies.

    This parameter is supported if the policy type is SimpleScaling.

    For more information, see Auto Scaling Cooldowns in the 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.

    This parameter is supported 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.

    This parameter is required if the policy type is StepScaling and not supported otherwise.

  • :estimated_instance_warmup (Integer)

    The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. The default is to use the value specified for the default cooldown period for the group.

    This parameter is supported if the policy type is StepScaling or TargetTrackingScaling.

  • :target_tracking_configuration (Types::TargetTrackingConfiguration)

    The configuration of a target tracking policy.

    This parameter is required if the policy type is TargetTrackingScaling and not supported otherwise.

Returns:



511
512
513
514
515
516
517
518
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 511

def put_scaling_policy(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.put_scaling_policy(options)
  ScalingPolicy.new(
    name: options[:policy_name],
    client: @client
  )
end

#put_scheduled_update_group_action(options = {}) ⇒ ScheduledAction

Examples:

Request syntax with placeholder values


scheduledaction = auto_scaling_group.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,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :scheduled_action_name (required, String)

    The name of this scaling action.

  • :time (Time, DateTime, Date, Integer, String)

    This parameter is deprecated.

  • :start_time (Time, DateTime, Date, Integer, String)

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

    If you specify Recurrence and StartTime, 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, Auto Scaling returns an error message.

  • :end_time (Time, DateTime, Date, Integer, String)

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

  • :recurrence (String)

    The recurring schedule for this action, in Unix cron syntax format. For more information, see Cron in Wikipedia.

  • :min_size (Integer)

    The minimum size for the Auto Scaling group.

  • :max_size (Integer)

    The maximum size for the Auto Scaling group.

  • :desired_capacity (Integer)

    The number of EC2 instances that should be running in the group.

Returns:



564
565
566
567
568
569
570
571
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 564

def put_scheduled_update_group_action(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.put_scheduled_update_group_action(options)
  ScheduledAction.new(
    name: options[:scheduled_action_name],
    client: @client
  )
end

#resume_processes(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :scaling_processes (Array<String>)

    One or more of the following processes. If you omit this parameter, all processes are specified.

    • Launch

    • Terminate

    • HealthCheck

    • ReplaceUnhealthy

    • AZRebalance

    • AlarmNotification

    • ScheduledActions

    • AddToLoadBalancer

Returns:

  • (EmptyStructure)


599
600
601
602
603
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 599

def resume_processes(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.resume_processes(options)
  resp.data
end

#scheduled_actions(options = {}) ⇒ ScheduledAction::Collection

Examples:

Request syntax with placeholder values


scheduled_actions = auto_scaling_group.scheduled_actions({
  scheduled_action_names: ["ResourceName"],
  start_time: Time.now,
  end_time: Time.now,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :scheduled_action_names (Array<String>)

    Describes one or more scheduled actions. If you omit this parameter, all scheduled actions are described. If you specify an unknown scheduled action, it is ignored with no error.

    You can describe up to a maximum of 50 instances with a single call. If there are more items to return, the call returns a token. To get the next set of items, repeat the call with the returned token.

  • :start_time (Time, DateTime, Date, Integer, String)

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

  • :end_time (Time, DateTime, Date, Integer, String)

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

Returns:



984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 984

def scheduled_actions(options = {})
  batches = Enumerator.new do |y|
    options = options.merge(auto_scaling_group_name: @name)
    resp = @client.describe_scheduled_actions(options)
    resp.each_page do |page|
      batch = []
      page.data.scheduled_update_group_actions.each do |s|
        batch << ScheduledAction.new(
          name: s.scheduled_action_name,
          data: s,
          client: @client
        )
      end
      y.yield(batch)
    end
  end
  ScheduledAction::Collection.new(batches)
end

#set_desired_capacity(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :desired_capacity (required, Integer)

    The number of EC2 instances that should be running in the Auto Scaling group.

  • :honor_cooldown (Boolean)

    By default, SetDesiredCapacity overrides any cooldown period associated with the Auto Scaling group. Specify True to make Auto Scaling to wait for the cool-down period associated with the Auto Scaling group to complete before initiating a scaling activity to set your Auto Scaling group to its new capacity.

Returns:

  • (EmptyStructure)


622
623
624
625
626
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 622

def set_desired_capacity(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.set_desired_capacity(options)
  resp.data
end

#statusString

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

Returns:

  • (String)


148
149
150
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 148

def status
  data.status
end

#suspend_processes(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :scaling_processes (Array<String>)

    One or more of the following processes. If you omit this parameter, all processes are specified.

    • Launch

    • Terminate

    • HealthCheck

    • ReplaceUnhealthy

    • AZRebalance

    • AlarmNotification

    • ScheduledActions

    • AddToLoadBalancer

Returns:

  • (EmptyStructure)


654
655
656
657
658
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 654

def suspend_processes(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.suspend_processes(options)
  resp.data
end

#suspended_processesArray<Types::SuspendedProcess>

The suspended processes associated with the group.

Returns:



113
114
115
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 113

def suspended_processes
  data.suspended_processes
end

#tag(key) ⇒ Tag

Parameters:

  • key (String)

Returns:



1005
1006
1007
1008
1009
1010
1011
1012
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 1005

def tag(key)
  Tag.new(
    key: key,
    resource_id: @name,
    resource_type: "auto-scaling-group",
    client: @client
  )
end

#tagsTag::Collection

Returns:



1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 1015

def tags
  batch = []
  data.tags.each do |t|
    batch << Tag.new(
      key: t.key,
      resource_id: t.resource_id,
      resource_type: t.resource_type,
      data: t,
      client: @client
    )
  end
  Tag::Collection.new([batch], size: batch.size)
end

#target_group_arnsArray<String>

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

Returns:

  • (Array<String>)


86
87
88
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 86

def target_group_arns
  data.target_group_arns
end

#termination_policiesArray<String>

The termination policies for the group.

Returns:

  • (Array<String>)


154
155
156
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 154

def termination_policies
  data.termination_policies
end

#update(options = {}) ⇒ AutoScalingGroup

Examples:

Request syntax with placeholder values


autoscalinggroup = auto_scaling_group.update({
  launch_configuration_name: "ResourceName",
  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,
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :launch_configuration_name (String)

    The name of the launch configuration.

  • :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 number of EC2 instances that should be running in the Auto Scaling group. 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 is 300.

    For more information, see Auto Scaling Cooldowns in the 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.

  • :health_check_grace_period (Integer)

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

    For more information, see Health Checks in the Auto Scaling User Guide.

  • :placement_group (String)

    The name of the placement group into which you'll launch your instances, if any. For more information, see Placement Groups in the Amazon Elastic Compute Cloud User Guide.

  • :vpc_zone_identifier (String)

    The ID of the subnet, if you are launching into a VPC. You can specify several subnets in a comma-separated list.

    When you specify VPCZoneIdentifier with AvailabilityZones, ensure that the subnets' Availability Zones match the values you specify for AvailabilityZones.

    For more information, see Launching Auto Scaling Instances in a VPC in the Auto Scaling User Guide.

  • :termination_policies (Array<String>)

    A standalone termination policy or a list of termination policies used to select the instance to terminate. The policies are executed in the order that they are listed.

    For more information, see Controlling Which Instances Auto Scaling Terminates During Scale In in the Auto Scaling User Guide.

  • :new_instances_protected_from_scale_in (Boolean)

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

Returns:



750
751
752
753
754
755
756
757
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 750

def update(options = {})
  options = options.merge(auto_scaling_group_name: @name)
  resp = @client.update_auto_scaling_group(options)
  AutoScalingGroup.new(
    name: options[:auto_scaling_group_name],
    client: @client
  )
end

#vpc_zone_identifierString

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

If you specify VPCZoneIdentifier and AvailabilityZones, ensure that the Availability Zones of the subnets match the values for AvailabilityZones.

Returns:

  • (String)


135
136
137
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 135

def vpc_zone_identifier
  data.vpc_zone_identifier
end

#wait_until_exists(options = {}) ⇒ AutoScalingGroup

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 10
  • :delay (Float) — default: 5
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



220
221
222
223
224
225
226
227
228
229
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 220

def wait_until_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::GroupExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(auto_scaling_group_names: [@name]))
  AutoScalingGroup.new({
    name: @name,
    client: @client
  })
end

#wait_until_in_service(options = {}) ⇒ AutoScalingGroup

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 15
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



237
238
239
240
241
242
243
244
245
246
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 237

def wait_until_in_service(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::GroupInService.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(auto_scaling_group_names: [@name]))
  AutoScalingGroup.new({
    name: @name,
    client: @client
  })
end

#wait_until_not_exists(options = {}) ⇒ AutoScalingGroup

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 15
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



254
255
256
257
258
259
260
261
262
263
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/auto_scaling_group.rb', line 254

def wait_until_not_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::GroupNotExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(auto_scaling_group_names: [@name]))
  AutoScalingGroup.new({
    name: @name,
    client: @client
  })
end