Sha256: b2bfbd2f7b6ba280148c1fecb3f6a9d35419dcd11f8b6878a05250a7332c8737

Contents?: true

Size: 988 Bytes

Versions: 36

Compression:

Stored size: 988 Bytes

Contents

module Ufo::Cfn::Stack::Builder::Resources::Scaling
  class Policy < Base
    def build
      return unless autoscaling_enabled?

      text =<<~EOL
        Type: AWS::ApplicationAutoScaling::ScalingPolicy
        Properties:
          PolicyName: !Sub "${AWS::StackName}-auto-scaling-policy"
          PolicyType: TargetTrackingScaling
          ScalingTargetId: !Ref ScalingTarget
          TargetTrackingScalingPolicyConfiguration:
            PredefinedMetricSpecification:
              PredefinedMetricType: #{autoscaling.predefined_metric_type}
            TargetValue: #{autoscaling.target_value}
      EOL

      attrs = Ufo::Yaml.load(text).deep_symbolize_keys
      props = attrs[:Properties]
      conf = props[:TargetTrackingScalingPolicyConfiguration]
      conf[:ScaleInCooldown] = autoscaling.scale_in_cooldown if autoscaling.scale_in_cooldown
      conf[:ScaleOutCooldown] = autoscaling.scale_out_cooldown if autoscaling.scale_out_cooldown

      attrs
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ufo-6.1.5 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.1.4 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.1.3 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.1.2 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.1.1 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.1.0 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.9 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.8 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.7 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.6 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.5 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.4 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.3 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.2 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.1 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.0.0 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb