rubycfn 0.5.3 → 0.5.4

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: 337ae0668503c4e97c9a3b8a3ed2693d5611ecb592ad2802b83e158f1a2b32f5
4
- data.tar.gz: 25e6d98d9f4ecb0f80fb8a1c55bd907ff2af293ca04e8186774ffec5375948ec
3
+ metadata.gz: 83de34bc40509c9a8425856cbc70eac67efb38eeb7441e6710fd2490abc70779
4
+ data.tar.gz: f8f01c6a27922524362b59aef01d05841d3247c46874caf8cfa2c944ee7441e9
5
5
  SHA512:
6
- metadata.gz: 5de8efbd6b5b242f5f63a336f82602dcb96d6824b4bbf763c62bba0661bf1c811a1c453dfbcef7e20b6650cba46660758a5f99e271b70481e9850c51ba3bf9f5
7
- data.tar.gz: '08fdaabf55a7e3ed1e6bf60b66b038f8729433d257c59fe74323042d178c6f0e0a1d52fd12aae13ea482b14ea986326614f79efb7a412cd2b1eea6932fc0fc83'
6
+ metadata.gz: 7082ea8b1a3f7b3a23406898614fd08c5af073889c13b1101a5b2580e9025881443f91ce5ceb81141508a06bf943ec3c1c4ed9ab754c51a56fd324fc6c659106
7
+ data.tar.gz: c735c3327552fbfea5417ab18442dc2829a7fc05d94a4687af942a8f70ba2e0e5b94d7da66f2b27ebdac278d430da54b606b328706ae215c6cc114b33d0122e1
data/Gemfile.lock CHANGED
@@ -4,7 +4,7 @@ PATH
4
4
  rubycfn (0.5.3)
5
5
  activesupport (~> 5.1.5)
6
6
  dotenv (~> 2.4.0)
7
- json (~> 2.1.0)
7
+ json (~> 2.3.0)
8
8
  neatjson (~> 0.8.4)
9
9
  tty-prompt (~> 0.16.0)
10
10
 
@@ -16,20 +16,20 @@ GEM
16
16
  i18n (>= 0.7, < 2)
17
17
  minitest (~> 5.1)
18
18
  tzinfo (~> 1.1)
19
- addressable (2.7.0)
19
+ addressable (2.8.0)
20
20
  public_suffix (>= 2.0.2, < 5.0)
21
- awesome_print (1.8.0)
22
- coderay (1.1.2)
23
- concurrent-ruby (1.1.6)
24
- diff-lcs (1.3)
25
- docile (1.3.2)
21
+ awesome_print (1.9.2)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.9)
24
+ diff-lcs (1.4.4)
25
+ docile (1.4.0)
26
26
  dotenv (2.4.0)
27
- equatable (0.6.1)
28
- ffi (1.12.2)
29
- formatador (0.2.5)
30
- given_core (3.8.0)
27
+ equatable (0.7.0)
28
+ ffi (1.15.3)
29
+ formatador (0.3.0)
30
+ given_core (3.8.2)
31
31
  sorcerer (>= 0.3.7)
32
- guard (2.16.1)
32
+ guard (2.17.0)
33
33
  formatador (>= 0.2.4)
34
34
  listen (>= 2.7, < 4.0)
35
35
  lumberjack (>= 1.0.12, < 2.0)
@@ -43,65 +43,67 @@ GEM
43
43
  guard (~> 2.1)
44
44
  guard-compat (~> 1.1)
45
45
  rspec (>= 2.99.0, < 4.0)
46
- i18n (1.8.2)
46
+ i18n (1.8.10)
47
47
  concurrent-ruby (~> 1.0)
48
- json (2.1.0)
48
+ json (2.3.1)
49
49
  launchy (2.5.0)
50
50
  addressable (~> 2.7)
51
- listen (3.2.1)
51
+ listen (3.5.1)
52
52
  rb-fsevent (~> 0.10, >= 0.10.3)
53
53
  rb-inotify (~> 0.9, >= 0.9.10)
54
- lumberjack (1.2.4)
55
- method_source (0.9.2)
56
- minitest (5.14.0)
54
+ lumberjack (1.2.8)
55
+ method_source (1.0.0)
56
+ minitest (5.14.4)
57
57
  neatjson (0.8.4)
58
58
  necromancer (0.4.0)
59
59
  nenv (0.3.0)
60
60
  notiffany (0.1.3)
61
61
  nenv (~> 0.1)
62
62
  shellany (~> 0.0)
63
- pastel (0.7.3)
63
+ pastel (0.7.4)
64
64
  equatable (~> 0.6)
