terrafying-components 1.15.25 → 1.16.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: 065624fa7820b9041d5b8197c725d6d28b31e8d1a305e0ea5392ae5dc34249ea
4
- data.tar.gz: 65f410d981a749ec65c5108ac4b96a9abe58f30f193251f606f1d9a7baafe799
3
+ metadata.gz: abc7ffc1ed20de13b8618934cff4733da372d880aee548d5a5e557b5f67dd2a3
4
+ data.tar.gz: 1ff951aea47e93472b1d58942b3f08b23fb7d1c1fbe279dc14d3400f616149e5
5
5
  SHA512:
6
- metadata.gz: 3f8a4922ae67518c2387aa118bcf4ad094677cb6dd7f91e4d862072ccd177fe46547388f258c53b32e1224d3c77960b7dd3a56f2376265c2227a280f7d8eb045
7
- data.tar.gz: f92cc6b8f795495c280b10f141e1c78a3c3b5b814c22ae9c4b02d85c9b82589dd4756f19e0017b10dc912a57d52ccd366c894b49076e695b17cd0717285e80c5
6
+ metadata.gz: e6315aa679c2c6a8b089097eb23137bafc61c724a65636f9be35e8a2e1069df8828cbb5cb55722065083369912993882319b9f8029ba0b36671614dff6af7fc8
7
+ data.tar.gz: 0a53e102db91dd7e86d45841c5fc70bb757d43471ee91e9f02d7c4c3ba236ad20e699e3407ed1f86dcc5500e566c2122ee61516f6ac8f9b51e3fe137d18320af
@@ -159,7 +159,7 @@ module Terrafying
159
159
 
160
160
  def attach_load_balancer(load_balancer)
161
161
  load_balancer.targets.each.with_index do |target, i|
162
- resource :aws_autoscaling_attachment, "#{load_balancer.name}-#{@name}-#{i}",
162
+ resource :aws_autoscaling_attachment, "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1'),
163
163
  autoscaling_group_name: @asg,
164
164
  alb_target_group_arn: target.target_group
165
165
  end
@@ -169,13 +169,14 @@ module Terrafying
169
169
 
170
170
  def autoscale_on_load_balancer(load_balancer, target_value:, disable_scale_in:)
171
171
  load_balancer.targets.each.with_index do |target, i|
172
+ policy_ident = "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1')
172
173
  policy_name = "#{load_balancer.name}-#{@name}-#{i}"
173
174
  lb_arn = load_balancer.id.to_s.gsub(/id/, 'arn_suffix')
174
175
  tg_arn = target.target_group.to_s.gsub(/id/, 'arn_suffix')
175
176
  listener = "aws_lb_listener.#{target.listener.to_s.split('.')[1]}"
176
- autoscaling_attachment = "aws_autoscaling_attachment.#{policy_name}"
177
+ autoscaling_attachment = "aws_autoscaling_attachment.#{policy_ident}"
177
178
 
178
- resource :aws_autoscaling_policy, policy_name,
179
+ resource :aws_autoscaling_policy, policy_ident,
179
180
  name: policy_name,
180
181
  autoscaling_group_name: @asg,
181
182
  policy_type: 'TargetTrackingScaling',
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest'
4
3
  require 'terrafying/components/usable'
5
4
  require 'terrafying/generator'
6
-
5
+ require 'digest'
7
6
  require_relative './ports'
8
7
 
9
8
  module Terrafying
@@ -36,14 +35,15 @@ module Terrafying
36
35
  rescue StandardError
37
36
  @type = 'application'
38
37
  ident = make_identifier(@type, vpc.name, name)
38
+ name = make_name(@type, vpc.name, name)
39
39
 
40
- lb = aws.lb_by_name(ident)
40
+ lb = aws.lb_by_name(name)
41
41
 
42
- @security_group = aws.security_group_by_tags(loadbalancer_name: ident)
42
+ @security_group = aws.security_group_by_tags(loadbalancer_name: name)
43
43
  end
44
44
 
45
45
  @id = lb.load_balancer_arn
46
- @name = ident
46
+ @name = name
47
47
 
48
48
  target_groups = aws.target_groups_by_lb(@id)
49
49
 
@@ -93,14 +93,14 @@ module Terrafying
93
93
  @type = l4_ports.count == 0 ? 'application' : 'network'
94
94
 
95
95
  ident = make_identifier(@type, vpc.name, name)
96
- @name = ident
96
+ @name = make_name(@type, vpc.name, name)
97
97
 
98
98
  if application?
99
99
  @security_group = resource :aws_security_group, ident,
100
- name: "loadbalancer-#{ident}",
101
- description: "Describe the ingress and egress of the load balancer #{ident}",
100
+ name: "loadbalancer-#{@name}",
101
+ description: "Describe the ingress and egress of the load balancer #{@name}",
102
102
  tags: @tags.merge(
103
- loadbalancer_name: ident
103
+ loadbalancer_name: @name
104
104
  ),
105
105
  vpc_id: vpc.id
106
106
 
@@ -112,7 +112,7 @@ module Terrafying
112
112
  end
113
113
 
