terrafying-components 1.15.22 → 1.16.0
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 +4 -4
- data/lib/terrafying/components/dynamicset.rb +1 -1
- data/lib/terrafying/components/loadbalancer.rb +19 -14
- data/lib/terrafying/components/prometheus.rb +1 -1
- data/lib/terrafying/components/staticset.rb +4 -4
- data/lib/terrafying/components/usable.rb +4 -4
- data/lib/terrafying/components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ef68fe8cac6454c7f73d265e46325fc00fe561384e94064083fcc10b700235e
|
4
|
+
data.tar.gz: 86b516f8cdec630841d18cd2a40cd02a797f7e7c613c260756a42cf0b7268a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de232dfbd8aeb280917aeb6ee897b107bfba3952c59d0d147af02f739180b071cbe110d3c85bb8fc9bb2283e2411bcfd98f212842a99824c53f14966f69d2be1
|
7
|
+
data.tar.gz: 118ecf7c1240dfbe1b9623c23d3451f727b5c505b24ed236296e4f56938d79e4ddd19fc30a9ac060d007a9b464830bf2e834e2c9fce08d0ae7cc8f12b1f430f7
|
@@ -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
|
@@ -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(
|
40
|
+
lb = aws.lb_by_name(name)
|
41
41
|
|
42
|
-
@security_group = aws.security_group_by_tags(loadbalancer_name:
|
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 =
|
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 =
|
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-#{
|
101
|
-
description: "Describe the ingress and egress of the load balancer #{
|
100
|
+
name: "loadbalancer-#{@name}",
|
101
|
+
description: "Describe the ingress and egress of the load balancer #{@name}",
|
102
102
|
tags: @tags.merge(
|
103
|
-
loadbalancer_name:
|
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:
|
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:
|
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
|
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
|
@@ -38,7 +38,7 @@ module Terrafying
|
|
38
38
|
options = {
|
39
39
|
public: false,
|
40
40
|
eip: false,
|
41
|
-
ami: aws.ami('base-image-fc-
|
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: [],
|
@@ -63,7 +63,7 @@ module Terrafying
|
|
63
63
|
description: "Describe the ingress and egress of the static set #{ident}",
|
64
64
|
tags: options[:tags],
|
65
65
|
vpc_id: vpc.id
|
66
|
-
|
66
|
+
|
67
67
|
vpc_endpoints_egress = options[:vpc_endpoints_egress]
|
68
68
|
if vpc_endpoints_egress.empty?
|
69
69
|
default_egress_rule(ident, @security_group)
|
@@ -102,7 +102,7 @@ module Terrafying
|
|
102
102
|
type: 'ingress',
|
103
103
|
from_port: from_port(port[:upstream_port]),
|
104
104
|
to_port: to_port(port[:upstream_port]),
|
105
|
-
protocol: port[:type],
|
105
|
+
protocol: port[:type] == 'udp' ? 'udp' : 'tcp',
|
106
106
|
self: true
|
107
107
|
end
|
108
108
|
|
@@ -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]),
|
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.
|
4
|
+
version: 1.16.0
|
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
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|