Sha256: c0bcf821085927c074176067a3d707b44655a43251f43df90e68c02e1c77e7c5

Contents?: true

Size: 1.42 KB

Versions: 29

Compression:

Stored size: 1.42 KB

Contents

class Ufo::Cfn::Stack::Builder::Resources
  class TargetGroup < Base
    def build
      {
        Type: "AWS::ElasticLoadBalancingV2::TargetGroup",
        Condition: "CreateTargetGroupIsTrue",
        Properties: properties,
      }
    end

    def properties
      props = {
        VpcId: {Ref: "Vpc"},
        Tags: [
          {
            Key: "Name",
            Value: @stack_name,
          }
        ],
        Protocol: vars[:default_target_group_protocol],
        Port: 80,
        HealthCheckIntervalSeconds: 10,
        HealthyThresholdCount: 2,
        UnhealthyThresholdCount: 2,
        TargetGroupAttributes: [
          {
            Key: "deregistration_delay.timeout_seconds",
            Value: 10
          }
        ]
      }

      props[:TargetType] = "ip" if vars[:container][:network_mode] == "awsvpc"
      props[:HealthCheckPort] = vars[:container][:port] if vars[:elb_type] == "network" && vars[:network_mode] == "awsvpc"
      props[:HealthCheckPath] = health_check_path
      props[:HealthCheckIntervalSeconds] = health_check_interval_seconds
      props[:HealthyThresholdCount] = healthy_threshold_count
      props[:UnhealthyThresholdCount] = unhealthy_threshold_count

      props
    end

    meths = %w[
      health_check_interval_seconds
      health_check_path
      healthy_threshold_count
      unhealthy_threshold_count
    ]
    delegate *meths, to: :elb
    def elb
      Ufo.config.elb
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ufo-6.3.9 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.8 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.7 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.6 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.5 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.4 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.3 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.2 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.1 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.3.0 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.5 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.4 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.3 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.2 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.1 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.2.0 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.1.5 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.1.4 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.1.3 lib/ufo/cfn/stack/builder/resources/target_group.rb
ufo-6.1.2 lib/ufo/cfn/stack/builder/resources/target_group.rb