cloud-mu 3.0.0beta → 3.0.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/README.md +17 -8
- data/ansible/roles/mu-nat/README.md +33 -0
- data/ansible/roles/mu-nat/defaults/main.yml +3 -0
- data/ansible/roles/mu-nat/handlers/main.yml +2 -0
- data/ansible/roles/mu-nat/meta/main.yml +60 -0
- data/ansible/roles/mu-nat/tasks/main.yml +65 -0
- data/ansible/roles/mu-nat/tests/inventory +2 -0
- data/ansible/roles/mu-nat/tests/test.yml +5 -0
- data/ansible/roles/mu-nat/vars/main.yml +2 -0
- data/bin/mu-cleanup +2 -1
- data/bin/mu-configure +950 -948
- data/bin/mu-gen-docs +6 -0
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-tools/recipes/gcloud.rb +8 -1
- data/modules/mommacat.ru +1 -1
- data/modules/mu.rb +31 -39
- data/modules/mu/cloud.rb +11 -1
- data/modules/mu/clouds/aws.rb +8 -3
- data/modules/mu/clouds/aws/alarm.rb +5 -8
- data/modules/mu/clouds/aws/bucket.rb +15 -9
- data/modules/mu/clouds/aws/cache_cluster.rb +60 -26
- data/modules/mu/clouds/aws/collection.rb +4 -4
- data/modules/mu/clouds/aws/container_cluster.rb +50 -33
- data/modules/mu/clouds/aws/database.rb +25 -21
- data/modules/mu/clouds/aws/dnszone.rb +12 -14
- data/modules/mu/clouds/aws/endpoint.rb +5 -8
- data/modules/mu/clouds/aws/firewall_rule.rb +9 -4
- data/modules/mu/clouds/aws/folder.rb +4 -7
- data/modules/mu/clouds/aws/function.rb +5 -8
- data/modules/mu/clouds/aws/group.rb +5 -8
- data/modules/mu/clouds/aws/habitat.rb +2 -5
- data/modules/mu/clouds/aws/loadbalancer.rb +12 -16
- data/modules/mu/clouds/aws/log.rb +6 -9
- data/modules/mu/clouds/aws/msg_queue.rb +16 -19
- data/modules/mu/clouds/aws/nosqldb.rb +27 -18
- data/modules/mu/clouds/aws/notifier.rb +6 -9
- data/modules/mu/clouds/aws/role.rb +4 -7
- data/modules/mu/clouds/aws/search_domain.rb +50 -23
- data/modules/mu/clouds/aws/server.rb +20 -14
- data/modules/mu/clouds/aws/server_pool.rb +22 -12
- data/modules/mu/clouds/aws/storage_pool.rb +9 -14
- data/modules/mu/clouds/aws/user.rb +5 -8
- data/modules/mu/clouds/aws/userdata/linux.erb +7 -1
- data/modules/mu/clouds/aws/vpc.rb +16 -14
- data/modules/mu/clouds/azure.rb +1 -1
- data/modules/mu/clouds/azure/container_cluster.rb +1 -1
- data/modules/mu/clouds/azure/server.rb +16 -2
- data/modules/mu/clouds/azure/user.rb +1 -1
- data/modules/mu/clouds/azure/userdata/linux.erb +84 -80
- data/modules/mu/clouds/azure/vpc.rb +32 -13
- data/modules/mu/clouds/cloudformation/server.rb +1 -1
- data/modules/mu/clouds/google.rb +2 -3
- data/modules/mu/clouds/google/container_cluster.rb +9 -1
- data/modules/mu/clouds/google/firewall_rule.rb +6 -0
- data/modules/mu/clouds/google/role.rb +1 -3
- data/modules/mu/clouds/google/server.rb +25 -4
- data/modules/mu/clouds/google/user.rb +1 -1
- data/modules/mu/clouds/google/userdata/linux.erb +9 -5
- data/modules/mu/clouds/google/vpc.rb +102 -21
- data/modules/mu/config.rb +250 -49
- data/modules/mu/config/alarm.rb +1 -0
- data/modules/mu/config/container_cluster.yml +0 -1
- data/modules/mu/config/database.yml +4 -1
- data/modules/mu/config/search_domain.yml +4 -3
- data/modules/mu/config/server.rb +7 -3
- data/modules/mu/config/server.yml +4 -1
- data/modules/mu/config/server_pool.yml +2 -0
- data/modules/mu/config/vpc.rb +42 -29
- data/modules/mu/deploy.rb +12 -5
- data/modules/mu/groomers/ansible.rb +4 -1
- data/modules/mu/groomers/chef.rb +5 -1
- data/modules/mu/kittens.rb +60 -11
- data/modules/mu/logger.rb +6 -4
- data/modules/mu/mommacat.rb +39 -19
- data/modules/mu/mu.yaml.rb +276 -0
- metadata +13 -4
@@ -297,13 +297,13 @@ module MU
|
|
297
297
|
end
|
298
298
|
|
299
299
|
# placeholder
|
300
|
-
def self.find(
|
300
|
+
def self.find(**args)
|
301
301
|
found = nil
|
302
|
-
resp = MU::Cloud::AWS.cloudformation(region: region, credentials: credentials).describe_stacks(
|
303
|
-
stack_name: cloud_id
|
302
|
+
resp = MU::Cloud::AWS.cloudformation(region: args[:region], credentials: args[:credentials]).describe_stacks(
|
303
|
+
stack_name: args[:cloud_id]
|
304
304
|
)
|
305
305
|
if resp and resp.stacks
|
306
|
-
found[cloud_id] = resp.stacks.first
|
306
|
+
found[args[:cloud_id]] = resp.stacks.first
|
307
307
|
end
|
308
308
|
|
309
309
|
found
|
@@ -213,7 +213,7 @@ module MU
|
|
213
213
|
)
|
214
214
|
end
|
215
215
|
|
216
|
-
MU.log %Q{How to interact with your
|
216
|
+
MU.log %Q{How to interact with your EKS cluster\nkubectl --kubeconfig "#{kube_conf}" get all\nkubectl --kubeconfig "#{kube_conf}" create -f some_k8s_deploy.yml\nkubectl --kubeconfig "#{kube_conf}" get nodes}, MU::SUMMARY
|
217
217
|
elsif @config['flavor'] != "Fargate"
|
218
218
|
resp = MU::Cloud::AWS.ecs(region: @config['region'], credentials: @config['credentials']).list_container_instances({
|
219
219
|
cluster: @mu_name
|
@@ -495,12 +495,28 @@ module MU
|
|
495
495
|
if @config['vpc']
|
496
496
|
subnet_ids = []
|
497
497
|
all_public = true
|
498
|
-
|
499
|
-
|
500
|
-
|
498
|
+
|
499
|
+
subnets =
|
500
|
+
if @config["vpc"]["subnets"].empty?
|
501
|
+
@vpc.subnets
|
502
|
+
else
|
503
|
+
subnet_objects= []
|
504
|
+
@config["vpc"]["subnets"].each { |subnet|
|
505
|
+
sobj = @vpc.getSubnet(cloud_id: subnet["subnet_id"], name: subnet["subnet_name"])
|
506
|
+
if sobj.nil?
|
507
|
+
MU.log "Got nil result from @vpc.getSubnet(cloud_id: #{subnet["subnet_id"]}, name: #{subnet["subnet_name"]})", MU::WARN
|
508
|
+
else
|
509
|
+
subnet_objects << sobj
|
510
|
+
end
|
511
|
+
}
|
512
|
+
subnet_objects
|
513
|
+
end
|
514
|
+
|
515
|
+
subnets.each { |subnet_obj|
|
501
516
|
subnet_ids << subnet_obj.cloud_id
|
502
517
|
all_public = false if subnet_obj.private?
|
503
518
|
}
|
519
|
+
|
504
520
|
service_params[:network_configuration] = {
|
505
521
|
:awsvpc_configuration => {
|
506
522
|
:subnets => subnet_ids,
|
@@ -905,15 +921,10 @@ MU.log c.name, MU::NOTICE, details: t
|
|
905
921
|
end
|
906
922
|
|
907
923
|
# Locate an existing container_clusters.
|
908
|
-
# @
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
def self.find(cloud_id: nil, region: MU.curRegion, credentials: nil, flags: {})
|
913
|
-
MU.log cloud_id, MU::WARN, details: flags
|
914
|
-
MU.log region, MU::WARN
|
915
|
-
resp = MU::Cloud::AWS.ecs(region: region, credentials: credentials).list_clusters
|
916
|
-
resp = MU::Cloud::AWS.eks(region: region, credentials: credentials).list_clusters
|
924
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching container_clusters.
|
925
|
+
def self.find(**args)
|
926
|
+
resp = MU::Cloud::AWS.ecs(region: args[:region], credentials: args[:credentials]).list_clusters
|
927
|
+
resp = MU::Cloud::AWS.eks(region: args[:region], credentials: args[:credentials]).list_clusters
|
917
928
|
# XXX uh, this ain't complete
|
918
929
|
end
|
919
930
|
|
@@ -1528,6 +1539,32 @@ MU.log c.name, MU::NOTICE, details: t
|
|
1528
1539
|
ok = false
|
1529
1540
|
end
|
1530
1541
|
|
1542
|
+
if ["Fargate", "EKS"].include?(cluster["flavor"]) and !cluster["vpc"]
|
1543
|
+
siblings = configurator.haveLitterMate?(nil, "vpcs", has_multiple: true)
|
1544
|
+
if siblings.size == 1
|
1545
|
+
MU.log "ContainerCluster #{cluster['name']} did not declare a VPC. Inserting into sibling VPC #{siblings[0]['name']}.", MU::WARN
|
1546
|
+
cluster["vpc"] = {
|
1547
|
+
"name" => siblings[0]['name'],
|
1548
|
+
"subnet_pref" => "all_private"
|
1549
|
+
}
|
1550
|
+
elsif MU::Cloud::AWS.hosted? and MU::Cloud::AWS.myVPCObj
|
1551
|
+
cluster["vpc"] = {
|
1552
|
+
"id" => MU.myVPC,
|
1553
|
+
"subnet_pref" => "all_private"
|
1554
|
+
}
|
1555
|
+
else
|
1556
|
+
MU.log "ContainerCluster #{cluster['name']} must declare a VPC", MU::ERR
|
1557
|
+
ok = false
|
1558
|
+
end
|
1559
|
+
|
1560
|
+
# Re-insert ourselves with this modification so that our child
|
1561
|
+
# resources get this VPC we just shoved in
|
1562
|
+
if ok and cluster['vpc']
|
1563
|
+
cluster.delete("#MU_VALIDATED")
|
1564
|
+
return configurator.insertKitten(cluster, "container_clusters", overwrite: true)
|
1565
|
+
end
|
1566
|
+
end
|
1567
|
+
|
1531
1568
|
if cluster["volumes"]
|
1532
1569
|
cluster["volumes"].each { |v|
|
1533
1570
|
if v["type"] == "docker"
|
@@ -1627,26 +1664,6 @@ MU.log c.name, MU::NOTICE, details: t
|
|
1627
1664
|
ok = false
|
1628
1665
|
end
|
1629
1666
|
|
1630
|
-
if cluster["flavor"] == "EKS" and !cluster["vpc"]
|
1631
|
-
if !MU::Cloud::AWS.hosted? or !MU::Cloud::AWS.myVPCObj
|
1632
|
-
siblings = configurator.haveLitterMate?(nil, "vpcs", has_multiple: true)
|
1633
|
-
if siblings.size == 1
|
1634
|
-
MU.log "EKS cluster #{cluster['name']} did not declare a VPC. Inserting into an available sibling VPC.", MU::WARN
|
1635
|
-
cluster["vpc"] = {
|
1636
|
-
"name" => siblings[0]['name'],
|
1637
|
-
"subnet_pref" => "all_private"
|
1638
|
-
}
|
1639
|
-
else
|
1640
|
-
MU.log "EKS cluster #{cluster['name']} must declare a VPC", MU::ERR
|
1641
|
-
ok = false
|
1642
|
-
end
|
1643
|
-
else
|
1644
|
-
cluster["vpc"] = {
|
1645
|
-
"id" => MU.myVPC,
|
1646
|
-
"subnet_pref" => "all_private"
|
1647
|
-
}
|
1648
|
-
end
|
1649
|
-
end
|
1650
1667
|
|
1651
1668
|
if ["ECS", "EKS"].include?(cluster["flavor"])
|
1652
1669
|
std_ami = getStandardImage(cluster["flavor"], cluster['region'], version: cluster['kubernetes']['version'], gpu: cluster['gpu'])
|
@@ -164,27 +164,22 @@ module MU
|
|
164
164
|
|
165
165
|
|
166
166
|
# Locate an existing Database or Databases and return an array containing matching AWS resource descriptors for those that match.
|
167
|
-
# @
|
168
|
-
|
169
|
-
# @param tag_key [String]: A tag key to search.
|
170
|
-
# @param tag_value [String]: The value of the tag specified by tag_key to match when searching by tag.
|
171
|
-
# @param flags [Hash]: Optional flags
|
172
|
-
# @return [Array<Hash<String,OpenStruct>>]: The cloud provider's complete descriptions of matching Databases
|
173
|
-
def self.find(cloud_id: nil, region: MU.curRegion, tag_key: "Name", tag_value: nil, credentials: nil, flags: {})
|
167
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching Databases
|
168
|
+
def self.find(**args)
|
174
169
|
map = {}
|
175
|
-
if cloud_id
|
176
|
-
resp = MU::Cloud::AWS::Database.getDatabaseById(cloud_id, region: region, credentials: credentials)
|
177
|
-
map[cloud_id] = resp if resp
|
170
|
+
if args[:cloud_id]
|
171
|
+
resp = MU::Cloud::AWS::Database.getDatabaseById(args[:cloud_id], region: args[:region], credentials: args[:credentials])
|
172
|
+
map[args[:cloud_id]] = resp if resp
|
178
173
|
end
|
179
174
|
|
180
|
-
if tag_value
|
181
|
-
MU::Cloud::AWS.rds(credentials: credentials, region: region).describe_db_instances.db_instances.each { |db|
|
182
|
-
resp = MU::Cloud::AWS.rds(credentials: credentials, region: region).list_tags_for_resource(
|
183
|
-
resource_name: MU::Cloud::AWS::Database.getARN(db.db_instance_identifier, "db", "rds", region: region, credentials: credentials)
|
175
|
+
if args[:tag_value]
|
176
|
+
MU::Cloud::AWS.rds(credentials: args[:credentials], region: args[:region]).describe_db_instances.db_instances.each { |db|
|
177
|
+
resp = MU::Cloud::AWS.rds(credentials: args[:credentials], region: args[:region]).list_tags_for_resource(
|
178
|
+
resource_name: MU::Cloud::AWS::Database.getARN(db.db_instance_identifier, "db", "rds", region: args[:region], credentials: args[:credentials])
|
184
179
|
)
|
185
180
|
if resp && resp.tag_list && !resp.tag_list.empty?
|
186
181
|
resp.tag_list.each { |tag|
|
187
|
-
map[db.db_instance_identifier] = db if tag.key == tag_key and tag.value == tag_value
|
182
|
+
map[db.db_instance_identifier] = db if tag.key == args[:tag_key] and tag.value == args[:tag_value]
|
188
183
|
}
|
189
184
|
end
|
190
185
|
}
|
@@ -370,7 +365,7 @@ module MU
|
|
370
365
|
# Does create_db_instance implement wait_until_available ?
|
371
366
|
waiter.max_attempts = nil
|
372
367
|
waiter.before_attempt do |w_attempts|
|
373
|
-
MU.log "Waiting for RDS database #{@config['identifier']} to be ready
|
368
|
+
MU.log "Waiting for RDS database #{@config['identifier']} to be ready...", MU::NOTICE if w_attempts % 10 == 0
|
374
369
|
end
|
375
370
|
waiter.before_wait do |w_attempts, r|
|
376
371
|
throw :success if r.db_instances.first.db_instance_status == "available"
|
@@ -457,6 +452,14 @@ module MU
|
|
457
452
|
# Maybe wait for DB instance to be in available state. DB should still be writeable at this state
|
458
453
|
if @config['allow_major_version_upgrade'] && @config["creation_style"] == "new"
|
459
454
|
MU.log "Setting major database version upgrade on #{@config['identifier']}'"
|
455
|
+
database = MU::Cloud::AWS::Database.getDatabaseById(@config['identifier'], region: @config['region'], credentials: @config['credentials'])
|
456
|
+
begin
|
457
|
+
if database.db_instance_status != "available"
|
458
|
+
sleep 5
|
459
|
+
database = MU::Cloud::AWS::Database.getDatabaseById(@config['identifier'], region: @config['region'], credentials: @config['credentials'])
|
460
|
+
end
|
461
|
+
end while database.db_instance_status != "available"
|
462
|
+
|
460
463
|
MU::Cloud::AWS.rds(region: @config['region'], credentials: @config['credentials']).modify_db_instance(
|
461
464
|
db_instance_identifier: @config['identifier'],
|
462
465
|
apply_immediately: true,
|
@@ -611,11 +614,8 @@ module MU
|
|
611
614
|
|
612
615
|
subnets.each{ |subnet|
|
613
616
|
next if subnet.nil?
|
614
|
-
if @config["publicly_accessible"]
|
615
|
-
|
616
|
-
elsif !@config["publicly_accessible"]
|
617
|
-
subnet_ids << subnet.cloud_id if subnet.private?
|
618
|
-
end
|
617
|
+
next if @config["publicly_accessible"] and subnet.private?
|
618
|
+
subnet_ids << subnet.cloud_id
|
619
619
|
}
|
620
620
|
else
|
621
621
|
# If we didn't specify a VPC try to figure out if the account has a default VPC
|
@@ -1566,6 +1566,10 @@ module MU
|
|
1566
1566
|
end
|
1567
1567
|
end
|
1568
1568
|
|
1569
|
+
if db['engine'] == "aurora-postgresql"
|
1570
|
+
db.delete('cloudwatch_logs')
|
1571
|
+
end
|
1572
|
+
|
1569
1573
|
if db['engine'].match(/^aurora/) and !db['create_cluster'] and !db['add_cluster_node']
|
1570
1574
|
MU.log "Database #{db['name']}: #{db['engine']} looks like a cluster engine, but create_cluster is not set. Add 'create_cluster: true' if you're building an RDS cluster.", MU::ERR
|
1571
1575
|
ok = false
|
@@ -542,7 +542,8 @@ module MU
|
|
542
542
|
|
543
543
|
if !mu_zone.nil? and !MU.myVPC.nil?
|
544
544
|
subdomain = cloudclass.cfg_name
|
545
|
-
dns_name = name.downcase+"."+subdomain
|
545
|
+
dns_name = name.downcase+"."+subdomain
|
546
|
+
dns_name += "."+MU.myInstanceId if MU.myInstanceId
|
546
547
|
record_type = "CNAME"
|
547
548
|
record_type = "A" if target.match(/^\d+\.\d+\.\d+\.\d+/)
|
548
549
|
ip = nil
|
@@ -869,36 +870,33 @@ module MU
|
|
869
870
|
end
|
870
871
|
|
871
872
|
# Locate an existing DNSZone or DNSZones and return an array containing matching AWS resource descriptors for those that match.
|
872
|
-
# @
|
873
|
-
|
874
|
-
# @param flags [Hash]: Optional flags
|
875
|
-
# @return [Array<Hash<String,OpenStruct>>]: The cloud provider's complete descriptions of matching DNSZones
|
876
|
-
def self.find(cloud_id: nil, deploy_id: MU.deploy_id, region: MU.curRegion, credentials: nil, flags: {})
|
873
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching DNSZones
|
874
|
+
def self.find(**args)
|
877
875
|
matches = {}
|
878
876
|
|
879
|
-
resp = MU::Cloud::AWS.route53(credentials: credentials).list_hosted_zones(
|
877
|
+
resp = MU::Cloud::AWS.route53(credentials: args[:credentials]).list_hosted_zones(
|
880
878
|
max_items: 100
|
881
879
|
)
|
882
880
|
|
883
881
|
resp.hosted_zones.each { |zone|
|
884
|
-
if !cloud_id.nil? and !cloud_id.empty?
|
885
|
-
if zone.id == cloud_id
|
882
|
+
if !args[:cloud_id].nil? and !args[:cloud_id].empty?
|
883
|
+
if zone.id == args[:cloud_id]
|
886
884
|
begin
|
887
|
-
matches[zone.id] = MU::Cloud::AWS.route53(credentials: credentials).get_hosted_zone(id: zone.id).hosted_zone
|
885
|
+
matches[zone.id] = MU::Cloud::AWS.route53(credentials: args[:credentials]).get_hosted_zone(id: zone.id).hosted_zone
|
888
886
|
rescue Aws::Route53::Errors::NoSuchHostedZone
|
889
887
|
MU.log "Hosted zone #{zone.id} doesn't exist"
|
890
888
|
end
|
891
|
-
elsif zone.name == cloud_id or zone.name == cloud_id+"."
|
889
|
+
elsif zone.name == args[:cloud_id] or zone.name == args[:cloud_id]+"."
|
892
890
|
begin
|
893
|
-
matches[zone.id] = MU::Cloud::AWS.route53(credentials: credentials).get_hosted_zone(id: zone.id).hosted_zone
|
891
|
+
matches[zone.id] = MU::Cloud::AWS.route53(credentials: args[:credentials]).get_hosted_zone(id: zone.id).hosted_zone
|
894
892
|
rescue Aws::Route53::Errors::NoSuchHostedZone
|
895
893
|
MU.log "Hosted zone #{zone.id} doesn't exist"
|
896
894
|
end
|
897
895
|
end
|
898
896
|
end
|
899
|
-
if !deploy_id.nil? and !deploy_id.empty? and zone.config.comment == deploy_id
|
897
|
+
if !args[:deploy_id].nil? and !args[:deploy_id].empty? and zone.config.comment == args[:deploy_id]
|
900
898
|
begin
|
901
|
-
matches[zone.id] = MU::Cloud::AWS.route53(credentials: credentials).get_hosted_zone(id: zone.id).hosted_zone
|
899
|
+
matches[zone.id] = MU::Cloud::AWS.route53(credentials: args[:credentials]).get_hosted_zone(id: zone.id).hosted_zone
|
902
900
|
rescue Aws::Route53::Errors::NoSuchHostedZone
|
903
901
|
MU.log "Hosted zone #{zone.id} doesn't exist"
|
904
902
|
end
|
@@ -256,14 +256,11 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
|
|
256
256
|
end
|
257
257
|
|
258
258
|
# Locate an existing API.
|
259
|
-
# @
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
if cloud_id
|
265
|
-
return MU::Cloud::AWS.apig(region: region, credentials: credentials).get_rest_api(
|
266
|
-
rest_api_id: cloud_id
|
259
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching API.
|
260
|
+
def self.find(**args)
|
261
|
+
if args[:cloud_id]
|
262
|
+
return MU::Cloud::AWS.apig(region: args[:region], credentials: args[:credentials]).get_rest_api(
|
263
|
+
rest_api_id: args[:cloud_id]
|
267
264
|
)
|
268
265
|
end
|
269
266
|
# resp = MU::Cloud::AWS.apig(region: region, credentials: credentials).get_rest_apis
|
@@ -562,10 +562,15 @@ module MU
|
|
562
562
|
rescue Aws::EC2::Errors::InvalidPermissionNotFound => e
|
563
563
|
end
|
564
564
|
end
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
565
|
+
begin
|
566
|
+
MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).authorize_security_group_ingress(
|
567
|
+
group_id: @cloud_id,
|
568
|
+
ip_permissions: [rule]
|
569
|
+
)
|
570
|
+
rescue Aws::EC2::Errors::InvalidParameterCombination => e
|
571
|
+
MU.log "FirewallRule #{@mu_name} had a bogus rule: #{e.message}", MU::ERR, details: rule
|
572
|
+
raise e
|
573
|
+
end
|
569
574
|
end
|
570
575
|
|
571
576
|
if egress
|
@@ -63,16 +63,13 @@ module MU
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Locate an existing AWS organization. If no identifying parameters are specified, this will return a description of the Organization which owns the account for our credentials.
|
66
|
-
# @
|
67
|
-
|
68
|
-
# @param flags [Hash]: Optional flags
|
69
|
-
# @return [OpenStruct]: The cloud provider's complete descriptions of matching log group.
|
70
|
-
def self.find(cloud_id: nil, region: MU.curRegion, credentials: nil, flags: {})
|
66
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching log group.
|
67
|
+
def self.find(**args)
|
71
68
|
found = nil
|
72
69
|
|
73
|
-
if cloud_id
|
70
|
+
if args[:cloud_id]
|
74
71
|
else
|
75
|
-
resp = MU::Cloud::AWS.orgs(credentials: credentials).describe_organization
|
72
|
+
resp = MU::Cloud::AWS.orgs(credentials: args[:credentials]).describe_organization
|
76
73
|
found ||= {}
|
77
74
|
found[resp.organization.id] = resp.organization
|
78
75
|
end
|
@@ -292,17 +292,14 @@ module MU
|
|
292
292
|
end
|
293
293
|
|
294
294
|
# Locate an existing function.
|
295
|
-
# @
|
296
|
-
|
297
|
-
# @param flags [Hash]: Optional flags
|
298
|
-
# @return [OpenStruct]: The cloud provider's complete descriptions of matching function.
|
299
|
-
def self.find(cloud_id: nil, region: MU.curRegion, credentials: nil, flags: {})
|
295
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching function.
|
296
|
+
def self.find(**args)
|
300
297
|
matches = {}
|
301
298
|
|
302
|
-
if !cloud_id.nil?
|
303
|
-
all_functions = MU::Cloud::AWS.lambda(region: region, credentials: credentials).list_functions
|
299
|
+
if !args[:cloud_id].nil?
|
300
|
+
all_functions = MU::Cloud::AWS.lambda(region: args[:region], credentials: args[:credentials]).list_functions
|
304
301
|
all_functions.functions.each do |x|
|
305
|
-
if x.function_name == cloud_id
|
302
|
+
if x.function_name == args[:cloud_id]
|
306
303
|
matches[x.function_name] = x
|
307
304
|
break
|
308
305
|
end
|
@@ -159,18 +159,15 @@ module MU
|
|
159
159
|
end
|
160
160
|
|
161
161
|
# Locate an existing group group.
|
162
|
-
# @
|
163
|
-
|
164
|
-
# @param flags [Hash]: Optional flags
|
165
|
-
# @return [OpenStruct]: The cloud provider's complete descriptions of matching group group.
|
166
|
-
def self.find(cloud_id: nil, region: MU.curRegion, credentials: nil, flags: {})
|
162
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching group group.
|
163
|
+
def self.find(**args)
|
167
164
|
found = nil
|
168
165
|
begin
|
169
|
-
resp = MU::Cloud::AWS.iam(credentials: credentials).get_group(
|
170
|
-
group_name: cloud_id
|
166
|
+
resp = MU::Cloud::AWS.iam(credentials: args[:credentials]).get_group(
|
167
|
+
group_name: args[:cloud_id]
|
171
168
|
)
|
172
169
|
found ||= {}
|
173
|
-
found[cloud_id] = resp
|
170
|
+
found[args[:cloud_id]] = resp
|
174
171
|
rescue Aws::IAM::Errors::NoSuchEntity
|
175
172
|
end
|
176
173
|
found
|
@@ -107,11 +107,8 @@ module MU
|
|
107
107
|
end
|
108
108
|
|
109
109
|
# Locate an existing account
|
110
|
-
# @
|
111
|
-
|
112
|
-
# @param flags [Hash]: Optional flags
|
113
|
-
# @return [OpenStruct]: The cloud provider's complete descriptions of matching account
|
114
|
-
def self.find(cloud_id: nil, region: MU.curRegion, credentials: nil, flags: {})
|
110
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching account
|
111
|
+
def self.find(**args)
|
115
112
|
{}
|
116
113
|
end
|
117
114
|
|
@@ -852,43 +852,39 @@ module MU
|
|
852
852
|
end
|
853
853
|
|
854
854
|
# Locate an existing LoadBalancer or LoadBalancers and return an array containing matching AWS resource descriptors for those that match.
|
855
|
-
# @
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
# @param flags [Hash]: Optional flags
|
860
|
-
# @return [Array<Hash<String,OpenStruct>>]: The cloud provider's complete descriptions of matching LoadBalancers
|
861
|
-
def self.find(cloud_id: nil, region: MU.curRegion, tag_key: "Name", tag_value: nil, credentials: nil, flags: {})
|
862
|
-
classic = flags['classic'] ? true : false
|
855
|
+
# @return [Hash<String,OpenStruct>]: The cloud provider's complete descriptions of matching LoadBalancers
|
856
|
+
def self.find(**args)
|
857
|
+
args[:flags] ||= {}
|
858
|
+
classic = args[:flags]['classic'] ? true : false
|
863
859
|
|
864
860
|
matches = {}
|
865
861
|
list = {}
|
866
862
|
arn2name = {}
|
867
863
|
resp = nil
|
868
864
|
if classic
|
869
|
-
resp = MU::Cloud::AWS.elb(region: region, credentials: credentials).describe_load_balancers().load_balancer_descriptions
|
865
|
+
resp = MU::Cloud::AWS.elb(region: args[:region], credentials: args[:credentials]).describe_load_balancers().load_balancer_descriptions
|
870
866
|
else
|
871
|
-
resp = MU::Cloud::AWS.elb2(region: region, credentials: credentials).describe_load_balancers().load_balancers
|
867
|
+
resp = MU::Cloud::AWS.elb2(region: args[:region], credentials: args[:credentials]).describe_load_balancers().load_balancers
|
872
868
|
end
|
873
869
|
|
874
870
|
resp.each { |lb|
|
875
871
|
list[lb.load_balancer_name] = lb
|
876
872
|
arn2name[lb.load_balancer_arn] = lb.load_balancer_name if !classic
|
877
|
-
if !cloud_id.nil? and lb.load_balancer_name == cloud_id
|
878
|
-
matches[cloud_id] = lb
|
873
|
+
if !args[:cloud_id].nil? and lb.load_balancer_name == args[:cloud_id]
|
874
|
+
matches[args[:cloud_id]] = lb
|
879
875
|
end
|
880
876
|
}
|
881
877
|
|
882
878
|
return matches if matches.size > 0
|
883
879
|
|
884
|
-
if !tag_key.nil? and !tag_value.nil? and !tag_key.empty? and list.size > 0
|
880
|
+
if !args[:tag_key].nil? and !args[:tag_value].nil? and !args[:tag_key].empty? and list.size > 0
|
885
881
|
tag_descriptions = nil
|
886
882
|
if classic
|
887
|
-
tag_descriptions = MU::Cloud::AWS.elb(region: region, credentials: credentials).describe_tags(
|
883
|
+
tag_descriptions = MU::Cloud::AWS.elb(region: args[:region], credentials: args[:credentials]).describe_tags(
|
888
884
|
load_balancer_names: list.keys
|
889
885
|
).tag_descriptions
|
890
886
|
else
|
891
|
-
tag_descriptions = MU::Cloud::AWS.elb2(region: region, credentials: credentials).describe_tags(
|
887
|
+
tag_descriptions = MU::Cloud::AWS.elb2(region: args[:region], credentials: args[:credentials]).describe_tags(
|
892
888
|
resource_arns: list.values.map { |l| l.load_balancer_arn }
|
893
889
|
).tag_descriptions
|
894
890
|
end
|
@@ -896,7 +892,7 @@ module MU
|
|
896
892
|
tag_descriptions.each { |lb|
|
897
893
|
lb_name = classic ? lb.load_balancer_name : arn2name[lb.resource_arn]
|
898
894
|
lb.tags.each { |tag|
|
899
|
-
if tag.key == tag_key and tag.value == tag_value
|
895
|
+
if tag.key == args[:tag_key] and tag.value == args[:tag_value]
|
900
896
|
matches[lb_name] = list[lb_name]
|
901
897
|
end
|
902
898
|
}
|