terrafying-components 1.9.0 → 1.9.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17ae473ab3bb13ee3c9e59a9a21ca52e7fa475ac82fa10dfba999df184a936c
|
4
|
+
data.tar.gz: 94e1251f7f41160c1585ac0a90557df41a43ee51180372893158a72da16d9084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65061c32d01671493933b6186ecaf598ad3d259eed7e21438e61080c7af9a30537f3eff6f4f3f10f1502aa4a54b9726de78056d67078f138f154b93ae17c0a07
|
7
|
+
data.tar.gz: f273e1ce10eb6e6b0b45d524b83ff640f6c1f00d8425ecf22f2dd20d1ee8e3af91854ca1925cc2bfe099ad17129d7d99a0ae5db8326dfbda2285b80bc230ca17
|
@@ -142,6 +142,29 @@ module Terrafying
|
|
142
142
|
self.used_by(load_balancer) if load_balancer.type == "application"
|
143
143
|
end
|
144
144
|
|
145
|
+
def autoscale_on_load_balancer(load_balancer, target_value:, disable_scale_in:)
|
146
|
+
load_balancer.target_groups.each.with_index { |target_group, i|
|
147
|
+
policy_name = "#{load_balancer.name}-#{@name}-#{i}"
|
148
|
+
lb_arn = load_balancer.id.to_s.gsub(/id/, 'arn_suffix')
|
149
|
+
tg_arn = target_group.to_s.gsub(/id/, 'arn_suffix')
|
150
|
+
|
151
|
+
resource :aws_autoscaling_policy, policy_name, {
|
152
|
+
name: policy_name,
|
153
|
+
autoscaling_group_name: @asg,
|
154
|
+
adjustment_type: 'ChangeInCapacity',
|
155
|
+
policy_type: 'TargetTrackingScaling',
|
156
|
+
target_tracking_configuration: {
|
157
|
+
predefined_metric_specification: {
|
158
|
+
predefined_metric_type: 'ALBRequestCountPerTarget',
|
159
|
+
resource_label: "#{lb_arn}/#{tg_arn}"
|
160
|
+
},
|
161
|
+
target_value: target_value,
|
162
|
+
disable_scale_in: disable_scale_in
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
145
168
|
def generate_template(health_check, instances, launch_config, subnets,tags, rolling_update)
|
146
169
|
template = {
|
147
170
|
Resources: {
|
@@ -152,7 +175,6 @@ module Terrafying
|
|
152
175
|
HealthCheckType: "#{health_check[:type]}",
|
153
176
|
HealthCheckGracePeriod: health_check[:grace_period],
|
154
177
|
LaunchConfigurationName: "#{launch_config}",
|
155
|
-
MaxSize: "#{instances[:max]}",
|
156
178
|
MetricsCollection: [
|
157
179
|
{
|
158
180
|
Granularity: "1Minute",
|
@@ -168,14 +190,15 @@ module Terrafying
|
|
168
190
|
]
|
169
191
|
},
|
170
192
|
],
|
171
|
-
|
172
|
-
|
193
|
+
MaxSize: instances[:max].to_s,
|
194
|
+
MinSize: instances[:min].to_s,
|
195
|
+
DesiredCapacity: instances[:desired] ? instances[:desired].to_s : nil,
|
173
196
|
Tags: tags,
|
174
197
|
TerminationPolicies: [
|
175
198
|
"Default"
|
176
199
|
],
|
177
200
|
VPCZoneIdentifier: subnets
|
178
|
-
}
|
201
|
+
}.compact
|
179
202
|
}
|
180
203
|
},
|
181
204
|
Outputs: {
|
@@ -185,6 +185,11 @@ module Terrafying
|
|
185
185
|
@security_group = set.ingress_security_group if network?
|
186
186
|
end
|
187
187
|
|
188
|
+
def autoscale(set, target_value:, disable_scale_in:)
|
189
|
+
raise "Dont' know how to attach object to LB" unless set.respond_to?(:autoscale_on_load_balancer)
|
190
|
+
set.autoscale_on_load_balancer(self, target_value: target_value, disable_scale_in: disable_scale_in)
|
191
|
+
end
|
192
|
+
|
188
193
|
def make_identifier(type, vpc_name, name)
|
189
194
|
gen_id = "#{type}-#{tf_safe(vpc_name)}-#{name}"
|
190
195
|
return Digest::SHA2.hexdigest(gen_id)[0..24] if @hex_ident || gen_id.size > 26
|
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.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: 2018-11-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|