Class: Applb::DSL::EC2::LoadBalancer::TargetGroups::TargetGroup::Result
- Inherits:
-
Object
- Object
- Applb::DSL::EC2::LoadBalancer::TargetGroups::TargetGroup::Result
- 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 target_type /
Instance Method Summary collapse
- #aws(aws_tg) ⇒ Object
- #create ⇒ Object
-
#initialize(context) ⇒ Result
constructor
A new instance of Result.
- #modify ⇒ Object
- #to_h ⇒ Object
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. 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 |
#create ⇒ Object
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 |
#modify ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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])}") if unmodifiable_attributes_updated?(dsl_hash, aws_hash) raise 'Can not modify unmodifiable attributes.' end return if @options[:dry_run] client.modify_target_group(modify_option).target_groups.first end |
#to_h ⇒ Object
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 |