65
65
  tty-color (~> 0.5)
66
- pry (0.12.2)
67
- coderay (~> 1.1.0)
68
- method_source (~> 0.9.0)
69
- public_suffix (4.0.3)
70
- rake (13.0.1)
71
- rb-fsevent (0.10.3)
66
+ pry (0.14.1)
67
+ coderay (~> 1.1)
68
+ method_source (~> 1.0)
69
+ public_suffix (4.0.6)
70
+ rake (13.0.4)
71
+ rb-fsevent (0.11.0)
72
72
  rb-inotify (0.10.1)
73
73
  ffi (~> 1.0)
74
- rspec (3.9.0)
75
- rspec-core (~> 3.9.0)
76
- rspec-expectations (~> 3.9.0)
77
- rspec-mocks (~> 3.9.0)
78
- rspec-core (3.9.1)
79
- rspec-support (~> 3.9.1)
80
- rspec-expectations (3.9.1)
74
+ rspec (3.10.0)
75
+ rspec-core (~> 3.10.0)
76
+ rspec-expectations (~> 3.10.0)
77
+ rspec-mocks (~> 3.10.0)
78
+ rspec-core (3.10.1)
79
+ rspec-support (~> 3.10.0)
80
+ rspec-expectations (3.10.1)
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.9.0)
83
- rspec-given (3.8.0)
84
- given_core (= 3.8.0)
82
+ rspec-support (~> 3.10.0)
83
+ rspec-given (3.8.2)
84
+ given_core (= 3.8.2)
85
85
  rspec (>= 2.14.0)
86
86
  rspec-its (1.3.0)
87
87
  rspec-core (>= 3.0.0)
88
88
  rspec-expectations (>= 3.0.0)
89
- rspec-mocks (3.9.1)
89
+ rspec-mocks (3.10.2)
90
90
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.9.0)
92
- rspec-support (3.9.2)
91
+ rspec-support (~> 3.10.0)
92
+ rspec-support (3.10.2)
93
93
  rspec_junit_formatter (0.4.1)
94
94
  rspec-core (>= 2, < 4, != 2.12.0)
95
95
  shellany (0.0.1)
96
- simplecov (0.18.5)
96
+ simplecov (0.21.2)
97
97
  docile (~> 1.1)
98
98
  simplecov-html (~> 0.11)
99
- simplecov-html (0.12.2)
99
+ simplecov_json_formatter (~> 0.1)
100
+ simplecov-html (0.12.3)
101
+ simplecov_json_formatter (0.1.3)
100
102
  sorcerer (2.0.1)
101
- thor (1.0.1)
103
+ thor (1.1.0)
102
104
  thread_safe (0.3.6)
103
- timers (4.3.0)
104
- tty-color (0.5.1)
105
+ timers (4.3.3)
106
+ tty-color (0.6.0)
105
107
  tty-cursor (0.5.0)
106
108
  tty-prompt (0.16.1)
107
109
  necromancer (~> 0.4.0)
@@ -114,7 +116,7 @@ GEM
114
116
  tty-screen (~> 0.6.4)
115
117
  wisper (~> 2.0.0)
116
118
  tty-screen (0.6.5)
117
- tzinfo (1.2.6)
119
+ tzinfo (1.2.9)
118
120
  thread_safe (~> 0.1)
119
121
  wisper (2.0.1)
120
122
 
@@ -137,4 +139,4 @@ DEPENDENCIES
137
139
  simplecov (~> 0.9)
138
140
 
139
141
  BUNDLED WITH
140
- 2.1.4
142
+ 2.2.22
@@ -1,4 +1,4 @@
1
1
  # Rubycfn version
2
2
  module Rubycfn
3
- VERSION = "0.5.3".freeze
3
+ VERSION = "0.5.4".freeze
4
4
  end
data/rubycfn.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "neatjson", "~> 0.8.4"
22
- spec.add_runtime_dependency "json", "~> 2.1.0"
22
+ spec.add_runtime_dependency "json", "~> 2.3.0"
23
23
  spec.add_runtime_dependency "activesupport", "~> 5.1.5"
24
24
  spec.add_runtime_dependency "tty-prompt", "~> 0.16.0"
25
25
  spec.add_runtime_dependency "dotenv", "~> 2.4.0"
@@ -34,8 +34,10 @@ def env_vars_to_array(val)
34
34
  vars
35
35
  end
36
36
 
37
+ @ignore_params = {}
38
+
37
39
  # Return the mandatory Stack parameters and add all defined ENV vars from config.yaml
