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.3.13 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.12 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.11 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.10 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.9 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.8 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.7 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.6 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.5 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.4 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.3 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.2 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.1 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.3.0 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.5 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.4 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.3 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.2 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.1 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb
ufo-6.2.0 lib/ufo/cfn/stack/builder/resources/scaling/policy.rb