terrafying-components 1.15.23 → 1.16.1

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: 38c0abb6c26db58962498dbf9d7972f882961b3eea7ae15ea9e751006a20a8ec
4
- data.tar.gz: eb67dc1708c7ea17c0ad765f497f880355f34ef66f24b6065db42a5508a400ad
3
+ metadata.gz: b50d687af3469863a26431ebf83dce31803b9f4f4796611bb19bb6a484775d85
4
+ data.tar.gz: 2976995d3d9e10a7911512b0a6878fbe29ca6f77d14e221529d7608c256a2004
5
5
  SHA512:
6
- metadata.gz: 68441af54da4b7245890c814210046a19907b359a2001f44213db873a1eea9c0081aa2b04371545887765c5859bd241edf2488d8b3c5b1222e81e91c05ef263c
7
- data.tar.gz: 7e864776191dda38e812051ce5c2ee74cce3ae8a6de474698b57057ea77328c611475706c3619e14c5b522037b0b8615d94520fe0f6616ff864d2bd1d3ec3b9c
6
+ metadata.gz: e28060bd8ca364084b9da908222ca0dd3d484370c46f1f7bbaa3303a897ebc11bf8c6887ddc2b998f57d4e66a001a3bb1adc5568b5c67a4b6b4b5b417cec5c2b
7
+ data.tar.gz: b0aec01bd714de940dc4dd32ea68d048ba7ff024fdfb055d65ba8a35d9750f59bc904d510744f44f7921c7da16946ed1772c7291bf9e8ae56665b5d6c70000cd
@@ -44,12 +44,9 @@ module Terrafying
44
44
  subnets: vpc.subnets.fetch(:private, []),
45
45
  depends_on: [],
46
46
  rolling_update: :simple,
47
- metadata_options: nil,
48
47
  vpc_endpoints_egress: []
49
48
  }.merge(options)
50
49
 
51
- metadata_options = options[:metadata_options]
52
-
53
50
  ident = "#{tf_safe(vpc.name)}-#{name}"
54
51
 
55
52
  @name = ident
@@ -88,7 +85,6 @@ module Terrafying
88
85
  lifecycle: {
89
86
  create_before_destroy: true
90
87
  },
91
- metadata_options: options[:metadata_options],
92
88
  depends_on: resource_name_from(options[:instance_profile])
93
89
 
94
90
  if options[:instances][:track]
@@ -163,7 +159,7 @@ module Terrafying
163
159
 
164
160
  def attach_load_balancer(load_balancer)
165
161
  load_balancer.targets.each.with_index do |target, i|
166
- resource :aws_autoscaling_attachment, "#{load_balancer.name}-#{@name}-#{i}",
162
+ resource :aws_autoscaling_attachment, "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1'),
167
163
  autoscaling_group_name: @asg,
168
164
  alb_target_group_arn: target.target_group
169
165
  end
@@ -173,7 +169,7 @@ module Terrafying
173
169
 
174
170
  def autoscale_on_load_balancer(load_balancer, target_value:, disable_scale_in:)
175
171
  load_balancer.targets.each.with_index do |target, i|
176
- policy_name = "#{load_balancer.name}-#{@name}-#{i}"
172
+ policy_name = "#{load_balancer.name}-#{@name}-#{i}".gsub(%r{^(\d)}, '_\1')
177
173
  lb_arn = load_balancer.id.to_s.gsub(/id/, 'arn_suffix')
178
174
  tg_arn = target.target_group.to_s.gsub(/id/, 'arn_suffix')
179
175
  listener = "aws_lb_listener.#{target.listener.to_s.split('.')[1]}"
@@ -36,7 +36,6 @@ module Terrafying
36
36
  instance_profile: nil,
37
37
  ports: [],
38
38
  tags: {},
39
- metadata_options: nil,
40
39
  security_groups: [],
41
40
  depends_on: []
42
41
  }.merge(options)
@@ -56,12 +55,7 @@ module Terrafying
56
55
  from_port: 0,
57
56
  to_port: 0,
58
57
  protocol: -1,
59
- cidr_blocks: ['0.0.0.0/0'],
60
- ipv6_cidr_blocks: nil,
61
- prefix_list_ids: nil,
62
- security_groups: nil,
63
- self: nil,
64
- description: nil
58
+ cidr_blocks: ['0.0.0.0/0']
65
59
  }
66
60
  ]
67
61
 
@@ -105,7 +99,6 @@ module Terrafying
105
99
  vpc.internal_ssh_security_group
106
100
  ].push(*options[:security_groups]),
107
101
  user_data: options[:user_data],
108
- metadata_options: options[:metadata_options],
109
102
  lifecycle: {
110
103
  create_before_destroy: true
111
104
  },
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest/bubblebabble'
4
3
  require 'terrafying/components/usable'
5
4
  require 'terrafying/generator'
6
5
  require 'digest'
@@ -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,17 +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)
220
+ gen_id = "#{type}-#{tf_safe(vpc_name)}-#{name}"
221
+ return Digest::SHA2.hexdigest(gen_id)[0..24] if @hex_ident || gen_id.size > 26
219
222
 
