Class: AWS::AutoScaling::ScalingPolicy

Inherits:
Core::Resource
  • Object
show all
Defined in:
lib/aws/auto_scaling/scaling_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adjustment_typeString (readonly)

Returns the current value of adjustment_type.

Returns:

  • (String)

    the current value of adjustment_type



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def adjustment_type
  @adjustment_type
end

#alarmsHash (readonly)

Returns a hash of alarms names (keys) to alarm ARNs (values).

Returns:

  • (Hash)

    the current value of alarms



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def alarms
  @alarms
end

#arnString (readonly)

Returns the current value of arn.

Returns:

  • (String)

    the current value of arn



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def arn
  @arn
end

#cooldownInteger (readonly)

Returns the current value of cooldown.

Returns:

  • (Integer)

    the current value of cooldown



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def cooldown
  @cooldown
end

#groupGroup (readonly) Also known as: auto_scaling_group

Returns:



43
44
45
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 43

def group
  @group
end

#min_adjustment_stepInteger (readonly)

Returns the current value of min_adjustment_step.

Returns:

  • (Integer)

    the current value of min_adjustment_step



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def min_adjustment_step
  @min_adjustment_step
end

#nameString (readonly)

Returns:

  • (String)


48
49
50
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 48

def name
  @name
end

#scaling_adjustmentInteger (readonly)

Returns the current value of scaling_adjustment.

Returns:

  • (Integer)

    the current value of scaling_adjustment



31
32
33
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 31

def scaling_adjustment
  @scaling_adjustment
end

Instance Method Details

#deletenil

Deletes this scaling policy.

Returns:

  • (nil)


110
111
112
113
114
115
116
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 110

def delete
  client_opts = {}
  client_opts[:auto_scaling_group_name] = group.name
  client_opts[:policy_name] = name
  client.delete_policy(client_opts)
  nil
end

#execute(options = {}) ⇒ nil

Runs this policy against it’s Auto Scaling group.

Parameters:

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

Options Hash (options):

  • :honor_cooldown (Boolean) — default: false

    Set to true if you want Auto Scaling to reject this request when the Auto Scaling group is in cooldown.

Returns:

  • (nil)

Raises:

  • (Errors::ScalingActivityInProgress)


99
100
101
102
103
104
105
106
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 99

def execute options = {}
  client_opts = {}
  client_opts[:auto_scaling_group_name] = group.name
  client_opts[:policy_name] = name
  client_opts[:honor_cooldown] = options[:honor_cooldown] == true
  client.execute_policy(client_opts)
  nil
end

#exists?Boolean

Returns true if the policy exists.

Returns:

  • (Boolean)

    Returns true if the policy exists.



119
120
121
122
123
124
125
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 119

def exists?
  client_opts = {}
  client_opts[:auto_scaling_group_name] = group.name
  client_opts[:policy_names] = [name]
  resp = client.describe_policies(client_opts)
  !resp.scaling_policies.empty?
end

#update(options = {}) ⇒ nil Also known as: put

Updates this scaling policy.

Parameters:

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

Options Hash (options):

  • :adjustment_type (required, String)

    Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are:

    • ‘ChangeInCapacity’

    • ‘ExactCapacity’

    • ‘PercentChangeInCapacity’

  • :scaling_adjustment (required, Integer)

    The number of instances by which to scale. :adjustment_type determines the interpretation of this umber (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity.

  • :cooldown (Integer)

    The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start.

  • :min_adjustment_step (Integer)

Returns:

  • (nil)


79
80
81
82
83
84
# File 'lib/aws/auto_scaling/scaling_policy.rb', line 79

def update options = {}
  client_opts = scaling_policy_options(group, name, options)
  resp = client.put_scaling_policy(client_opts)
  static_attributes[:arn] = resp.policy_arn
  nil
end