38
- def parent_parameters(env_vars)
40
+ def parent_parameters(env_vars, simple_name)
39
41
  params = {
40
42
  "Vpc": :vpc_stack.ref("Outputs.Vpc"),
41
43
  "Cluster": :ecs_stack.ref("Outputs.EcsCluster"),
@@ -50,6 +52,11 @@ def parent_parameters(env_vars)
50
52
  }
51
53
 
52
54
  env_vars.each do |var|
55
+ TOPLEVEL_BINDING.eval("@ignore_params[:#{simple_name}] ||= []")
56
+ if var[:Value].class == Hash && var[:Value].keys[0] == :Ref
57
+ TOPLEVEL_BINDING.eval("@ignore_params[:#{simple_name}].push(\"#{var[:Name]}\")")
58
+ next
59
+ end
53
60
  params[var[:Name].cfnize] = var[:Value]
54
61
  end
55
62
  params
@@ -59,10 +66,17 @@ def application_parameters(env_vars)
59
66
  vars = []
60
67
 
61
68
  env_vars.each do |var|
62
- vars.push(
63
- Name: var[:Name],
64
- Value: var[:Name].cfnize.ref
65
- )
69
+ if var[:Value].class == Hash && var[:Value].keys[0] == :Ref
70
+ vars.push(
71
+ Name: var[:Name],
72
+ Value: var[:Value]
73
+ )
74
+ else
75
+ vars.push(
76
+ Name: var[:Name],
77
+ Value: var[:Name].cfnize.ref
78
+ )
79
+ end
66
80
  end
67
81
  vars
68
82
  end
@@ -83,14 +97,23 @@ def create_applications
83
97
 
84
98
  r._id("#{resource_name}Stack")
85
99
  r.property(:template_url) { "#{simple_name}stack" }
86
- r.property(:parameters) { parent_parameters(env_vars) }
100
+ r.property(:parameters) { parent_parameters(env_vars, simple_name) }
87
101
  Object.const_set("#{resource_name}Stack", Module.new).class_eval <<-RUBY
88
102
  extend ActiveSupport::Concern
89
103
  include Rubycfn
90
104
 
91
105
  included do
92
106
 
107
+ def get_aliases(val)
108
+ aliases = []
109
+ return aliases if val["aliases"].nil?
110
+ return aliases if val["aliases"][environment].nil?
111
+ val["aliases"][environment]
112
+ end
113
+
114
+ ignore_params = TOPLEVEL_BINDING.eval("@ignore_params[:#{simple_name}]")
93
115
  application_vars.each do |var|
116
+ next if ignore_params.include? var[:Name]
94
117
  Object.class_eval("parameter var[:Name].to_sym, description: 'Value for ENV var \#{var[:Name]}'")
95
118
  end
96
119
 
@@ -134,17 +157,30 @@ def create_applications
134
157
  description: "ARN of ECS deployment failure Lambda",
135
158
  type: "String"
136
159
 
160
+ variable :aliases,
161
+ value: app_config,
162
+ filter: :get_aliases
163
+
164
+ variable :min_override,
165
+ value: app_config[environment].nil? ? "" : app_config[environment]["min"].to_s
166
+
137
167
  variable :min,
138
- value: app_config["min"].to_s
168
+ value: min_override.empty? ? app_config["min"].to_s : min_override
169
+
170
+ variable :max_override,
171
+ value: app_config[environment].nil? ? "" : app_config[environment]["max"].to_s
139
172
 
140
173
  variable :max,
141
- value: app_config["max"].to_s
174
+ value: max_override.empty? ? app_config["max"].to_s : max_override
142
175
 
143
176
  variable :container_port,
144
177
  value: app_config["container_port"].to_s
145
178
 
179
+ variable :memory_override,
180
+ value: app_config[environment].nil? ? "" : app_config[environment]["mem"].to_s
181
+
146
182
  variable :memory,
147
- value: app_config["mem"].to_s
183
+ value: memory_override.empty? ? app_config["mem"].to_s : memory_override
148
184
 
149
185
  variable :image,
150
186
  value: app_config["image"]
@@ -158,11 +194,14 @@ def create_applications
158
194
 
159
195
 
160
196
  description generate_stack_description("#{resource_name}Stack")
197
+
161
198
  resource :service,
199
+ amount: max.to_i.positive? ? 1 : 0,
162
200
  type: "AWS::ECS::Service" do |r|
163
201
  r.property(:service_name) { "#{environment}-<%= project_name %>-#{simple_name}" }