220
- gen_id = "#{type}-#{vpc_name}-#{name}"
221
- hex = Digest::SHA2.hexdigest(gen_id)[0..24]
222
- if hex[0..0] =~ /[a-z]/
223
- return hex if @hex_ident || gen_id.size > 26
224
- else return Digest::SHA256.bubblebabble(gen_id)[0..15]
225
- end
226
-
227
223
  gen_id[0..31]
228
224
  end
225
+
226
+ def make_identifier(type, vpc_name, name)
227
+ make_name(type, vpc_name, name).gsub(%r{^(\d)}, '_\1')
228
+ end
229
229
  end
230
230
  end
231
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',
@@ -59,7 +59,6 @@ module Terrafying
59
59
  subnets: vpc.subnets.fetch(:private, []),
60
60
  startup_grace_period: 300,
61
61
  depends_on: [],
62
- metadata_options: nil,
63
62
  audit_role: "arn:aws:iam::#{aws.account_id}:role/auditd_logging",
64
63
  metrics_ports: [],
65
64
  vpc_endpoints_egress: []
@@ -97,8 +96,6 @@ module Terrafying
97
96
  @instance_profile = add! InstanceProfile.create(ident, statements: iam_statements)
98
97
  end
99
98
 
100
- metadata_options = options[:metadata_options]
101
-
102
99
  tags = options[:tags].merge(service_name: name)
103
100
 
104
101
  set = options[:instances].is_a?(Hash) ? DynamicSet : StaticSet
@@ -115,7 +112,6 @@ module Terrafying
115
112
  instance_set_options = {
116
113
  instance_profile: @instance_profile,
117
114
  depends_on: depends_on,
118
- metadata_options: metadata_options,
119
115
  tags: tags
120
116
  }
121
117
 
@@ -170,7 +166,7 @@ module Terrafying
170
166
  prom = Prometheus.find_in(vpc: vpc)
171
167
  ports.each do |port|
172
168
  sg_rule_ident = Digest::SHA256.hexdigest("#{vpc.name}-#{port}-#{security_group}-#{prom.security_group}")
173
- resource :aws_security_group_rule, sg_rule_ident,
169
+ resource :aws_security_group_rule, sg_rule_ident.gsub(%r{^(\d)}, '_\1'),
174
170
  security_group_id: security_group,
175
171
  type: 'ingress',
176
172
  from_port: port,
@@ -38,7 +38,7 @@ module Terrafying
38
38
  options = {
39
39
  public: false,
40
40
  eip: false,
41
- ami: aws.ami('base-image-fc-3c48f829', owners = ['477284023816']),
41
+ ami: aws.ami('base-image-fc-2860fb52', owners = ['136393635417']),
42
42
  instance_type: 't3a.micro',
43
43
  subnets: vpc.subnets.fetch(:private, []),
44
44
  ports: [],
@@ -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.23'
5
+ VERSION = '1.16.1'
6
6
  end
7
7
  end
@@ -5,7 +5,6 @@ require 'netaddr'
5
5
  require 'terrafying/components/subnet'
6
6
  require 'terrafying/components/zone'
7
7
  require 'terrafying/generator'
8
- require 'digest/bubblebabble'
9
8
 
10
9
  module Terrafying
11
10
  module Components
@@ -185,12 +184,7 @@ module Terrafying
185
184
  from_port: 22,
186
185
  to_port: 22,
187
186
  protocol: 'tcp',
188
- cidr_blocks: [@cidr],
189
- description: nil,
190
- ipv6_cidr_blocks: nil,
191
- prefix_list_ids: nil,
192
- security_groups: nil,
193
- self: nil
187
+ cidr_blocks: [@cidr]
194
188
  }
195
189
  ],
196
190
  egress: [
@@ -198,12 +192,7 @@ module Terrafying
198
192
  from_port: 22,
199
193
  to_port: 22,
200
194
  protocol: 'tcp',
201
- cidr_blocks: [@cidr],
202
- description: nil,
203
- ipv6_cidr_blocks: nil,
204
- prefix_list_ids: nil,
205
- security_groups: nil,
206
- self: nil
195
+ cidr_blocks: [@cidr]
207
196
  }
208
197
  ]
209
198
  self
@@ -244,7 +233,7 @@ module Terrafying
244
233
  subnets: @subnets.values.flatten
245
234
  }.merge(options)
246
235
 
247
- ident = tf_safe(Digest::SHA256.bubblebabble(ip_address)[0..11]+ip_address)
236
+ ident = tf_safe(ip_address)
248
237
 
249
238
  if options[:tunnels].count > 2
250
239
  raise 'You can only define a max of two tunnels'
@@ -294,7 +283,7 @@ module Terrafying
294
283
  route_tables.product(cidrs).each do |route_table, cidr|
295
284
  hash = Digest::SHA2.hexdigest "#{route_table}-#{tf_safe(cidr)}"
296
285
 
297
- resource :aws_route, "#{@name}-to-#{tf_safe(ip_address)}-peer-#{hash}",
286
+ resource :aws_route, "#{@name}-to-#{ident}-peer-#{hash}",
298
287
  route_table_id: route_table,
299
288
  destination_cidr_block: cidr,
300
289
  gateway_id: vpn_gateway
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.23
4
+ version: 1.16.1
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-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake