terrafying-components 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f6c3a26183611276c66ff87fca478593f4ea518aadc777c01cdc82ad2cada834
         | 
| 4 | 
            +
              data.tar.gz: 18febee5dc3610671991ff9cf99e12790565aee35deb731e93e850f718f2a07e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: adc75d83583d4075799ff76449b0e947131540a6b8c630930984a263809d54a9764b6cc03eb16d3940357d01441cadcdf5c71529fd4659e449c400a65daabdda
         | 
| 7 | 
            +
              data.tar.gz: dc26c3124a592de98ea80571d1b9a378a6a6f8c50c15fbf14911b2886511fa52f8b50b9ac66a0edf9bc25c87165b51205d3659c61a6a629aeca70895fe0ac561
         | 
| @@ -132,10 +132,10 @@ module Terrafying | |
| 132 132 | 
             
                  end
         | 
| 133 133 |  | 
| 134 134 | 
             
                  def attach_load_balancer(load_balancer)
         | 
| 135 | 
            -
                    load_balancer. | 
| 135 | 
            +
                    load_balancer.targets.each.with_index { |target, i|
         | 
| 136 136 | 
             
                      resource :aws_autoscaling_attachment, "#{load_balancer.name}-#{@name}-#{i}", {
         | 
| 137 137 | 
             
                                 autoscaling_group_name: @asg,
         | 
| 138 | 
            -
                                 alb_target_group_arn: target_group
         | 
| 138 | 
            +
                                 alb_target_group_arn: target.target_group
         | 
| 139 139 | 
             
                               }
         | 
| 140 140 | 
             
                    }
         | 
| 141 141 |  | 
| @@ -143,10 +143,11 @@ module Terrafying | |
| 143 143 | 
             
                  end
         | 
| 144 144 |  | 
| 145 145 | 
             
                  def autoscale_on_load_balancer(load_balancer, target_value:, disable_scale_in:)
         | 
| 146 | 
            -
                    load_balancer. | 
| 146 | 
            +
                    load_balancer.targets.each.with_index do |target, i|
         | 
| 147 147 | 
             
                      policy_name = "#{load_balancer.name}-#{@name}-#{i}"
         | 
| 148 148 | 
             
                      lb_arn = load_balancer.id.to_s.gsub(/id/, 'arn_suffix')
         | 
| 149 | 
            -
                      tg_arn = target_group.to_s.gsub(/id/, 'arn_suffix')
         | 
| 149 | 
            +
                      tg_arn = target.target_group.to_s.gsub(/id/, 'arn_suffix')
         | 
| 150 | 
            +
                      listener = target.listener.to_s.gsub(/\.id/, '')
         | 
| 150 151 |  | 
| 151 152 | 
             
                      resource :aws_autoscaling_policy, policy_name, {
         | 
| 152 153 | 
             
                        name: policy_name,
         | 
| @@ -160,9 +161,10 @@ module Terrafying | |
| 160 161 | 
             
                          },
         | 
| 161 162 | 
             
                          target_value: target_value,
         | 
| 162 163 | 
             
                          disable_scale_in: disable_scale_in
         | 
| 163 | 
            -
                        }
         | 
| 164 | 
            +
                        },
         | 
| 165 | 
            +
                        depends_on: [listener]
         | 
| 164 166 | 
             
                      }
         | 
| 165 | 
            -
                     | 
| 167 | 
            +
                    end
         | 
| 166 168 | 
             
                  end
         | 
| 167 169 |  | 
| 168 170 | 
             
                  def generate_template(health_check, instances, launch_config, subnets,tags, rolling_update)
         | 
| @@ -5,12 +5,12 @@ require 'terrafying/generator' | |
| 5 5 | 
             
            require_relative './ports'
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Terrafying
         | 
| 8 | 
            -
             | 
| 9 8 | 
             
              module Components
         | 
| 10 | 
            -
             | 
| 11 9 | 
             
                class LoadBalancer < Terrafying::Context
         | 
| 12 10 |  | 
| 13 | 
            -
                  attr_reader :id, :name, :type, :security_group, :ports, : | 