114
114
  @id = resource :aws_lb, ident, {
115
- name: ident,
115
+ name: @name,
116
116
  load_balancer_type: type,
117
117
  internal: !options[:public],
118
118
  tags: @tags
@@ -125,8 +125,9 @@ module Terrafying
125
125
 
126
126
  @ports.each do |port|
127
127
  port_ident = "#{ident}-#{port[:downstream_port]}"
128
+ port_name = "#{@name}-#{port[:downstream_port]}"
128
129
 
129
- default_action = port.key?(:action) ? port[:action] : forward_to_tg(port, port_ident, vpc)
130
+ default_action = port.key?(:action) ? port[:action] : forward_to_tg(port, port_ident, port_name, vpc)
130
131
 
131
132
  ssl_options = alb_certs(port, port_ident)
132
133
 
@@ -148,9 +149,9 @@ module Terrafying
148
149
  self
149
150
  end
150
151
 
151
- def forward_to_tg(port, port_ident, vpc)
152
+ def forward_to_tg(port, port_ident, port_name, vpc)
152
153
  target_group = resource :aws_lb_target_group, port_ident, {
153
- name: port_ident,
154
+ name: port_name,
154
155
  port: port[:downstream_port],
155
156
  protocol: port[:type].upcase,
156
157
  vpc_id: vpc.id
@@ -215,12 +216,16 @@ module Terrafying
215
216
  set.autoscale_on_load_balancer(self, target_value: target_value, disable_scale_in: disable_scale_in)
216
217
  end
217
218
 
218
- def make_identifier(type, vpc_name, name)
219
+ def make_name(type, vpc_name, name)
219
220
  gen_id = "#{type}-#{tf_safe(vpc_name)}-#{name}"
220
221
  return Digest::SHA2.hexdigest(gen_id)[0..24] if @hex_ident || gen_id.size > 26
221
222
 
222
223
  gen_id[0..31]
223
224
  end
225
+
226
+ def make_identifier(type, vpc_name, name)
227
+ make_name(type, vpc_name, name).gsub(%r{^(\d)}, '_\1')
228
+ end
224
229
  end
225
230
  end
226
231
  end
@@ -22,7 +22,7 @@ module Terrafying
22
22
  thanos_name: 'thanos',
23
23
  thanos_version: 'v0.10.1',
24
24
  prom_name: 'prometheus',
25
- prom_version: 'v2.15.2',
25
+ prom_version: 'v2.23.0',
26
26
  instances: 2,
27
27
  instance_type: 't3a.small',
28
28
  thanos_instance_type: 't3a.small',
@@ -166,7 +166,7 @@ module Terrafying
166
166
  prom = Prometheus.find_in(vpc: vpc)
167
167
  ports.each do |port|
168
168
  sg_rule_ident = Digest::SHA256.hexdigest("#{vpc.name}-#{port}-#{security_group}-#{prom.security_group}")
169
- resource :aws_security_group_rule, sg_rule_ident,
169
+ resource :aws_security_group_rule, sg_rule_ident.gsub(%r{^(\d)}, '_\1'),
170
170
  security_group_id: security_group,
171
171
  type: 'ingress',
172
172
  from_port: port,
@@ -161,7 +161,7 @@ module Terrafying
161
161
 
162
162
  def attach_load_balancer(load_balancer)
163
163
  @instances.product(load_balancer.targets).each.with_index do |(instance, target), i|
164
- resource :aws_lb_target_group_attachment, "#{load_balancer.name}-#{@name}-#{i}",
164
+ resource :aws_lb_target_group_attachment, "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1'),
165
165
  target_group_arn: target.target_group,
166
166
  target_id: instance.id
167
167
  end
@@ -16,7 +16,7 @@ module Terrafying
16
16
  end
17
17
 
18
18
  def path_mtu_setup!
19
- resource :aws_security_group_rule, "#{@name}-path-mtu",
19
+ resource :aws_security_group_rule, "#{@name}-path-mtu".gsub(%r{^(\d)}, '_\1'),
20
20
  security_group_id: egress_security_group,
21
21
  type: 'ingress',
22
22
  protocol: 1, # icmp
@@ -42,7 +42,7 @@ module Terrafying
42
42
  cidr_ident = cidr.tr('./', '-')
43
43
 
44
44
  @ports.select(&block).map do |port|
45
- resource :aws_security_group_rule, "#{@name}-to-#{cidr_ident}-#{port[:name]}",
45
+ resource :aws_security_group_rule, "#{@name}-to-#{cidr_ident}-#{port[:name]}".gsub(%r{^(\d)}, '_\1'),
46
46
  security_group_id: ingress_security_group,
47
47
  type: 'ingress',
48
48
  from_port: from_port(port[:upstream_port]),
@@ -92,7 +92,7 @@ module Terrafying
92
92
  def used_by(*other_resources, &block)
93
93
  other_resources.map do |other_resource|
94
94
  @ports.select(&block).map.map do |port|
95
- resource :aws_security_group_rule, "#{@name}-to-#{other_resource.name}-#{port[:name]}",
95
+ resource :aws_security_group_rule, "#{@name}-to-#{other_resource.name}-#{port[:name]}".gsub(%r{^(\d)}, '_\1'),
96
96
  security_group_id: ingress_security_group,
97
97
  type: 'ingress',
98
98
  from_port: from_port(port[:upstream_port]),
@@ -100,7 +100,7 @@ module Terrafying
100
100
  protocol: port[:type] == 'udp' ? 'udp' : 'tcp',
101
101
  source_security_group_id: other_resource.egress_security_group
102
102
 
103
- resource :aws_security_group_rule, "#{other_resource.name}-to-#{@name}-#{port[:name]}",
103
+ resource :aws_security_group_rule, "#{other_resource.name}-to-#{@name}-#{port[:name]}".gsub(%r{^(\d)}, '_\1'),
104
104
  security_group_id: other_resource.egress_security_group,
105
105
  type: 'egress',
106
106
  from_port: from_port(port[:downstream_port]),
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Terrafying
4
4
  module Components
5
- VERSION = '1.15.25'
5
+ VERSION = '1.16.2'
6
6
  end
7
7
  end
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.15.25
4
+ version: 1.16.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: 2020-10-29 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake