Class: Aws::AutoScaling::ScalingPolicy

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
sig/scaling_policy.rbs,
lib/aws-sdk-autoscaling/scaling_policy.rb

Overview

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ScalingPolicy.

Overloads:

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

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ ScalingPolicy

    Options Hash (options):

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


13
14
15
# File 'sig/scaling_policy.rbs', line 13

def initialize: (String name, Hash[Symbol, untyped] options) -> void
| (name: String, ?client: Client) -> void
| (Hash[Symbol, untyped] args) -> void

Instance Method Details

#adjustment_typeString

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

Returns:

  • (String)


31
# File 'sig/scaling_policy.rbs', line 31

def adjustment_type: () -> ::String

#alarmsArray<Types::Alarm>

The CloudWatch alarms related to the policy.

Returns:



55
# File 'sig/scaling_policy.rbs', line 55

def alarms: () -> ::Array[Types::Alarm]

#auto_scaling_group_nameString

The name of the Auto Scaling group.

Returns:

  • (String)


22
# File 'sig/scaling_policy.rbs', line 22

def auto_scaling_group_name: () -> ::String

#clientClient

Returns:



158
# File 'lib/aws-sdk-autoscaling/scaling_policy.rb', line 158

def client: () -> Client

#cooldownInteger

The duration of the policy's cooldown period, in seconds.

Returns:

  • (Integer)


43
# File 'sig/scaling_policy.rbs', line 43

def cooldown: () -> ::Integer

#dataTypes::ScalingPolicy

Returns the data for this Aws::AutoScaling::ScalingPolicy. Calls Client#describe_policies if #data_loaded? is false.

Returns:



73
# File 'sig/scaling_policy.rbs', line 73

def data: () -> Types::ScalingPolicy

#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.



76
# File 'sig/scaling_policy.rbs', line 76

def data_loaded?: () -> bool

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


scaling_policy.delete({
  auto_scaling_group_name: "XmlStringMaxLen255",
})

Parameters:

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

    ({})

Options Hash (options):

  • :auto_scaling_group_name (String)

    The name of the Auto Scaling group.

Returns:

  • (EmptyStructure)


80
# File 'sig/scaling_policy.rbs', line 80

def delete: (

#enabledBoolean

Indicates whether the policy is enabled (true) or disabled (false).

Returns:

  • (Boolean)


61
# File 'sig/scaling_policy.rbs', line 61

def enabled: () -> bool

#estimated_instance_warmupInteger

The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.

Returns:

  • (Integer)


52
# File 'sig/scaling_policy.rbs', line 52

def estimated_instance_warmup: () -> ::Integer

#execute(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


scaling_policy.execute({
  auto_scaling_group_name: "XmlStringMaxLen255",
  honor_cooldown: false,
  metric_value: 1.0,
  breach_threshold: 1.0,
})

Parameters:

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

    ({})

Options Hash (options):

  • :auto_scaling_group_name (String)

    The name of the Auto Scaling group.

  • :honor_cooldown (Boolean)

    Indicates whether Amazon EC2 Auto Scaling waits for the cooldown period to complete before executing the policy.

    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_value (Float)

    The metric value to compare to BreachThreshold. This enables you to execute a policy of type StepScaling and determine which step adjustment to use. For example, if the breach threshold is 50 and you want to use a step adjustment with a lower bound of 0 and an upper bound of 10, you can set the metric value to 59.

    If you specify a metric value that doesn't correspond to a step adjustment for the policy, the call returns an error.

    Required if the policy type is StepScaling and not supported otherwise.

  • :breach_threshold (Float)

    The breach threshold for the alarm.

    Required if the policy type is StepScaling and not supported otherwise.

Returns:

  • (EmptyStructure)


86
# File 'sig/scaling_policy.rbs', line 86

def execute: (

#groupAutoScalingGroup?

Returns:



95
# File 'sig/scaling_policy.rbs', line 95

def group: () -> AutoScalingGroup?

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


374
375
376
# File 'lib/aws-sdk-autoscaling/scaling_policy.rb', line 374

def identifiers
  { name: @name }
end

#loadself Also known as: reload

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

scaling_policy.reload.data

Returns:

  • (self)


69
# File 'sig/scaling_policy.rbs', line 69

def load: () -> self

#metric_aggregation_typeString

The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average.

Returns:

  • (String)


49
# File 'sig/scaling_policy.rbs', line 49

def metric_aggregation_type: () -> ::String

#min_adjustment_magnitudeInteger

The minimum value to scale by when the adjustment type is PercentChangeInCapacity.

Returns:

  • (Integer)


37
# File 'sig/scaling_policy.rbs', line 37

def min_adjustment_magnitude: () -> ::Integer

#min_adjustment_stepInteger

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

Returns:

  • (Integer)


34
# File 'sig/scaling_policy.rbs', line 34

def min_adjustment_step: () -> ::Integer

#nameString Also known as: policy_name

Returns:

  • (String)


18
# File 'sig/scaling_policy.rbs', line 18

def name: () -> String

#policy_arnString

The Amazon Resource Name (ARN) of the policy.

Returns:

  • (String)


25
# File 'sig/scaling_policy.rbs', line 25

def policy_arn: () -> ::String

#policy_typeString

One of the following policy types:

  • TargetTrackingScaling

  • StepScaling

  • SimpleScaling (default)

  • PredictiveScaling

For more information, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (String)


28
# File 'sig/scaling_policy.rbs', line 28

def policy_type: () -> ::String

#predictive_scaling_configurationTypes::PredictiveScalingConfiguration

A predictive scaling policy.



64
# File 'sig/scaling_policy.rbs', line 64

def predictive_scaling_configuration: () -> Types::PredictiveScalingConfiguration

#scaling_adjustmentInteger

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.

Returns:

  • (Integer)


40
# File 'sig/scaling_policy.rbs', line 40

def scaling_adjustment: () -> ::Integer

#step_adjustmentsArray<Types::StepAdjustment>

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

Returns:



46
# File 'sig/scaling_policy.rbs', line 46

def step_adjustments: () -> ::Array[Types::StepAdjustment]

#target_tracking_configurationTypes::TargetTrackingConfiguration

A target tracking scaling policy.



58
# File 'sig/scaling_policy.rbs', line 58

def target_tracking_configuration: () -> Types::TargetTrackingConfiguration

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::AutoScaling::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged.

Waiter polls an API operation until a resource enters a desired state.

Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) do |instance|
  instance.state.name == 'running'
end

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/aws-sdk-autoscaling/scaling_policy.rb', line 272

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    Aws::Waiters::Waiter.new(options).wait({})
  end
end