| 11 | 
            +
                  attr_reader :id, :name, :type, :security_group, :ports, :targets, :alias_config
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  Struct.new('Target', :target_group, :listener, keyword_init: true)
         | 
| 14 14 |  | 
| 15 15 | 
             
                  include Usable
         | 
| 16 16 |  | 
| @@ -46,7 +46,13 @@ module Terrafying | |
| 46 46 |  | 
| 47 47 | 
             
                    target_groups = aws.target_groups_by_lb(@id)
         | 
| 48 48 |  | 
| 49 | 
            -
                    @ | 
| 49 | 
            +
                    @targets = target_groups.map { |tg|
         | 
| 50 | 
            +
                      Struct::Target.new(
         | 
| 51 | 
            +
                        target_group: tg.target_group_arn,
         | 
| 52 | 
            +
                        listener: nil
         | 
| 53 | 
            +
                      )
         | 
| 54 | 
            +
                    }
         | 
| 55 | 
            +
             | 
| 50 56 | 
             
                    @ports = enrich_ports(target_groups.map(&:port).sort.uniq)
         | 
| 51 57 |  | 
| 52 58 | 
             
                    @alias_config = {
         | 
| @@ -108,7 +114,7 @@ module Terrafying | |
| 108 114 | 
             
                    }.merge(subnets_for(options[:subnets]))
         | 
| 109 115 | 
             
                     .merge(application? ? { security_groups: [@security_group] } : {})
         | 
| 110 116 |  | 
| 111 | 
            -
                    @ | 
| 117 | 
            +
                    @targets = []
         | 
| 112 118 |  | 
| 113 119 | 
             
                    @ports.each { |port|
         | 
| 114 120 | 
             
                      port_ident = "#{ident}-#{port[:downstream_port]}"
         | 
| @@ -122,7 +128,7 @@ module Terrafying | |
| 122 128 |  | 
| 123 129 | 
             
                      ssl_options = alb_certs(port, port_ident)
         | 
| 124 130 |  | 
| 125 | 
            -
                      resource :aws_lb_listener, port_ident, {
         | 
| 131 | 
            +
                      listener = resource :aws_lb_listener, port_ident, {
         | 
| 126 132 | 
             
                                 load_balancer_arn: @id,
         | 
| 127 133 | 
             
                                 port: port[:upstream_port],
         | 
| 128 134 | 
             
                                 protocol: port[:type].upcase,
         | 
| @@ -132,7 +138,10 @@ module Terrafying | |
| 132 138 | 
             
                                 },
         | 
| 133 139 | 
             
                               }.merge(ssl_options)
         | 
| 134 140 |  | 
| 135 | 
            -
                      @ | 
| 141 | 
            +
                      @targets << Struct::Target.new(
         | 
| 142 | 
            +
                        target_group: target_group,
         | 
| 143 | 
            +
                        listener: listener
         | 
| 144 | 
            +
                      )
         | 
| 136 145 | 
             
                    }
         | 
| 137 146 |  | 
| 138 147 | 
             
                    @alias_config = {
         | 
| @@ -136,9 +136,9 @@ module Terrafying | |
| 136 136 | 
             
                  end
         | 
| 137 137 |  | 
| 138 138 | 
             
                  def attach_load_balancer(load_balancer)
         | 
| 139 | 
            -
                    @instances.product(load_balancer. | 
| 139 | 
            +
                    @instances.product(load_balancer.targets).each.with_index { |(instance, target), i|
         | 
| 140 140 | 
             
                      resource :aws_lb_target_group_attachment, "#{load_balancer.name}-#{@name}-#{i}", {
         | 
| 141 | 
            -
                                 target_group_arn: target_group,
         | 
| 141 | 
            +
                                 target_group_arn: target.target_group,
         | 
| 142 142 | 
             
                                 target_id: instance.id,
         | 
| 143 143 | 
             
                               }
         | 
| 144 144 | 
             
                    }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: terrafying-components
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.9. | 
| 4 | 
            +
              version: 1.9.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - uSwitch Limited
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-11- | 
| 11 | 
            +
            date: 2018-11-23 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |