Class: Ufo::Cfn::Stack::Builder::Resources::TargetGroup

Inherits:
Base show all
Defined in:
lib/ufo/cfn/stack/builder/resources/target_group.rb

Instance Attribute Summary

Attributes inherited from Base

#vars

Attributes inherited from Ufo::CLI::Base

#task_definition

Instance Method Summary collapse

Methods inherited from Base

build, #initialize, #manage_ecs_security_group?, #managed_security_group, #security_groups

Methods included from Ufo::Concerns

#deploy, #info, #ps

Methods included from Ufo::Concerns::Names

#names

Methods included from AwsServices

#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #s3, #ssm_client, #waf_client

Methods included from AwsServices::Concerns

#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns

Methods inherited from Ufo::CLI::Base

#initialize

Methods included from Utils::Sure

#sure?

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Methods included from Utils::Logging

#logger

Constructor Details

This class inherits a constructor from Ufo::Cfn::Stack::Builder::Base

Instance Method Details

#buildObject



3
4
5
6
7
8
9
# File 'lib/ufo/cfn/stack/builder/resources/target_group.rb', line 3

def build
  {
    Type: "AWS::ElasticLoadBalancingV2::TargetGroup",
    Condition: "CreateTargetGroupIsTrue",
    Properties: properties,
  }
end

#elbObject



55
56
57
# File 'lib/ufo/cfn/stack/builder/resources/target_group.rb', line 55

def elb
  Ufo.config.elb
end

#propertiesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ufo/cfn/stack/builder/resources/target_group.rb', line 11

def properties
  props = {
    VpcId: {Ref: "Vpc"},
    Tags: [
      {
        Key: "Name",
        Value: @stack_name,
      }
    ],
    Protocol: vars[:default_target_group_protocol],
    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[:Matcher] = matcher
  props[:ProtocolVersion] = protocol_version
  props[:Port] = port

  props
end