164
202
  r.property(:cluster) { :cluster.ref }
165
203
  r.property(:role) { :service_role.ref }
204
+ r.property(:health_check_grace_period_seconds) { 120 }
166
205
  r.property(:desired_count) { min.to_i }
167
206
  r.property(:task_definition) { :task_definition.ref }
168
207
  r.property(:load_balancers) do
@@ -175,6 +214,7 @@ def create_applications
175
214
  end
176
215
 
177
216
  resource :application_deployment_health,
217
+ amount: max.to_i.positive? ? 1 : 0,
178
218
  type: "Custom::EcsDeploymentCheck" do |r|
179
219
  r.property(:service_token) { :application_deployment_failure_rollback_function_arn.ref }
180
220
  r.property("AWSRegion") { "${AWS::Region}".fnsub }
@@ -183,6 +223,7 @@ def create_applications
183
223
  end
184
224
 
185
225
  resource :task_definition,
226
+ amount: max.to_i.positive? ? 1 : 0,
186
227
  type: "AWS::ECS::TaskDefinition" do |r|
187
228
  r.property(:family) { "#{simple_name}-service" }
188
229
  r.property(:container_definitions) do
@@ -211,12 +252,14 @@ def create_applications
211
252
  end
212
253
 
213
254
  resource :cloud_watch_logs_group,
255
+ amount: max.to_i.positive? ? 1 : 0,
214
256
  type: "AWS::Logs::LogGroup" do |r|
215
257
  r.property(:log_group_name) { ["AWS::StackName".ref, "-#{simple_name}"].fnjoin }
216
258
  r.property(:retention_in_days) { 30 }
217
259
  end
218
260
 
219
261
  resource :target_group,
262
+ amount: max.to_i.positive? ? 1 : 0,
220
263
  type: "AWS::ElasticLoadBalancingV2::TargetGroup" do |r|
221
264
  r.property(:vpc_id) { :vpc.ref }
222
265
  r.property(:port) { container_port.to_i }
@@ -234,6 +277,7 @@ def create_applications
234
277
  end
235
278
 
236
279
  resource :listener_rule,
280
+ amount: max.to_i.positive? ? 1 : 0,
237
281
  type: "AWS::ElasticLoadBalancingV2::ListenerRule" do |r|
238
282
  r.property(:listener_arn) { :listener.ref }
239
283
  r.property(:priority) { priority.to_i }
@@ -244,7 +288,7 @@ def create_applications
244
288
  "Values": [
245
289
  ["origin", name.tr("_", "-"), :hosted_zone_name.ref].fnjoin("."),
246
290
  [name.tr("_", "-"), :hosted_zone_name.ref].fnjoin(".")
247
- ]
291
+ ] + aliases
248
292
  }
249
293
  ]
250
294
  end
@@ -275,6 +319,7 @@ def create_applications
275
319
  }
276
320
 
277
321
  resource :service_role,
322
+ amount: max.to_i.positive? ? 1 : 0,
278
323
  type: "AWS::IAM::Role" do |r|
279
324
  r.property(:role_name) { "ecs-service-${AWS::StackName}".fnsub }
280
325
  r.property(:path) { "/" }
@@ -330,6 +375,7 @@ def create_applications
330
375
  end
331
376
 
332
377
  resource :application_load_balancer_record,
378
+ amount: max.to_i.positive? ? 1 : 0,
333
379
  type: "AWS::Route53::RecordSet" do |r|
334
380
  r.property(:type) { "A" }
335
381
  r.property(:name) { ["origin", name.tr("_", "-"), :hosted_zone_name.ref].fnjoin(".") }
@@ -344,6 +390,7 @@ def create_applications
344
390
  end
345
391
 
346
392
  resource :service_scalable_target,
393
+ amount: max.to_i.positive? ? 1 : 0,
347
394
  type: "AWS::ApplicationAutoScaling::ScalableTarget" do |r|
348
395
  r.property(:max_capacity) { max.to_i }
349
396
  r.property(:min_capacity) { min.to_i }
@@ -354,6 +401,7 @@ def create_applications
354
401
  end
355
402
 
356
403
  resource :service_scale_out_policy,
404
+ amount: max.to_i.positive? ? 1 : 0,
357
405
  type: "AWS::ApplicationAutoScaling::ScalingPolicy" do |r|
358
406
  r.property(:policy_name) { "ServiceScaleOutPolicy" }
359
407
  r.property(:policy_type) { "StepScaling" }
@@ -374,6 +422,7 @@ def create_applications
374
422
  end
375
423
 
376
424
  resource :service_scale_in_policy,
