class AWS::AutoScaling::ScalingPolicy

@attr_reader [String] arn

@attr_reader [String] adjustment_type

@attr_reader [Integer] scaling_adjustment

@attr_reader [Hash] alarms Returns a hash of alarms names (keys)

to alarm ARNs (values).

@attr_reader [Integer] cooldown

@attr_reader [Integer] min_adjustment_magnitude

Attributes

auto_scaling_group[R]

@return [Group]

group[R]

@return [Group]

name[R]

@return [String]

Public Class Methods

new(auto_scaling_group, policy_name, options = {}) click to toggle source

@private

# File lib/aws/auto_scaling/scaling_policy.rb, line 36
def initialize auto_scaling_group, policy_name, options = {}
  @group = auto_scaling_group
  @name = policy_name
  super
end

Public Instance Methods

delete() click to toggle source

Deletes this scaling policy. @return [nil]

# 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 = {}) click to toggle source

Runs this policy against it's Auto Scaling group.

@param [Hash] options

@option options [Boolean] :honor_cooldown (false) Set to true if you

want Auto Scaling to reject this request when the Auto Scaling 
group is in cooldown.

@raise [Errors::ScalingActivityInProgress]

@return [nil]

# 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?() click to toggle source

@return [Boolean] Returns true if the policy exists.

# 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
put(options = {}) click to toggle source
Alias for: update
update(options = {}) click to toggle source

Updates this scaling policy. @param (see AWS::AutoScaling::ScalingPolicyOptions#scaling_policy_options) @option (see AWS::AutoScaling::ScalingPolicyOptions#scaling_policy_options) @return [nil]

# 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
Also aliased as: put

Protected Instance Methods

get_resource(attr_name = nil) click to toggle source
# File lib/aws/auto_scaling/scaling_policy.rb, line 129
def get_resource attr_name = nil
  client_opts = {}
  client_opts[:auto_scaling_group_name] = group.name
  client_opts[:policy_names] = [name]
  client.describe_policies(client_opts)
end
resource_identifiers() click to toggle source
# File lib/aws/auto_scaling/scaling_policy.rb, line 136
def resource_identifiers
  [[:group, group], [:name, name]]
end