terrafying-components 1.15.18 → 2.0.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 +4 -4
- data/lib/terrafying/components/dynamicset.rb +4 -0
- data/lib/terrafying/components/instance.rb +15 -3
- data/lib/terrafying/components/letsencrypt.rb +11 -2
- data/lib/terrafying/components/loadbalancer.rb +2 -2
- data/lib/terrafying/components/prometheus.rb +8 -1
- data/lib/terrafying/components/service.rb +4 -0
- data/lib/terrafying/components/version.rb +1 -1
- data/lib/terrafying/components/vpc.rb +14 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ed9e1ca845d8806f8a66b55a0c24b7659d75f9927fb8963bce56565c5d324ef
|
4
|
+
data.tar.gz: '09e2d9661b9a2041a62ca36bb3251962eef12af484499fe6a0cea649a7d83c26'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3655d57e5bfcf6efe36a8cf2bc8b8b6bf384721435bf10f5beb457cdf3f344e7a3ae7ea244a81a24441e72a183cf472b5ef6dd274a7aa866e259f2cacd363e8
|
7
|
+
data.tar.gz: a8b13ddd1d36a9d8d5b9fbcf99345fb3ac4093af16d4711664dae80772a2a8aa0623595d2950d7c4d9c0b8f1f358b5660843ad65cabf75dfa0d7ed0682df1827
|
@@ -44,9 +44,12 @@ module Terrafying
|
|
44
44
|
subnets: vpc.subnets.fetch(:private, []),
|
45
45
|
depends_on: [],
|
46
46
|
rolling_update: :simple,
|
47
|
+
metadata_options: {},
|
47
48
|
vpc_endpoints_egress: []
|
48
49
|
}.merge(options)
|
49
50
|
|
51
|
+
metadata_options = options[:metadata_options]
|
52
|
+
|
50
53
|
ident = "#{tf_safe(vpc.name)}-#{name}"
|
51
54
|
|
52
55
|
@name = ident
|
@@ -85,6 +88,7 @@ module Terrafying
|
|
85
88
|
lifecycle: {
|
86
89
|
create_before_destroy: true
|
87
90
|
},
|
91
|
+
metadata_options: options[:metadata_options],
|
88
92
|
depends_on: resource_name_from(options[:instance_profile])
|
89
93
|
|
90
94
|
if options[:instances][:track]
|
@@ -36,8 +36,14 @@ module Terrafying
|
|
36
36
|
instance_profile: nil,
|
37
37
|
ports: [],
|
38
38
|
tags: {},
|
39
|
-
security_groups:
|
40
|
-
|
39
|
+
security_groups: nil,
|
40
|
+
metadata_options: nil,
|
41
|
+
depends_on: nil,
|
42
|
+
ipv6_cidr_blocks: nil,
|
43
|
+
prefix_list_ids: nil,
|
44
|
+
security_groups: nil,
|
45
|
+
self: nil,
|
46
|
+
description: nil,
|
41
47
|
}.merge(options)
|
42
48
|
|
43
49
|
ident = "#{tf_safe(vpc.name)}-#{name}"
|
@@ -55,7 +61,12 @@ module Terrafying
|
|
55
61
|
from_port: 0,
|
56
62
|
to_port: 0,
|
57
63
|
protocol: -1,
|
58
|
-
cidr_blocks: ['0.0.0.0/0']
|
64
|
+
cidr_blocks: ['0.0.0.0/0'],
|
65
|
+
ipv6_cidr_blocks: options[:ipv6_cidr_blocks],
|
66
|
+
prefix_list_ids: options[:prefix_list_ids],
|
67
|
+
security_groups: options[:security_groups],
|
68
|
+
self: options[:self],
|
69
|
+
description: options[:description]
|
59
70
|
}
|
60
71
|
]
|
61
72
|
|
@@ -99,6 +110,7 @@ module Terrafying
|
|
99
110
|
vpc.internal_ssh_security_group
|
100
111
|
].push(*options[:security_groups]),
|
101
112
|
user_data: options[:user_data],
|
113
|
+
metadata_options: options[:metadata_options],
|
102
114
|
lifecycle: {
|
103
115
|
create_before_destroy: true
|
104
116
|
},
|
@@ -345,11 +345,12 @@ module Terrafying
|
|
345
345
|
policy_arn: "${aws_iam_policy.#{@name}_lambda_execution_policy.arn}"
|
346
346
|
}
|
347
347
|
|
348
|
-
|
348
|
+
alpha_num = generate_alpha_num().to_s
|
349
|
+
|
349
350
|
event_rule = resource :aws_cloudwatch_event_rule, "once_per_day", {
|
350
351
|
name: "once-per-day",
|
351
352
|
description: "Fires once per day",
|
352
|
-
schedule_expression: "cron(0 #{
|
353
|
+
schedule_expression: "cron(0 #{alpha_num} * * ? *)"
|
353
354
|
}
|
354
355
|
|
355
356
|
resource :aws_cloudwatch_event_target, "#{@name}_lambda_event_target", {
|
@@ -368,6 +369,14 @@ module Terrafying
|
|
368
369
|
self
|
369
370
|
end
|
370
371
|
|
372
|
+
def generate_alpha_num()
|
373
|
+
result = @name.split("").each do |ch|
|
374
|
+
alpha_num = ch.upcase.ord - 'A'.ord
|
375
|
+
return alpha_num.abs if (alpha_num.abs < 24)
|
376
|
+
end
|
377
|
+
result.is_a?(Integer) ? result : 6
|
378
|
+
end
|
379
|
+
|
371
380
|
end
|
372
381
|
end
|
373
382
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'digest'
|
3
|
+
require 'digest/bubblebabble'
|
4
4
|
require 'terrafying/components/usable'
|
5
5
|
require 'terrafying/generator'
|
6
6
|
|
@@ -217,7 +217,7 @@ module Terrafying
|
|
217
217
|
|
218
218
|
def make_identifier(type, vpc_name, name)
|
219
219
|
gen_id = "#{type}-#{tf_safe(vpc_name)}-#{name}"
|
220
|
-
return Digest::
|
220
|
+
return Digest::SHA256.bubblebabble(gen_id)[0..15] if @hex_ident || gen_id.size > 26
|
221
221
|
|
222
222
|
gen_id[0..31]
|
223
223
|
end
|
@@ -28,7 +28,8 @@ module Terrafying
|
|
28
28
|
thanos_instance_type: 't3a.small',
|
29
29
|
prometheus_tsdb_retention: '1d',
|
30
30
|
prometheus_data_dir: '/var/lib/prometheus',
|
31
|
-
prometheus_data_size: 20
|
31
|
+
prometheus_data_size: 20,
|
32
|
+
prometheus_additional_scrape_configs: []
|
32
33
|
)
|
33
34
|
super()
|
34
35
|
@vpc = vpc
|
@@ -42,6 +43,7 @@ module Terrafying
|
|
42
43
|
@prometheus_tsdb_retention = prometheus_tsdb_retention
|
43
44
|
@prometheus_data_dir = prometheus_data_dir
|
44
45
|
@prometheus_data_size = prometheus_data_size
|
46
|
+
@prometheus_additional_scrape_configs = prometheus_additional_scrape_configs
|
45
47
|
end
|
46
48
|
|
47
49
|
def find
|
@@ -270,6 +272,11 @@ module Terrafying
|
|
270
272
|
target_label: instance_id
|
271
273
|
- source_labels: [__meta_ec2_tag_envoy_cluster]
|
272
274
|
target_label: envoy_cluster
|
275
|
+
- source_labels: [__meta_ec2_tag_service_name]
|
276
|
+
target_label: service_name
|
277
|
+
<%- end -%>
|
278
|
+
<%- @prometheus_additional_scrape_configs.each do |conf| -%>
|
279
|
+
<%= conf %>
|
273
280
|
<%- end -%>
|
274
281
|
END
|
275
282
|
}
|
@@ -59,6 +59,7 @@ module Terrafying
|
|
59
59
|
subnets: vpc.subnets.fetch(:private, []),
|
60
60
|
startup_grace_period: 300,
|
61
61
|
depends_on: [],
|
62
|
+
metadata_options: {},
|
62
63
|
audit_role: "arn:aws:iam::#{aws.account_id}:role/auditd_logging",
|
63
64
|
metrics_ports: [],
|
64
65
|
vpc_endpoints_egress: []
|
@@ -96,6 +97,8 @@ module Terrafying
|
|
96
97
|
@instance_profile = add! InstanceProfile.create(ident, statements: iam_statements)
|
97
98
|
end
|
98
99
|
|
100
|
+
metadata_options = options[:metadata_options]
|
101
|
+
|
99
102
|
tags = options[:tags].merge(service_name: name)
|
100
103
|
|
101
104
|
set = options[:instances].is_a?(Hash) ? DynamicSet : StaticSet
|
@@ -112,6 +115,7 @@ module Terrafying
|
|
112
115
|
instance_set_options = {
|
113
116
|
instance_profile: @instance_profile,
|
114
117
|
depends_on: depends_on,
|
118
|
+
metadata_options: metadata_options,
|
115
119
|
tags: tags
|
116
120
|
}
|
117
121
|
|
@@ -5,6 +5,7 @@ require 'netaddr'
|
|
5
5
|
require 'terrafying/components/subnet'
|
6
6
|
require 'terrafying/components/zone'
|
7
7
|
require 'terrafying/generator'
|
8
|
+
require 'digest/bubblebabble'
|
8
9
|
|
9
10
|
module Terrafying
|
10
11
|
module Components
|
@@ -184,7 +185,12 @@ module Terrafying
|
|
184
185
|
from_port: 22,
|
185
186
|
to_port: 22,
|
186
187
|
protocol: 'tcp',
|
187
|
-
cidr_blocks: [@cidr]
|
188
|
+
cidr_blocks: [@cidr],
|
189
|
+
description: nil,
|
190
|
+
ipv6_cidr_blocks: nil,
|
191
|
+
prefix_list_ids: nil,
|
192
|
+
security_groups: nil,
|
193
|
+
self: nil
|
188
194
|
}
|
189
195
|
],
|
190
196
|
egress: [
|
@@ -192,7 +198,12 @@ module Terrafying
|
|
192
198
|
from_port: 22,
|
193
199
|
to_port: 22,
|
194
200
|
protocol: 'tcp',
|
195
|
-
cidr_blocks: [@cidr]
|
201
|
+
cidr_blocks: [@cidr],
|
202
|
+
description: nil,
|
203
|
+
ipv6_cidr_blocks: nil,
|
204
|
+
prefix_list_ids: nil,
|
205
|
+
security_groups: nil,
|
206
|
+
self: nil
|
196
207
|
}
|
197
208
|
]
|
198
209
|
self
|
@@ -233,7 +244,7 @@ module Terrafying
|
|
233
244
|
subnets: @subnets.values.flatten
|
234
245
|
}.merge(options)
|
235
246
|
|
236
|
-
ident = tf_safe(ip_address)
|
247
|
+
ident = tf_safe(Digest::SHA256.bubblebabble(ip_address)[0..11]+ip_address)
|
237
248
|
|
238
249
|
if options[:tunnels].count > 2
|
239
250
|
raise 'You can only define a max of two tunnels'
|
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:
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.7.
|
61
|
+
version: 1.7.8
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.7.
|
68
|
+
version: 1.7.8
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: xxhash
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|