Class: Applb::DSL::EC2::LoadBalancer::TargetGroups::TargetGroup::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/applb/dsl/target_group.rb

Constant Summary collapse

ATTRIBUTES =
i/
  name protocol port vpc_id health_check_protocol health_check_port health_check_path
  health_check_interval_seconds health_check_timeout_seconds healthy_threshold_count
  unhealthy_threshold_count matcher
/

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Result

Returns a new instance of Result.



19
20
21
22
# File 'lib/applb/dsl/target_group.rb', line 19

def initialize(context)
  @context = context
  @options = context.options
end

Instance Method Details

#aws(aws_tg) ⇒ Object



28
29
30
31
# File 'lib/applb/dsl/target_group.rb', line 28

def aws(aws_tg)
  @aws_tg = aws_tg
  self
end

#createObject



33
34
35
36
37
# File 'lib/applb/dsl/target_group.rb', line 33

def create
  Applb.logger.info("Create target group #{name}")
  return if @options[:dry_run]
  client.create_target_group(create_option).target_groups.first
end

#modifyObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/applb/dsl/target_group.rb', line 39

def modify
  dsl_hash = to_diff_h
  aws_hash = to_diff_h_aws
  return if dsl_hash == aws_hash

  Applb.logger.info("Modify target group #{name}")
  Applb.logger.info("<diff>\n#{Applb::Utils.diff(aws_hash, dsl_hash, color: @options[:color])}")
  return if @options[:dry_run]

  client.modify_target_group(modify_option).target_groups.first
end

#to_hObject



24
25
26
# File 'lib/applb/dsl/target_group.rb', line 24

def to_h
  Hash[ATTRIBUTES.sort.map { |name| [name, public_send(name)] }]
end