cloud-mu 3.1.3 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +15 -3
- data/ansible/roles/mu-windows/README.md +33 -0
- data/ansible/roles/mu-windows/defaults/main.yml +2 -0
- data/ansible/roles/mu-windows/files/LaunchConfig.json +9 -0
- data/ansible/roles/mu-windows/files/config.xml +76 -0
- data/ansible/roles/mu-windows/handlers/main.yml +2 -0
- data/ansible/roles/mu-windows/meta/main.yml +53 -0
- data/ansible/roles/mu-windows/tasks/main.yml +36 -0
- data/ansible/roles/mu-windows/tests/inventory +2 -0
- data/ansible/roles/mu-windows/tests/test.yml +5 -0
- data/ansible/roles/mu-windows/vars/main.yml +2 -0
- data/bin/mu-adopt +21 -13
- data/bin/mu-azure-tests +57 -0
- data/bin/mu-cleanup +2 -4
- data/bin/mu-configure +52 -0
- data/bin/mu-deploy +3 -3
- data/bin/mu-findstray-tests +25 -0
- data/bin/mu-gen-docs +2 -4
- data/bin/mu-load-config.rb +4 -4
- data/bin/mu-node-manage +15 -16
- data/bin/mu-run-tests +147 -37
- data/cloud-mu.gemspec +22 -20
- data/cookbooks/mu-activedirectory/resources/domain.rb +4 -4
- data/cookbooks/mu-activedirectory/resources/domain_controller.rb +4 -4
- data/cookbooks/mu-tools/libraries/helper.rb +3 -2
- data/cookbooks/mu-tools/libraries/monkey.rb +35 -0
- data/cookbooks/mu-tools/recipes/apply_security.rb +14 -14
- data/cookbooks/mu-tools/recipes/aws_api.rb +9 -0
- data/cookbooks/mu-tools/recipes/eks.rb +2 -2
- data/cookbooks/mu-tools/recipes/google_api.rb +2 -2
- data/cookbooks/mu-tools/recipes/selinux.rb +2 -1
- data/cookbooks/mu-tools/recipes/windows-client.rb +163 -164
- data/cookbooks/mu-tools/resources/disk.rb +1 -1
- data/cookbooks/mu-tools/resources/windows_users.rb +44 -43
- data/extras/clean-stock-amis +25 -19
- data/extras/generate-stock-images +1 -0
- data/extras/image-generators/AWS/win2k12.yaml +18 -13
- data/extras/image-generators/AWS/win2k16.yaml +18 -13
- data/extras/image-generators/AWS/win2k19.yaml +21 -0
- data/extras/image-generators/Google/centos6.yaml +1 -0
- data/extras/image-generators/Google/centos7.yaml +1 -1
- data/modules/mommacat.ru +6 -16
- data/modules/mu.rb +158 -111
- data/modules/mu/adoption.rb +404 -71
- data/modules/mu/cleanup.rb +221 -306
- data/modules/mu/cloud.rb +129 -1633
- data/modules/mu/cloud/database.rb +49 -0
- data/modules/mu/cloud/dnszone.rb +44 -0
- data/modules/mu/cloud/machine_images.rb +212 -0
- data/modules/mu/cloud/providers.rb +81 -0
- data/modules/mu/cloud/resource_base.rb +926 -0
- data/modules/mu/cloud/server.rb +40 -0
- data/modules/mu/cloud/server_pool.rb +1 -0
- data/modules/mu/cloud/ssh_sessions.rb +228 -0
- data/modules/mu/cloud/winrm_sessions.rb +237 -0
- data/modules/mu/cloud/wrappers.rb +169 -0
- data/modules/mu/config.rb +171 -1767
- data/modules/mu/config/alarm.rb +2 -6
- data/modules/mu/config/bucket.rb +32 -3
- data/modules/mu/config/cache_cluster.rb +2 -2
- data/modules/mu/config/cdn.rb +100 -0
- data/modules/mu/config/collection.rb +4 -4
- data/modules/mu/config/container_cluster.rb +9 -4
- data/modules/mu/config/database.rb +84 -105
- data/modules/mu/config/database.yml +1 -2
- data/modules/mu/config/dnszone.rb +10 -9
- data/modules/mu/config/doc_helpers.rb +516 -0
- data/modules/mu/config/endpoint.rb +5 -4
- data/modules/mu/config/firewall_rule.rb +103 -4
- data/modules/mu/config/folder.rb +4 -4
- data/modules/mu/config/function.rb +19 -10
- data/modules/mu/config/group.rb +4 -4
- data/modules/mu/config/habitat.rb +4 -4
- data/modules/mu/config/job.rb +89 -0
- data/modules/mu/config/loadbalancer.rb +60 -14
- data/modules/mu/config/log.rb +4 -4
- data/modules/mu/config/msg_queue.rb +4 -4
- data/modules/mu/config/nosqldb.rb +4 -4
- data/modules/mu/config/notifier.rb +10 -21
- data/modules/mu/config/ref.rb +411 -0
- data/modules/mu/config/role.rb +4 -4
- data/modules/mu/config/schema_helpers.rb +509 -0
- data/modules/mu/config/search_domain.rb +4 -4
- data/modules/mu/config/server.rb +98 -71
- data/modules/mu/config/server.yml +1 -0
- data/modules/mu/config/server_pool.rb +5 -9
- data/modules/mu/config/storage_pool.rb +1 -1
- data/modules/mu/config/tail.rb +200 -0
- data/modules/mu/config/user.rb +4 -4
- data/modules/mu/config/vpc.rb +71 -27
- data/modules/mu/config/vpc.yml +0 -1
- data/modules/mu/defaults/AWS.yaml +91 -68
- data/modules/mu/defaults/Azure.yaml +1 -0
- data/modules/mu/defaults/Google.yaml +3 -2
- data/modules/mu/deploy.rb +43 -26
- data/modules/mu/groomer.rb +17 -2
- data/modules/mu/groomers/ansible.rb +188 -41
- data/modules/mu/groomers/chef.rb +116 -55
- data/modules/mu/logger.rb +127 -148
- data/modules/mu/master.rb +410 -2
- data/modules/mu/master/chef.rb +3 -4
- data/modules/mu/master/ldap.rb +3 -3
- data/modules/mu/master/ssl.rb +12 -3
- data/modules/mu/mommacat.rb +218 -2612
- data/modules/mu/mommacat/daemon.rb +403 -0
- data/modules/mu/mommacat/naming.rb +473 -0
- data/modules/mu/mommacat/search.rb +495 -0
- data/modules/mu/mommacat/storage.rb +722 -0
- data/modules/mu/{clouds → providers}/README.md +1 -1
- data/modules/mu/{clouds → providers}/aws.rb +380 -122
- data/modules/mu/{clouds → providers}/aws/alarm.rb +7 -5
- data/modules/mu/{clouds → providers}/aws/bucket.rb +297 -59
- data/modules/mu/{clouds → providers}/aws/cache_cluster.rb +37 -71
- data/modules/mu/providers/aws/cdn.rb +782 -0
- data/modules/mu/{clouds → providers}/aws/collection.rb +26 -25
- data/modules/mu/{clouds → providers}/aws/container_cluster.rb +724 -744
- data/modules/mu/providers/aws/database.rb +1744 -0
- data/modules/mu/{clouds → providers}/aws/dnszone.rb +88 -70
- data/modules/mu/providers/aws/endpoint.rb +1072 -0
- data/modules/mu/{clouds → providers}/aws/firewall_rule.rb +220 -247
- data/modules/mu/{clouds → providers}/aws/folder.rb +8 -8
- data/modules/mu/{clouds → providers}/aws/function.rb +300 -142
- data/modules/mu/{clouds → providers}/aws/group.rb +31 -29
- data/modules/mu/{clouds → providers}/aws/habitat.rb +18 -15
- data/modules/mu/providers/aws/job.rb +466 -0
- data/modules/mu/{clouds → providers}/aws/loadbalancer.rb +66 -56
- data/modules/mu/{clouds → providers}/aws/log.rb +17 -14
- data/modules/mu/{clouds → providers}/aws/msg_queue.rb +29 -19
- data/modules/mu/{clouds → providers}/aws/nosqldb.rb +114 -16
- data/modules/mu/{clouds → providers}/aws/notifier.rb +142 -65
- data/modules/mu/{clouds → providers}/aws/role.rb +158 -118
- data/modules/mu/{clouds → providers}/aws/search_domain.rb +201 -59
- data/modules/mu/{clouds → providers}/aws/server.rb +844 -1139
- data/modules/mu/{clouds → providers}/aws/server_pool.rb +74 -65
- data/modules/mu/{clouds → providers}/aws/storage_pool.rb +26 -44
- data/modules/mu/{clouds → providers}/aws/user.rb +24 -25
- data/modules/mu/{clouds → providers}/aws/userdata/README.md +0 -0
- data/modules/mu/{clouds → providers}/aws/userdata/linux.erb +5 -4
- data/modules/mu/{clouds → providers}/aws/userdata/windows.erb +2 -1
- data/modules/mu/{clouds → providers}/aws/vpc.rb +525 -931
- data/modules/mu/providers/aws/vpc_subnet.rb +286 -0
- data/modules/mu/{clouds → providers}/azure.rb +29 -9
- data/modules/mu/{clouds → providers}/azure/container_cluster.rb +3 -8
- data/modules/mu/{clouds → providers}/azure/firewall_rule.rb +18 -11
- data/modules/mu/{clouds → providers}/azure/habitat.rb +8 -6
- data/modules/mu/{clouds → providers}/azure/loadbalancer.rb +5 -5
- data/modules/mu/{clouds → providers}/azure/role.rb +8 -10
- data/modules/mu/{clouds → providers}/azure/server.rb +97 -49
- data/modules/mu/{clouds → providers}/azure/user.rb +6 -8
- data/modules/mu/{clouds → providers}/azure/userdata/README.md +0 -0
- data/modules/mu/{clouds → providers}/azure/userdata/linux.erb +0 -0
- data/modules/mu/{clouds → providers}/azure/userdata/windows.erb +0 -0
- data/modules/mu/{clouds → providers}/azure/vpc.rb +16 -21
- data/modules/mu/{clouds → providers}/cloudformation.rb +18 -7
- data/modules/mu/{clouds → providers}/cloudformation/alarm.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/cache_cluster.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/collection.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/database.rb +6 -17
- data/modules/mu/{clouds → providers}/cloudformation/dnszone.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/firewall_rule.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/loadbalancer.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/log.rb +3 -3
- data/modules/mu/{clouds → providers}/cloudformation/server.rb +7 -7
- data/modules/mu/{clouds → providers}/cloudformation/server_pool.rb +5 -5
- data/modules/mu/{clouds → providers}/cloudformation/vpc.rb +5 -7
- data/modules/mu/{clouds → providers}/docker.rb +0 -0
- data/modules/mu/{clouds → providers}/google.rb +68 -30
- data/modules/mu/{clouds → providers}/google/bucket.rb +13 -15
- data/modules/mu/{clouds → providers}/google/container_cluster.rb +85 -78
- data/modules/mu/{clouds → providers}/google/database.rb +11 -21
- data/modules/mu/{clouds → providers}/google/firewall_rule.rb +15 -14
- data/modules/mu/{clouds → providers}/google/folder.rb +20 -17
- data/modules/mu/{clouds → providers}/google/function.rb +140 -168
- data/modules/mu/{clouds → providers}/google/group.rb +29 -34
- data/modules/mu/{clouds → providers}/google/habitat.rb +21 -22
- data/modules/mu/{clouds → providers}/google/loadbalancer.rb +19 -21
- data/modules/mu/{clouds → providers}/google/role.rb +94 -58
- data/modules/mu/{clouds → providers}/google/server.rb +243 -156
- data/modules/mu/{clouds → providers}/google/server_pool.rb +26 -45
- data/modules/mu/{clouds → providers}/google/user.rb +95 -31
- data/modules/mu/{clouds → providers}/google/userdata/README.md +0 -0
- data/modules/mu/{clouds → providers}/google/userdata/linux.erb +0 -0
- data/modules/mu/{clouds → providers}/google/userdata/windows.erb +0 -0
- data/modules/mu/{clouds → providers}/google/vpc.rb +103 -79
- data/modules/tests/aws-jobs-functions.yaml +46 -0
- data/modules/tests/bucket.yml +4 -0
- data/modules/tests/centos6.yaml +15 -0
- data/modules/tests/centos7.yaml +15 -0
- data/modules/tests/centos8.yaml +12 -0
- data/modules/tests/ecs.yaml +23 -0
- data/modules/tests/eks.yaml +1 -1
- data/modules/tests/functions/node-function/lambda_function.js +10 -0
- data/modules/tests/functions/python-function/lambda_function.py +12 -0
- data/modules/tests/includes-and-params.yaml +2 -1
- data/modules/tests/microservice_app.yaml +288 -0
- data/modules/tests/rds.yaml +108 -0
- data/modules/tests/regrooms/aws-iam.yaml +201 -0
- data/modules/tests/regrooms/bucket.yml +19 -0
- data/modules/tests/regrooms/rds.yaml +123 -0
- data/modules/tests/server-with-scrub-muisms.yaml +2 -1
- data/modules/tests/super_complex_bok.yml +2 -2
- data/modules/tests/super_simple_bok.yml +3 -5
- data/modules/tests/win2k12.yaml +17 -5
- data/modules/tests/win2k16.yaml +25 -0
- data/modules/tests/win2k19.yaml +25 -0
- data/requirements.txt +1 -0
- data/spec/mu/clouds/azure_spec.rb +2 -2
- metadata +240 -154
- data/extras/image-generators/AWS/windows.yaml +0 -18
- data/modules/mu/clouds/aws/database.rb +0 -1985
- data/modules/mu/clouds/aws/endpoint.rb +0 -592
@@ -163,7 +163,7 @@ module MU
|
|
163
163
|
dnsthread = Thread.new {
|
164
164
|
if !MU::Cloud::AWS.isGovCloud?
|
165
165
|
MU.dupGlobals(parent_thread_id)
|
166
|
-
generic_mu_dns = MU::Cloud
|
166
|
+
generic_mu_dns = MU::Cloud.resourceClass("AWS", "DNSZone").genericMuDNSEntry(name: @mu_name, target: "#{lb.dns_name}.", cloudclass: MU::Cloud::LoadBalancer, sync_wait: @config['dns_sync_wait'])
|
167
167
|
end
|
168
168
|
}
|
169
169
|
|
@@ -239,16 +239,35 @@ module MU
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
+
redirect_block = Proc.new { |r|
|
243
|
+
{
|
244
|
+
:protocol => r['protocol'],
|
245
|
+
:port => r['port'].to_s,
|
246
|
+
:host => r['host'],
|
247
|
+
:path => r['path'],
|
248
|
+
:query => r['query'],
|
249
|
+
:status_code => "HTTP_"+r['status_code'].to_s
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
242
253
|
if !@config['classic']
|
243
254
|
@config["listeners"].each { |l|
|
244
|
-
if
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
255
|
+
action = if l['redirect']
|
256
|
+
{
|
257
|
+
:type => "redirect",
|
258
|
+
:redirect_config => redirect_block.call(l['redirect'])
|
259
|
+
}
|
260
|
+
else
|
261
|
+
if !@targetgroups.has_key?(l['targetgroup'])
|
262
|
+
raise MuError, "Listener in #{@mu_name} configured for target group #{l['targetgroup']}, but I don't have data on a targetgroup by that name"
|
263
|
+
end
|
264
|
+
{
|
249
265
|
:target_group_arn => @targetgroups[l['targetgroup']].target_group_arn,
|
250
266
|
:type => "forward"
|
251
|
-
}
|
267
|
+
}
|
268
|
+
end
|
269
|
+
listen_descriptor = {
|
270
|
+
:default_actions => [ action ],
|
252
271
|
:load_balancer_arn => lb.load_balancer_arn,
|
253
272
|
:port => l['lb_port'],
|
254
273
|
:protocol => l['lb_protocol']
|
@@ -276,10 +295,17 @@ module MU
|
|
276
295
|
:actions => []
|
277
296
|
}
|
278
297
|
rule['actions'].each { |a|
|
279
|
-
rule_descriptor[:actions] <<
|
280
|
-
|
281
|
-
|
282
|
-
|
298
|
+
rule_descriptor[:actions] << if a['action'] == "forward"
|
299
|
+
{
|
300
|
+
:target_group_arn => @targetgroups[a['targetgroup']].target_group_arn,
|
301
|
+
:type => a['action']
|
302
|
+
}
|
303
|
+
elsif a['action'] == "redirect"
|
304
|
+
{
|
305
|
+
:redirect_config => redirect_block.call(rule['redirect']),
|
306
|
+
:type => a['action']
|
307
|
+
}
|
308
|
+
end
|
283
309
|
}
|
284
310
|
MU::Cloud::AWS.elb2(region: @config['region'], credentials: @config['credentials']).create_rule(rule_descriptor)
|
285
311
|
}
|
@@ -288,7 +314,7 @@ module MU
|
|
288
314
|
else
|
289
315
|
@config["listeners"].each { |l|
|
290
316
|
if l['ssl_certificate_id']
|
291
|
-
|
317
|
+
MU::Cloud::AWS.elb(region: @config['region'], credentials: @config['credentials']).set_load_balancer_policies_of_listener(
|
292
318
|
load_balancer_name: @cloud_id,
|
293
319
|
load_balancer_port: l['lb_port'],
|
294
320
|
policy_names: [
|
@@ -330,7 +356,7 @@ module MU
|
|
330
356
|
}
|
331
357
|
)
|
332
358
|
else
|
333
|
-
@targetgroups.
|
359
|
+
@targetgroups.values.each { |tg|
|
334
360
|
MU::Cloud::AWS.elb2(region: @config['region'], credentials: @config['credentials']).modify_target_group_attributes(
|
335
361
|
target_group_arn: tg.target_group_arn,
|
336
362
|
attributes: [
|
@@ -400,7 +426,7 @@ module MU
|
|
400
426
|
timeout = 0
|
401
427
|
MU.log "Disabling connection draining on #{lb.dns_name}"
|
402
428
|
end
|
403
|
-
@targetgroups.
|
429
|
+
@targetgroups.values.each { |tg|
|
404
430
|
MU::Cloud::AWS.elb2(region: @config['region'], credentials: @config['credentials']).modify_target_group_attributes(
|
405
431
|
target_group_arn: tg.target_group_arn,
|
406
432
|
attributes: [
|
@@ -473,7 +499,7 @@ module MU
|
|
473
499
|
end
|
474
500
|
end
|
475
501
|
else
|
476
|
-
@targetgroups.
|
502
|
+
@targetgroups.values.each { |tg|
|
477
503
|
MU::Cloud::AWS.elb2(region: @config['region'], credentials: @config['credentials']).modify_target_group_attributes(
|
478
504
|
target_group_arn: tg.target_group_arn,
|
479
505
|
attributes: [
|
@@ -536,7 +562,7 @@ module MU
|
|
536
562
|
}
|
537
563
|
end
|
538
564
|
if !MU::Cloud::AWS.isGovCloud?
|
539
|
-
MU::Cloud
|
565
|
+
MU::Cloud.resourceClass("AWS", "DNSZone").createRecordsFromConfig(@config['dns_records'], target: cloud_desc.dns_name)
|
540
566
|
end
|
541
567
|
end
|
542
568
|
|
@@ -553,15 +579,18 @@ module MU
|
|
553
579
|
end
|
554
580
|
end
|
555
581
|
|
582
|
+
@cloud_desc_cache = nil
|
556
583
|
# Wrapper for cloud_desc method that deals with elb vs. elb2 resources.
|
557
|
-
def cloud_desc
|
584
|
+
def cloud_desc(use_cache: true)
|
585
|
+
return @cloud_desc_cache if @cloud_desc_cache and use_cache
|
586
|
+
return nil if !@cloud_id
|
558
587
|
if @config['classic']
|
559
|
-
|
588
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb(region: @config['region'], credentials: @config['credentials']).describe_load_balancers(
|
560
589
|
load_balancer_names: [@cloud_id]
|
561
590
|
).load_balancer_descriptions.first
|
562
|
-
return
|
591
|
+
return @cloud_desc_cache
|
563
592
|
else
|
564
|
-
|
593
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb2(region: @config['region'], credentials: @config['credentials']).describe_load_balancers(
|
565
594
|
names: [@cloud_id]
|
566
595
|
).load_balancers.first
|
567
596
|
if @targetgroups.nil? and !@deploy.nil? and
|
@@ -573,7 +602,7 @@ module MU
|
|
573
602
|
}
|
574
603
|
end
|
575
604
|
|
576
|
-
return
|
605
|
+
return @cloud_desc_cache
|
577
606
|
end
|
578
607
|
end
|
579
608
|
|
@@ -643,8 +672,8 @@ module MU
|
|
643
672
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
644
673
|
# @param region [String]: The cloud provider region
|
645
674
|
# @return [void]
|
646
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
647
|
-
if (
|
675
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
676
|
+
if (deploy_id.nil? or deploy_id.empty?) and (!flags or !flags["vpc_id"])
|
648
677
|
raise MuError, "Can't touch ELBs without MU-ID or vpc_id flag"
|
649
678
|
end
|
650
679
|
|
@@ -654,7 +683,7 @@ module MU
|
|
654
683
|
# @param region [String]: The cloud provider region
|
655
684
|
# @param ignoremaster [Boolean]: Whether to ignore the MU-MASTER-IP tag
|
656
685
|
# @param classic [Boolean]: Whether to look for a classic ELB instead of an ALB (ELB2)
|
657
|
-
def self.checkForTagMatch(arn, region, ignoremaster, credentials, classic = false)
|
686
|
+
def self.checkForTagMatch(arn, region, ignoremaster, credentials, classic = false, deploy_id: MU.deploy_id)
|
658
687
|
tags = []
|
659
688
|
if classic
|
660
689
|
tags = MU::Cloud::AWS.elb(credentials: credentials, region: region).describe_tags(
|
@@ -671,7 +700,7 @@ module MU
|
|
671
700
|
if !tags.nil?
|
672
701
|
tags.each { |tag|
|
673
702
|
saw_tags << tag.key
|
674
|
-
muid_match = true if tag.key == "MU-ID" and tag.value ==
|
703
|
+
muid_match = true if tag.key == "MU-ID" and tag.value == deploy_id
|
675
704
|
mumaster_match = true if tag.key == "MU-MASTER-IP" and tag.value == MU.mu_public_ip
|
676
705
|
}
|
677
706
|
end
|
@@ -692,20 +721,19 @@ module MU
|
|
692
721
|
classic = false
|
693
722
|
end
|
694
723
|
begin
|
695
|
-
tags = []
|
696
724
|
matched = false
|
697
725
|
if flags and flags['vpc_id']
|
698
726
|
matched = true if lb.vpc_id == flags['vpc_id']
|
699
727
|
else
|
700
728
|
if classic
|
701
|
-
matched = self.checkForTagMatch(lb.load_balancer_name, region, ignoremaster, credentials, classic)
|
729
|
+
matched = self.checkForTagMatch(lb.load_balancer_name, region, ignoremaster, credentials, classic, deploy_id: deploy_id)
|
702
730
|
else
|
703
|
-
matched = self.checkForTagMatch(lb.load_balancer_arn, region, ignoremaster, credentials, classic)
|
731
|
+
matched = self.checkForTagMatch(lb.load_balancer_arn, region, ignoremaster, credentials, classic, deploy_id: deploy_id)
|
704
732
|
end
|
705
733
|
end
|
706
734
|
if matched
|
707
735
|
if !MU::Cloud::AWS.isGovCloud?
|
708
|
-
MU::Cloud
|
736
|
+
MU::Cloud.resourceClass("AWS", "DNSZone").genericMuDNSEntry(name: lb.load_balancer_name, target: lb.dns_name, cloudclass: MU::Cloud::LoadBalancer, delete: true) if !noop
|
709
737
|
end
|
710
738
|
if classic
|
711
739
|
MU.log "Removing Elastic Load Balancer #{lb.load_balancer_name}"
|
@@ -746,7 +774,7 @@ module MU
|
|
746
774
|
|
747
775
|
|
748
776
|
tgs.each { |tg|
|
749
|
-
if self.checkForTagMatch(tg.target_group_arn, region, ignoremaster, credentials)
|
777
|
+
if self.checkForTagMatch(tg.target_group_arn, region, ignoremaster, credentials, deploy_id: deploy_id)
|
750
778
|
MU.log "Removing Load Balancer Target Group #{tg.target_group_name}"
|
751
779
|
retries = 0
|
752
780
|
begin
|
@@ -773,9 +801,9 @@ module MU
|
|
773
801
|
end
|
774
802
|
|
775
803
|
# Cloud-specific configuration properties.
|
776
|
-
# @param
|
804
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
777
805
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
778
|
-
def self.schema(
|
806
|
+
def self.schema(_config)
|
779
807
|
toplevel_required = []
|
780
808
|
schema = {
|
781
809
|
"targetgroups" => {
|
@@ -792,35 +820,16 @@ module MU
|
|
792
820
|
}
|
793
821
|
}
|
794
822
|
},
|
795
|
-
"ingress_rules" =>
|
796
|
-
"items" => {
|
797
|
-
"properties" => {
|
798
|
-
"sgs" => {
|
799
|
-
"type" => "array",
|
800
|
-
"items" => {
|
801
|
-
"description" => "Other AWS Security Groups; resources that are associated with this group will have this rule applied to their traffic",
|
802
|
-
"type" => "string"
|
803
|
-
}
|
804
|
-
},
|
805
|
-
"lbs" => {
|
806
|
-
"type" => "array",
|
807
|
-
"items" => {
|
808
|
-
"description" => "AWS Load Balancers which will have this rule applied to their traffic",
|
809
|
-
"type" => "string"
|
810
|
-
}
|
811
|
-
}
|
812
|
-
}
|
813
|
-
}
|
814
|
-
}
|
823
|
+
"ingress_rules" => MU::Cloud.resourceClass("AWS", "FirewallRule").ingressRuleAddtlSchema
|
815
824
|
}
|
816
825
|
[toplevel_required, schema]
|
817
826
|
end
|
818
827
|
|
819
828
|
# Cloud-specific pre-processing of {MU::Config::BasketofKittens::loadbalancers}, bare and unvalidated.
|
820
829
|
# @param lb [Hash]: The resource to process and validate
|
821
|
-
# @param
|
830
|
+
# @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
|
822
831
|
# @return [Boolean]: True if validation succeeded, False otherwise
|
823
|
-
def self.validateConfig(lb,
|
832
|
+
def self.validateConfig(lb, _configurator)
|
824
833
|
ok = true
|
825
834
|
|
826
835
|
# XXX what about raw targetgroup ssl declarations?
|
@@ -829,8 +838,8 @@ module MU
|
|
829
838
|
(!listener["ssl_certificate_id"].nil? and !listener["ssl_certificate_id"].empty?)
|
830
839
|
if lb['cloud'] != "CloudFormation" # XXX or maybe do this anyway?
|
831
840
|
begin
|
832
|
-
listener["ssl_certificate_id"] = MU::Cloud::AWS.findSSLCertificate(name: listener["ssl_certificate_name"].to_s, id: listener["ssl_certificate_id"].to_s, region: lb['region'])
|
833
|
-
rescue MuError
|
841
|
+
listener["ssl_certificate_id"] = MU::Cloud::AWS.findSSLCertificate(name: listener["ssl_certificate_name"].to_s, id: listener["ssl_certificate_id"].to_s, region: lb['region']).first
|
842
|
+
rescue MuError
|
834
843
|
ok = false
|
835
844
|
next
|
836
845
|
end
|
@@ -922,6 +931,7 @@ module MU
|
|
922
931
|
return matches
|
923
932
|
|
924
933
|
end
|
934
|
+
|
925
935
|
end
|
926
936
|
end
|
927
937
|
end
|
@@ -202,11 +202,14 @@ module MU
|
|
202
202
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
203
203
|
# @param region [String]: The cloud provider region
|
204
204
|
# @return [void]
|
205
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
205
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
206
|
+
MU.log "AWS::Log.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
207
|
+
MU.log "Placeholder: AWS Log artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
|
208
|
+
|
206
209
|
log_groups = self.find(credentials: credentials, region: region).values
|
207
210
|
if !log_groups.empty?
|
208
211
|
log_groups.each{ |lg|
|
209
|
-
if lg.log_group_name.match(
|
212
|
+
if lg.log_group_name.match(deploy_id)
|
210
213
|
log_streams = MU::Cloud::AWS.cloudwatchlogs(credentials: credentials, region: region).describe_log_streams(log_group_name: lg.log_group_name).log_streams
|
211
214
|
if !log_streams.empty?
|
212
215
|
log_streams.each{ |ls|
|
@@ -227,13 +230,13 @@ module MU
|
|
227
230
|
}
|
228
231
|
end
|
229
232
|
|
230
|
-
unless noop
|
231
|
-
MU::Cloud::AWS.iam(credentials: credentials).list_roles.roles.each{ |role|
|
232
|
-
match_string = "#{
|
233
|
-
# Maybe we should have a more generic way to delete IAM profiles and policies. The call itself should be moved from MU::Cloud
|
234
|
-
# MU::Cloud
|
235
|
-
}
|
236
|
-
end
|
233
|
+
# unless noop
|
234
|
+
# MU::Cloud::AWS.iam(credentials: credentials).list_roles.roles.each{ |role|
|
235
|
+
# match_string = "#{deploy_id}.*CloudTrail"
|
236
|
+
# Maybe we should have a more generic way to delete IAM profiles and policies. The call itself should be moved from MU::Cloud.resourceClass("AWS", "Server").
|
237
|
+
# MU::Cloud.resourceClass("AWS", "Server").removeIAMProfile(role.role_name) if role.role_name.match(match_string)
|
238
|
+
# }
|
239
|
+
# end
|
237
240
|
end
|
238
241
|
|
239
242
|
# Locate an existing log group.
|
@@ -264,7 +267,7 @@ module MU
|
|
264
267
|
# Reverse-map our cloud description into a runnable config hash.
|
265
268
|
# We assume that any values we have in +@config+ are placeholders, and
|
266
269
|
# calculate our own accordingly based on what's live in the cloud.
|
267
|
-
def toKitten(
|
270
|
+
def toKitten(**_args)
|
268
271
|
bok = {
|
269
272
|
"cloud" => "AWS",
|
270
273
|
"credentials" => @config['credentials'],
|
@@ -304,9 +307,9 @@ module MU
|
|
304
307
|
|
305
308
|
|
306
309
|
# Cloud-specific configuration properties.
|
307
|
-
# @param
|
310
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
308
311
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
309
|
-
def self.schema(
|
312
|
+
def self.schema(_config)
|
310
313
|
toplevel_required = []
|
311
314
|
schema = {
|
312
315
|
"retention_period" => {
|
@@ -357,9 +360,9 @@ module MU
|
|
357
360
|
|
358
361
|
# Cloud-specific pre-processing of {MU::Config::BasketofKittens::logs}, bare and unvalidated.
|
359
362
|
# @param log [Hash]: The resource to process and validate
|
360
|
-
# @param
|
363
|
+
# @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
|
361
364
|
# @return [Boolean]: True if validation succeeded, False otherwise
|
362
|
-
def self.validateConfig(log,
|
365
|
+
def self.validateConfig(log, _configurator)
|
363
366
|
ok = true
|
364
367
|
|
365
368
|
if log["filters"] && !log["filters"].empty?
|
@@ -53,14 +53,14 @@ module MU
|
|
53
53
|
new_attrs = genQueueAttrs
|
54
54
|
|
55
55
|
changed = false
|
56
|
-
new_attrs.each_pair { |k,
|
56
|
+
new_attrs.each_pair { |k, _v|
|
57
57
|
if !cur_attrs.has_key?(k) or cur_attrs[k] != new_attrs[k]
|
58
58
|
changed = true
|
59
59
|
end
|
60
60
|
}
|
61
61
|
if changed
|
62
62
|
MU.log "Updating SQS queue #{@mu_name}", MU::NOTICE, details: new_attrs
|
63
|
-
|
63
|
+
MU::Cloud::AWS.sqs(region: @config['region'], credentials: @config['credentials']).set_queue_attributes(
|
64
64
|
queue_url: @cloud_id,
|
65
65
|
attributes: new_attrs
|
66
66
|
)
|
@@ -74,10 +74,14 @@ module MU
|
|
74
74
|
"arn:"+(MU::Cloud::AWS.isGovCloud?(@config["region"]) ? "aws-us-gov" : "aws")+":sqs:"+@config['region']+":"+MU::Cloud::AWS.credToAcct(@config['credentials'])+":"+@cloud_id
|
75
75
|
end
|
76
76
|
|
77
|
+
@cloud_desc_cache = nil
|
77
78
|
# Retrieve the AWS descriptor for this SQS queue. AWS doesn't exactly
|
78
79
|
# provide one; if you want real information for SQS ask notify()
|
79
80
|
# @return [Hash]: AWS doesn't return anything but the SQS URL, so supplement with attributes
|
80
|
-
def cloud_desc
|
81
|
+
def cloud_desc(use_cache: true)
|
82
|
+
return @cloud_desc_cache if @cloud_desc_cache and use_cache
|
83
|
+
return nil if !@cloud_id
|
84
|
+
|
81
85
|
if !@cloud_id
|
82
86
|
resp = MU::Cloud::AWS.sqs(region: @config['region'], credentials: @config['credentials']).list_queues(
|
83
87
|
queue_name_prefix: @mu_name
|
@@ -92,11 +96,12 @@ module MU
|
|
92
96
|
end
|
93
97
|
|
94
98
|
return nil if !@cloud_id
|
95
|
-
MU::Cloud::AWS::MsgQueue.find(
|
99
|
+
@cloud_desc_cache = MU::Cloud::AWS::MsgQueue.find(
|
96
100
|
cloud_id: @cloud_id.dup,
|
97
101
|
region: @config['region'],
|
98
102
|
credentials: @config['credentials']
|
99
103
|
)
|
104
|
+
@cloud_desc_cache
|
100
105
|
end
|
101
106
|
|
102
107
|
# Return the metadata for this MsgQueue rule
|
@@ -129,9 +134,12 @@ module MU
|
|
129
134
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
130
135
|
# @param region [String]: The cloud provider region
|
131
136
|
# @return [void]
|
132
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
137
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
138
|
+
MU.log "AWS::MsgQueue.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
139
|
+
MU.log "Placeholder: AWS MsgQueue artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
|
140
|
+
|
133
141
|
resp = MU::Cloud::AWS.sqs(credentials: credentials, region: region).list_queues(
|
134
|
-
queue_name_prefix:
|
142
|
+
queue_name_prefix: deploy_id
|
135
143
|
)
|
136
144
|
if resp and resp.queue_urls
|
137
145
|
threads = []
|
@@ -182,12 +190,20 @@ module MU
|
|
182
190
|
args[:cloud_id] = resp.queue_url if resp and resp.queue_url
|
183
191
|
end
|
184
192
|
end
|
185
|
-
rescue ::Aws::SQS::Errors::NonExistentQueue
|
193
|
+
rescue ::Aws::SQS::Errors::NonExistentQueue
|
186
194
|
end
|
187
195
|
|
188
196
|
# Go fetch its attributes
|
189
197
|
fetch = if args[:cloud_id]
|
190
|
-
|
198
|
+
if args[:cloud_id] !~ /^https?:\/\//
|
199
|
+
[begin
|
200
|
+
MU::Cloud::AWS.sqs(region: args[:region], credentials: args[:credentials]).get_queue_url(queue_name: args[:cloud_id]).queue_url
|
201
|
+
rescue Aws::SQS::Errors::NonExistentQueue
|
202
|
+
return found
|
203
|
+
end]
|
204
|
+
else
|
205
|
+
[args[:cloud_id]]
|
206
|
+
end
|
191
207
|
else
|
192
208
|
resp = MU::Cloud::AWS.sqs(region: args[:region], credentials: args[:credentials]).list_queues
|
193
209
|
resp.queue_urls
|
@@ -211,9 +227,9 @@ module MU
|
|
211
227
|
end
|
212
228
|
|
213
229
|
# Cloud-specific configuration properties.
|
214
|
-
# @param
|
230
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
215
231
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
216
|
-
def self.schema(
|
232
|
+
def self.schema(_config)
|
217
233
|
toplevel_required = []
|
218
234
|
schema = {
|
219
235
|
"max_msg_size" => {
|
@@ -320,16 +336,10 @@ module MU
|
|
320
336
|
failq.delete("failqueue")
|
321
337
|
ok = false if !configurator.insertKitten(failq, "msg_queues")
|
322
338
|
queue['failqueue']['name'] = failq['name']
|
323
|
-
queue[
|
324
|
-
"name" => failq['name'],
|
325
|
-
"type" => "msg_queue"
|
326
|
-
}
|
339
|
+
MU::Config.addDependency(queue, failq["name"], "msg_queue")
|
327
340
|
else
|
328
341
|
if configurator.haveLitterMate?(queue['failqueue']['name'], "msg_queue")
|
329
|
-
queue['
|
330
|
-
"name" => queue['failqueue']['name'],
|
331
|
-
"type" => "msg_queue"
|
332
|
-
}
|
342
|
+
MU::Config.addDependency(queue, queue['failqueue']['name'], "msg_queue")
|
333
343
|
else
|
334
344
|
failq = MU::Cloud::AWS::MsgQueue.find(cloud_id: queue['failqueue']['name'])
|
335
345
|
if !failq
|
@@ -382,7 +392,7 @@ module MU
|
|
382
392
|
end
|
383
393
|
begin
|
384
394
|
MU::Cloud::AWS.kms(region: queue['region']).describe_key(key_id: queue['kms']['key_id'])
|
385
|
-
rescue Aws::KMS::Errors::NotFoundException
|
395
|
+
rescue Aws::KMS::Errors::NotFoundException
|
386
396
|
MU.log "KMS key '#{queue['kms']['key_id']}' specified in Queue '#{queue['name']}' was not found.", MU::ERR, details: "Key IDs are of the form bf64a093-2c3d-46fa-0d4f-8232fa7ed53. Keys can be created at https://console.aws.amazon.com/iam/home#/encryptionKeys/#{queue['region']}"
|
387
397
|
ok = false
|
388
398
|
end
|