425
+ amount: max.to_i.positive? ? 1 : 0,
377
426
  type: "AWS::ApplicationAutoScaling::ScalingPolicy" do |r|
378
427
  r.property(:policy_name) { "ServiceScaleInPolicy" }
379
428
  r.property(:policy_type) { "StepScaling" }
@@ -394,6 +443,7 @@ def create_applications
394
443
  end
395
444
 
396
445
  resource :cpu_scale_out_alarm,
446
+ amount: max.to_i.positive? ? 1 : 0,
397
447
  type: "AWS::CloudWatch::Alarm" do |r|
398
448
  r.property(:alarm_name) { "CPU utilization greater than 90% on #{simple_name}-#{environment}" }
399
449
  r.property(:alarm_description) { "Alarm if cpu utilization greater than 90% of reserved cpu" }
@@ -420,6 +470,7 @@ def create_applications
420
470
  end
421
471
 
422
472
  resource :cpu_scale_in_alarm,
473
+ amount: max.to_i.positive? ? 1 : 0,
423
474
  type: "AWS::CloudWatch::Alarm" do |r|
424
475
  r.property(:alarm_name) { "CPU utilization less than 70% on #{simple_name}-#{environment}" }
425
476
  r.property(:alarm_description) { "Alarm if cpu utilization greater than 70% of reserved cpu" }
@@ -446,6 +497,7 @@ def create_applications
446
497
  end
447
498
 
448
499
  resource :ecs_application_certificate,
500
+ amount: max.to_i.positive? ? 1 : 0,
449
501
  type: "Custom::Certificate" do |r|
450
502
  r.property(:service_token) { :certificate_provider_function_arn.ref }
451
503
  r.property(:region) { "us-east-1" }
@@ -454,6 +506,7 @@ def create_applications
454
506
  end
455
507
 
456
508
  resource :ecs_application_issued_certificate,
509
+ amount: max.to_i.positive? ? 1 : 0,
457
510
  type: "Custom::IssuedCertificate" do |r|
458
511
  r.property(:service_token) { :certificate_provider_function_arn.ref }
459
512
  r.property(:region) { "us-east-1" }
@@ -461,6 +514,7 @@ def create_applications
461
514
  end
462
515
 
463
516
  resource :ecs_application_dns_record,
517
+ amount: max.to_i.positive? ? 1 : 0,
464
518
  type: "Custom::CertificateDNSRecord" do |r|
465
519
  r.property(:service_token) { :certificate_provider_function_arn.ref }
466
520
  r.property(:region) { "us-east-1" }
@@ -469,6 +523,7 @@ def create_applications
469
523
  end
470
524
 
471
525
  resource :ecs_application_validation_record,
526
+ amount: max.to_i.positive? ? 1 : 0,
472
527
  type: "AWS::Route53::RecordSetGroup" do |r|
473
528
  r.property(:hosted_zone_id) { :hosted_zone_id.ref }
474
529
  r.property(:record_sets) do
@@ -492,6 +547,7 @@ def create_applications
492
547
  :ecs_application_issued_certificate,
493
548
  :application_deployment_health
494
549
  ],
550
+ amount: max.to_i.positive? ? 1 : 0,
495
551
  type: "AWS::CloudFront::Distribution" do |r|
496
552
  r.property(:distribution_config) do
497
553
  {
@@ -547,6 +603,7 @@ def create_applications
547
603
  end
548
604
 
549
605
  resource :application_cloudfront_dns_record,
606
+ amount: max.to_i.positive? ? 1 : 0,
550
607
  type: "AWS::Route53::RecordSetGroup" do |r|
551
608
  r.property(:hosted_zone_id) { :hosted_zone_id.ref }
552
609
  r.property(:record_sets) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycfn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Vink
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: neatjson
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.0
33
+ version: 2.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.0
40
+ version: 2.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -324,7 +324,7 @@ homepage: https://github.com/dennisvink/rubycfn
324
324
  licenses:
325
325
  - MIT
326
326
  metadata: {}
327
- post_install_message:
327
+ post_install_message:
328
328
  rdoc_options: []
329
329
  require_paths:
330
330
  - lib
@@ -339,9 +339,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
339
  - !ruby/object:Gem::Version
340
340
  version: '0'
341
341
  requirements: []
342
- rubyforge_project:
343
- rubygems_version: 2.7.3
344
- signing_key:
342
+ rubygems_version: 3.1.2
343
+ signing_key:
345
344
  specification_version: 4
346
345
  summary: Rubycfn
347
346
  test_files: