Class: Aws::AutoScaling::ScalingPolicy
- Inherits:
-
Object
- Object
- Aws::AutoScaling::ScalingPolicy
- 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
-
#adjustment_type ⇒ String
Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage).
-
#alarms ⇒ Array<Types::Alarm>
The CloudWatch alarms related to the policy.
-
#auto_scaling_group_name ⇒ String
The name of the Auto Scaling group.
-
#cooldown ⇒ Integer
The duration of the policy's cooldown period, in seconds.
-
#enabled ⇒ Boolean
Indicates whether the policy is enabled (
true) or disabled (false). -
#estimated_instance_warmup ⇒ Integer
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.
-
#metric_aggregation_type ⇒ String
The aggregation type for the CloudWatch metrics.
-
#min_adjustment_magnitude ⇒ Integer
The minimum value to scale by when the adjustment type is
PercentChangeInCapacity. -
#min_adjustment_step ⇒ Integer
Available for backward compatibility.
- #name ⇒ String (also: #policy_name)
-
#policy_arn ⇒ String
The Amazon Resource Name (ARN) of the policy.
-
#policy_type ⇒ String
One of the following policy types:.
-
#predictive_scaling_configuration ⇒ Types::PredictiveScalingConfiguration
A predictive scaling policy.
-
#scaling_adjustment ⇒ Integer
The amount by which to scale, based on the specified adjustment type.
-
#step_adjustments ⇒ Array<Types::StepAdjustment>
A set of adjustments that enable you to scale based on the size of the alarm breach.
-
#target_tracking_configuration ⇒ Types::TargetTrackingConfiguration
A target tracking scaling policy.
Actions collapse
Associations collapse
- #group ⇒ AutoScalingGroup?
- #identifiers ⇒ Object deprecated private Deprecated.
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::ScalingPolicy
Returns the data for this ScalingPolicy.
-
#data_loaded? ⇒ Boolean
Returns
trueif this resource is loaded. -
#initialize(*args) ⇒ ScalingPolicy
constructor
A new instance of ScalingPolicy.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current ScalingPolicy.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::AutoScaling::Client] #wait_until instead
Constructor Details
#initialize(name, options = {}) ⇒ ScalingPolicy #initialize(options = {}) ⇒ ScalingPolicy
Returns a new instance of ScalingPolicy.
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_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.
31 |
# File 'sig/scaling_policy.rbs', line 31
def adjustment_type: () -> ::String
|
#alarms ⇒ Array<Types::Alarm>
The CloudWatch alarms related to the policy.
55 |
# File 'sig/scaling_policy.rbs', line 55
def alarms: () -> ::Array[Types::Alarm]
|
#auto_scaling_group_name ⇒ String
The name of the Auto Scaling group.
22 |
# File 'sig/scaling_policy.rbs', line 22
def auto_scaling_group_name: () -> ::String
|
#client ⇒ Client
158 |
# File 'lib/aws-sdk-autoscaling/scaling_policy.rb', line 158
def client: () -> Client
|
#cooldown ⇒ Integer
The duration of the policy's cooldown period, in seconds.
43 |
# File 'sig/scaling_policy.rbs', line 43
def cooldown: () -> ::Integer
|
#data ⇒ Types::ScalingPolicy
Returns the data for this Aws::AutoScaling::ScalingPolicy. Calls
Client#describe_policies if #data_loaded? is false.
73 |
# File 'sig/scaling_policy.rbs', line 73
def data: () -> Types::ScalingPolicy
|
#data_loaded? ⇒ Boolean
76 |
# File 'sig/scaling_policy.rbs', line 76
def data_loaded?: () -> bool
|
#delete(options = {}) ⇒ EmptyStructure
80 |
# File 'sig/scaling_policy.rbs', line 80
def delete: (
|
#enabled ⇒ Boolean
Indicates whether the policy is enabled (true) or disabled
(false).
61 |
# File 'sig/scaling_policy.rbs', line 61
def enabled: () -> bool
|
#estimated_instance_warmup ⇒ Integer
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.
52 |
# File 'sig/scaling_policy.rbs', line 52
def estimated_instance_warmup: () -> ::Integer
|
#execute(options = {}) ⇒ EmptyStructure
86 |
# File 'sig/scaling_policy.rbs', line 86
def execute: (
|
#group ⇒ AutoScalingGroup?
95 |
# File 'sig/scaling_policy.rbs', line 95
def group: () -> AutoScalingGroup?
|
#identifiers ⇒ Object
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.
374 375 376 |
# File 'lib/aws-sdk-autoscaling/scaling_policy.rb', line 374 def identifiers { name: @name } end |
#load ⇒ self 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
69 |
# File 'sig/scaling_policy.rbs', line 69
def load: () -> self
|
#metric_aggregation_type ⇒ String
The aggregation type for the CloudWatch metrics. The valid values are
Minimum, Maximum, and Average.
49 |
# File 'sig/scaling_policy.rbs', line 49
def metric_aggregation_type: () -> ::String
|
#min_adjustment_magnitude ⇒ Integer
The minimum value to scale by when the adjustment type is
PercentChangeInCapacity.
37 |
# File 'sig/scaling_policy.rbs', line 37
def min_adjustment_magnitude: () -> ::Integer
|
#min_adjustment_step ⇒ Integer
Available for backward compatibility. Use MinAdjustmentMagnitude
instead.
34 |
# File 'sig/scaling_policy.rbs', line 34
def min_adjustment_step: () -> ::Integer
|
#name ⇒ String Also known as: policy_name
18 |
# File 'sig/scaling_policy.rbs', line 18
def name: () -> String
|
#policy_arn ⇒ String
The Amazon Resource Name (ARN) of the policy.
25 |
# File 'sig/scaling_policy.rbs', line 25
def policy_arn: () -> ::String
|
#policy_type ⇒ String
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.
28 |
# File 'sig/scaling_policy.rbs', line 28
def policy_type: () -> ::String
|
#predictive_scaling_configuration ⇒ Types::PredictiveScalingConfiguration
A predictive scaling policy.
64 |
# File 'sig/scaling_policy.rbs', line 64
def predictive_scaling_configuration: () -> Types::PredictiveScalingConfiguration
|
#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.
40 |
# File 'sig/scaling_policy.rbs', line 40
def scaling_adjustment: () -> ::Integer
|
#step_adjustments ⇒ Array<Types::StepAdjustment>
A set of adjustments that enable you to scale based on the size of the alarm breach.
46 |
# File 'sig/scaling_policy.rbs', line 46
def step_adjustments: () -> ::Array[Types::StepAdjustment]
|
#target_tracking_configuration ⇒ Types::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
Use [Aws::AutoScaling::Client] #wait_until instead
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() {|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
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( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |