cloud-mu 3.1.3 → 3.1.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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +10 -2
  3. data/bin/mu-adopt +5 -1
  4. data/bin/mu-load-config.rb +2 -3
  5. data/bin/mu-run-tests +112 -27
  6. data/cloud-mu.gemspec +20 -20
  7. data/cookbooks/mu-tools/libraries/helper.rb +2 -1
  8. data/cookbooks/mu-tools/libraries/monkey.rb +35 -0
  9. data/cookbooks/mu-tools/recipes/google_api.rb +2 -2
  10. data/cookbooks/mu-tools/resources/disk.rb +1 -1
  11. data/extras/image-generators/Google/centos6.yaml +1 -0
  12. data/extras/image-generators/Google/centos7.yaml +1 -1
  13. data/modules/mommacat.ru +5 -15
  14. data/modules/mu.rb +10 -14
  15. data/modules/mu/adoption.rb +20 -14
  16. data/modules/mu/cleanup.rb +13 -9
  17. data/modules/mu/cloud.rb +26 -26
  18. data/modules/mu/clouds/aws.rb +100 -59
  19. data/modules/mu/clouds/aws/alarm.rb +4 -2
  20. data/modules/mu/clouds/aws/bucket.rb +25 -21
  21. data/modules/mu/clouds/aws/cache_cluster.rb +25 -23
  22. data/modules/mu/clouds/aws/collection.rb +21 -20
  23. data/modules/mu/clouds/aws/container_cluster.rb +47 -26
  24. data/modules/mu/clouds/aws/database.rb +57 -68
  25. data/modules/mu/clouds/aws/dnszone.rb +14 -14
  26. data/modules/mu/clouds/aws/endpoint.rb +20 -16
  27. data/modules/mu/clouds/aws/firewall_rule.rb +19 -16
  28. data/modules/mu/clouds/aws/folder.rb +7 -7
  29. data/modules/mu/clouds/aws/function.rb +15 -12
  30. data/modules/mu/clouds/aws/group.rb +14 -10
  31. data/modules/mu/clouds/aws/habitat.rb +16 -13
  32. data/modules/mu/clouds/aws/loadbalancer.rb +16 -15
  33. data/modules/mu/clouds/aws/log.rb +13 -10
  34. data/modules/mu/clouds/aws/msg_queue.rb +15 -8
  35. data/modules/mu/clouds/aws/nosqldb.rb +18 -11
  36. data/modules/mu/clouds/aws/notifier.rb +11 -6
  37. data/modules/mu/clouds/aws/role.rb +87 -70
  38. data/modules/mu/clouds/aws/search_domain.rb +30 -19
  39. data/modules/mu/clouds/aws/server.rb +102 -72
  40. data/modules/mu/clouds/aws/server_pool.rb +47 -28
  41. data/modules/mu/clouds/aws/storage_pool.rb +5 -6
  42. data/modules/mu/clouds/aws/user.rb +13 -10
  43. data/modules/mu/clouds/aws/vpc.rb +135 -121
  44. data/modules/mu/clouds/azure.rb +16 -9
  45. data/modules/mu/clouds/azure/container_cluster.rb +2 -3
  46. data/modules/mu/clouds/azure/firewall_rule.rb +10 -10
  47. data/modules/mu/clouds/azure/habitat.rb +8 -6
  48. data/modules/mu/clouds/azure/loadbalancer.rb +5 -5
  49. data/modules/mu/clouds/azure/role.rb +8 -10
  50. data/modules/mu/clouds/azure/server.rb +65 -25
  51. data/modules/mu/clouds/azure/user.rb +5 -7
  52. data/modules/mu/clouds/azure/vpc.rb +12 -15
  53. data/modules/mu/clouds/cloudformation.rb +8 -7
  54. data/modules/mu/clouds/cloudformation/vpc.rb +2 -4
  55. data/modules/mu/clouds/google.rb +39 -24
  56. data/modules/mu/clouds/google/bucket.rb +9 -11
  57. data/modules/mu/clouds/google/container_cluster.rb +27 -42
  58. data/modules/mu/clouds/google/database.rb +6 -9
  59. data/modules/mu/clouds/google/firewall_rule.rb +11 -10
  60. data/modules/mu/clouds/google/folder.rb +16 -9
  61. data/modules/mu/clouds/google/function.rb +127 -161
  62. data/modules/mu/clouds/google/group.rb +21 -18
  63. data/modules/mu/clouds/google/habitat.rb +18 -15
  64. data/modules/mu/clouds/google/loadbalancer.rb +14 -16
  65. data/modules/mu/clouds/google/role.rb +48 -31
  66. data/modules/mu/clouds/google/server.rb +105 -105
  67. data/modules/mu/clouds/google/server_pool.rb +12 -31
  68. data/modules/mu/clouds/google/user.rb +67 -13
  69. data/modules/mu/clouds/google/vpc.rb +58 -65
  70. data/modules/mu/config.rb +89 -1738
  71. data/modules/mu/config/bucket.rb +3 -3
  72. data/modules/mu/config/collection.rb +3 -3
  73. data/modules/mu/config/container_cluster.rb +2 -2
  74. data/modules/mu/config/dnszone.rb +5 -5
  75. data/modules/mu/config/doc_helpers.rb +517 -0
  76. data/modules/mu/config/endpoint.rb +3 -3
  77. data/modules/mu/config/firewall_rule.rb +118 -3
  78. data/modules/mu/config/folder.rb +3 -3
  79. data/modules/mu/config/function.rb +2 -2
  80. data/modules/mu/config/group.rb +3 -3
  81. data/modules/mu/config/habitat.rb +3 -3
  82. data/modules/mu/config/loadbalancer.rb +3 -3
  83. data/modules/mu/config/log.rb +3 -3
  84. data/modules/mu/config/msg_queue.rb +3 -3
  85. data/modules/mu/config/nosqldb.rb +3 -3
  86. data/modules/mu/config/notifier.rb +2 -2
  87. data/modules/mu/config/ref.rb +333 -0
  88. data/modules/mu/config/role.rb +3 -3
  89. data/modules/mu/config/schema_helpers.rb +508 -0
  90. data/modules/mu/config/search_domain.rb +3 -3
  91. data/modules/mu/config/server.rb +86 -58
  92. data/modules/mu/config/server_pool.rb +2 -2
  93. data/modules/mu/config/tail.rb +189 -0
  94. data/modules/mu/config/user.rb +3 -3
  95. data/modules/mu/config/vpc.rb +44 -4
  96. data/modules/mu/defaults/Google.yaml +2 -2
  97. data/modules/mu/deploy.rb +13 -10
  98. data/modules/mu/groomer.rb +1 -1
  99. data/modules/mu/groomers/ansible.rb +69 -24
  100. data/modules/mu/groomers/chef.rb +52 -44
  101. data/modules/mu/logger.rb +17 -14
  102. data/modules/mu/master.rb +317 -2
  103. data/modules/mu/master/chef.rb +3 -4
  104. data/modules/mu/master/ldap.rb +3 -3
  105. data/modules/mu/master/ssl.rb +12 -2
  106. data/modules/mu/mommacat.rb +85 -1766
  107. data/modules/mu/mommacat/daemon.rb +394 -0
  108. data/modules/mu/mommacat/naming.rb +366 -0
  109. data/modules/mu/mommacat/storage.rb +689 -0
  110. data/modules/tests/bucket.yml +4 -0
  111. data/modules/tests/{win2k12.yaml → needwork/win2k12.yaml} +0 -0
  112. data/modules/tests/regrooms/aws-iam.yaml +201 -0
  113. data/modules/tests/regrooms/bucket.yml +19 -0
  114. metadata +112 -102
@@ -344,7 +344,7 @@ module MU
344
344
  )
345
345
  rescue Aws::Route53::Errors::LastVPCAssociation => e
346
346
  MU.log e.inspect, MU::WARN
347
- rescue Aws::Route53::Errors::VPCAssociationNotFound => e
347
+ rescue Aws::Route53::Errors::VPCAssociationNotFound
348
348
  MU.log "VPC #{vpc_id} access to zone #{id} already revoked", MU::WARN
349
349
  end
350
350
  end
@@ -366,7 +366,7 @@ module MU
366
366
  # @param location [Hash<String>]: A parsed Hash of {MU::Config::BasketofKittens::dnszones::records::geo_location}.
367
367
  # @param set_identifier [String]: A unique string to differentiate otherwise-similar records. Normally auto-generated, should not need to specify.
368
368
  # @param alias_zone [String]: Zone ID of the target's hosted zone, when creating an alias (type R53ALIAS)
369
- def self.manageRecord(id, name, type, targets: nil, aliases: nil,
369
+ def self.manageRecord(id, name, type, targets: nil,
370
370
  ttl: 7200, delete: false, sync_wait: true, failover: nil,
371
371
  healthcheck: nil, region: nil, weight: nil, overwrite: true,
372
372
  location: nil, set_identifier: nil, alias_zone: nil)
@@ -502,7 +502,7 @@ module MU
502
502
  rescue Aws::Route53::Errors::PriorRequestNotComplete => e
503
503
  sleep 10
504
504
  retry
505
- rescue Aws::Route53::Errors::InvalidChangeBatch, Aws::Route53::Errors::InvalidInput, Exception => e
505
+ rescue Aws::Route53::Errors::InvalidChangeBatch, Aws::Route53::Errors::InvalidInput, StandardError => e
506
506
  return if e.message.match(/ but it already exists/) and !delete
507
507
  MU.log "Failed to change DNS records, #{e.inspect}", MU::ERR, details: params
508
508
  raise e if !delete
@@ -663,7 +663,8 @@ module MU
663
663
  # Called by {MU::Cleanup}. Locates resources that were created by the
664
664
  # currently-loaded deployment, and purges them.
665
665
  def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
666
- checks_to_clean = []
666
+ MU.log "AWS::DNSZone.cleanup: need to support flags['known']", MU::DEBUG, details: flags
667
+
667
668
  threads = []
668
669
  MU::Cloud::AWS.route53(credentials: credentials).list_health_checks.health_checks.each { |check|
669
670
  begin
@@ -692,19 +693,19 @@ module MU
692
693
  threads << Thread.new(check) { |mycheck|
693
694
  MU.dupGlobals(parent_thread_id)
694
695
  Thread.abort_on_exception = true
695
- MU.log "Removing health check #{check.id}"
696
+ MU.log "Removing health check #{mycheck.id}"
696
697
  retries = 5
697
698
  begin
698
- MU::Cloud::AWS.route53(credentials: credentials).delete_health_check(health_check_id: check.id) if !noop
699
+ MU::Cloud::AWS.route53(credentials: credentials).delete_health_check(health_mycheck_id: mycheck.id) if !noop
699
700
  rescue Aws::Route53::Errors::NoSuchHealthCheck => e
700
- MU.log "Health Check '#{check.id}' disappeared before I could remove it", MU::WARN, details: e.inspect
701
+ MU.log "Health Check '#{mycheck.id}' disappeared before I could remove it", MU::WARN, details: e.inspect
701
702
  rescue Aws::Route53::Errors::InvalidInput => e
702
703
  if e.message.match(/is still referenced from parent health check/) && retries <= 5
703
704
  sleep 5
704
705
  retries += 1
705
706
  retry
706
707
  else
707
- MU.log "Health Check #{check.id} still has a parent health check associated with it, skipping", MU::WARN, details: e.inspect
708
+ MU.log "Health Check #{mycheck.id} still has a parent health check associated with it, skipping", MU::WARN, details: e.inspect
708
709
  end
709
710
  end
710
711
  }
@@ -719,7 +720,7 @@ module MU
719
720
  }
720
721
 
721
722
  zones = MU::Cloud::DNSZone.find(deploy_id: MU.deploy_id, region: region)
722
- zones.each_pair { |id, zone|
723
+ zones.values.each { |zone|
723
724
  MU.log "Purging DNS Zone '#{zone.name}' (#{zone.id})"
724
725
  if !noop
725
726
  begin
@@ -727,7 +728,6 @@ module MU
727
728
  rrsets = MU::Cloud::AWS.route53(credentials: credentials).list_resource_record_sets(hosted_zone_id: zone.id)
728
729
  rrsets.resource_record_sets.each { |rrset|
729
730
  next if zone.name == rrset.name and (rrset.type == "NS" or rrset.type == "SOA")
730
- records = []
731
731
  MU::Cloud::AWS.route53(credentials: credentials).change_resource_record_sets(
732
732
  hosted_zone_id: zone.id,
733
733
  change_batch: {
@@ -791,9 +791,9 @@ module MU
791
791
  end
792
792
 
793
793
  # Cloud-specific configuration properties.
794
- # @param config [MU::Config]: The calling MU::Config object
794
+ # @param _config [MU::Config]: The calling MU::Config object
795
795
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
796
- def self.schema(config)
796
+ def self.schema(_config)
797
797
  toplevel_required = []
798
798
  schema = {}
799
799
  [toplevel_required, schema]
@@ -801,9 +801,9 @@ module MU
801
801
 
802
802
  # Cloud-specific pre-processing of {MU::Config::BasketofKittens::dnszones}, bare and unvalidated.
803
803
  # @param zone [Hash]: The resource to process and validate
804
- # @param configurator [MU::Config]: The overall deployment configurator of which this resource is a member
804
+ # @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
805
805
  # @return [Boolean]: True if validation succeeded, False otherwise
806
- def self.validateConfig(zone, configurator)
806
+ def self.validateConfig(zone, _configurator)
807
807
  ok = true
808
808
 
809
809
  if !zone["records"].nil?
@@ -116,15 +116,15 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
116
116
  end
117
117
 
118
118
  if m['integrate_with']
119
- role_arn = if m['iam_role']
120
- if m['iam_role'].match(/^arn:/)
121
- m['iam_role']
122
- else
123
- sib_role = @deploy.findLitterMate(name: m['iam_role'], type: "roles")
124
- sib_role.cloudobj.arn
119
+ # role_arn = if m['iam_role']
120
+ # if m['iam_role'].match(/^arn:/)
121
+ # m['iam_role']
122
+ # else
123
+ # sib_role = @deploy.findLitterMate(name: m['iam_role'], type: "roles")
124
+ # sib_role.cloudobj.arn
125
125
  # XXX make this more like get_role_arn in Function, or just use Role.find?
126
- end
127
- end
126
+ # end
127
+ # end
128
128
 
129
129
  function_obj = nil
130
130
 
@@ -198,13 +198,12 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
198
198
  generate_methods
199
199
 
200
200
  MU.log "Deploying API Gateway #{@config['name']} to #{@config['deploy_to']}"
201
- resp = MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials']).create_deployment(
201
+ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials']).create_deployment(
202
202
  rest_api_id: @cloud_id,
203
203
  stage_name: @config['deploy_to']
204
204
  # cache_cluster_enabled: false,
205
205
  # cache_cluster_size: 0.5,
206
206
  )
207
- deployment_id = resp.id
208
207
  # this automatically creates a stage with the same name, so we don't
209
208
  # have to deal with that
210
209
 
@@ -220,11 +219,14 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
220
219
 
221
220
  end
222
221
 
222
+ @cloud_desc_cache = nil
223
223
  # @return [Struct]
224
- def cloud_desc
225
- MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials']).get_rest_api(
224
+ def cloud_desc(use_cache: true)
225
+ return @cloud_desc_cache if @cloud_desc_cache and use_cache
226
+ @cloud_desc_cache = MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials']).get_rest_api(
226
227
  rest_api_id: @cloud_id
227
228
  )
229
+ @cloud_desc_cache
228
230
  end
229
231
 
230
232
  # Return the metadata for this API
@@ -241,6 +243,9 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
241
243
  # @param region [String]: The cloud provider region
242
244
  # @return [void]
243
245
  def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
246
+ MU.log "AWS::Endpoint.cleanup: need to support flags['known']", MU::DEBUG, details: flags
247
+ MU.log "Placeholder: AWS Endpoint artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
248
+
244
249
  resp = MU::Cloud::AWS.apig(region: region, credentials: credentials).get_rest_apis
245
250
  if resp and resp.items
246
251
  resp.items.each { |api|
@@ -279,9 +284,9 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
279
284
  end
280
285
 
281
286
  # Cloud-specific configuration properties.
282
- # @param config [MU::Config]: The calling MU::Config object
287
+ # @param _config [MU::Config]: The calling MU::Config object
283
288
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
284
- def self.schema(config)
289
+ def self.schema(_config)
285
290
  toplevel_required = []
286
291
  schema = {
287
292
  "deploy_to" => {
@@ -538,8 +543,6 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
538
543
  ok
539
544
  end
540
545
 
541
- private
542
-
543
546
  def self.cors_option_integrations(path)
544
547
  {
545
548
  "type" => "OPTIONS",
@@ -585,6 +588,7 @@ MU::Cloud::AWS.apig(region: @config['region'], credentials: @config['credentials
585
588
  }
586
589
  }
587
590
  end
591
+ private_class_method :cors_option_integrations
588
592
 
589
593
  end
590
594
  end
@@ -54,13 +54,12 @@ module MU
54
54
 
55
55
  secgroup = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).create_security_group(sg_struct)
56
56
  @cloud_id = secgroup.group_id
57
- rescue Aws::EC2::Errors::InvalidGroupDuplicate => e
57
+ rescue Aws::EC2::Errors::InvalidGroupDuplicate
58
58
  MU.log "EC2 Security Group #{groupname} already exists, using it", MU::NOTICE
59
59
  filters = [{name: "group-name", values: [groupname]}]
60
60
  filters << {name: "vpc-id", values: [vpc_id]} if !vpc_id.nil?
61
61
 
62
62
  secgroup = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_security_groups(filters: filters).security_groups.first
63
- deploy_id = @deploy.deploy_id if !@deploy_id.nil?
64
63
  if secgroup.nil?
65
64
  raise MuError, "Failed to locate security group named #{groupname}, even though EC2 says it already exists", caller
66
65
  end
@@ -69,24 +68,24 @@ module MU
69
68
 
70
69
  begin
71
70
  MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_security_groups(group_ids: [secgroup.group_id])
72
- rescue Aws::EC2::Errors::InvalidGroupNotFound => e
71
+ rescue Aws::EC2::Errors::InvalidGroupNotFound
73
72
  MU.log "#{secgroup.group_id} not yet ready, waiting...", MU::NOTICE
74
73
  sleep 10
75
74
  retry
76
75
  end
77
76
 
78
77
  MU::Cloud::AWS.createStandardTags(secgroup.group_id, region: @config['region'], credentials: @config['credentials'])
79
- MU::MommaCat.createTag(secgroup.group_id, "Name", groupname, region: @config['region'], credentials: @config['credentials'])
78
+ MU::Cloud::AWS.createTag(secgroup.group_id, "Name", groupname, region: @config['region'], credentials: @config['credentials'])
80
79
 
81
80
  if @config['optional_tags']
82
81
  MU::MommaCat.listOptionalTags.each { |key, value|
83
- MU::MommaCat.createTag(secgroup.group_id, key, value, region: @config['region'], credentials: @config['credentials'])
82
+ MU::Cloud::AWS.createTag(secgroup.group_id, key, value, region: @config['region'], credentials: @config['credentials'])
84
83
  }
85
84
  end
86
85
 
87
86
  if @config['tags']
88
87
  @config['tags'].each { |tag|
89
- MU::MommaCat.createTag(secgroup.group_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])
88
+ MU::Cloud::AWS.createTag(secgroup.group_id, tag['key'], tag['value'], region: @config['region'], credentials: @config['credentials'])
90
89
  }
91
90
  end
92
91
 
@@ -180,7 +179,7 @@ module MU
180
179
  ip_permissions: ec2_rule
181
180
  )
182
181
  end
183
- rescue Aws::EC2::Errors::InvalidPermissionDuplicate => e
182
+ rescue Aws::EC2::Errors::InvalidPermissionDuplicate
184
183
  MU.log "Attempt to add duplicate rule to #{@cloud_id}", MU::DEBUG, details: ec2_rule
185
184
  # Ensure that, at least, the description field gets updated on
186
185
  # existing rules
@@ -246,7 +245,7 @@ module MU
246
245
  # Reverse-map our cloud description into a runnable config hash.
247
246
  # We assume that any values we have in +@config+ are placeholders, and
248
247
  # calculate our own accordingly based on what's live in the cloud.
249
- def toKitten(rootparent: nil, billing: nil, habitats: nil)
248
+ def toKitten(**_args)
250
249
  bok = {
251
250
  "cloud" => "AWS",
252
251
  "credentials" => @config['credentials'],
@@ -513,14 +512,18 @@ module MU
513
512
  if eni_resp and eni_resp.data and
514
513
  eni_resp.data.network_interfaces
515
514
  eni_resp.data.network_interfaces.each { |iface|
516
- iface_groups = iface.groups.map { |sg| sg.group_id }
515
+ iface_groups = iface.groups.map { |if_sg| if_sg.group_id }
517
516
  iface_groups.delete(sg.group_id)
518
517
  iface_groups << default_sg if iface_groups.empty?
519
- MU.log "Attempting to remove #{sg.group_id} from ENI #{iface.network_interface_id}"
520
- MU::Cloud::AWS.ec2(credentials: credentials, region: region).modify_network_interface_attribute(
521
- network_interface_id: iface.network_interface_id,
522
- groups: iface_groups
523
- )
518
+ MU.log "Attempting to remove #{sg.group_id} (#{sg.group_name}) from ENI #{iface.network_interface_id}"
519
+ begin
520
+ MU::Cloud::AWS.ec2(credentials: credentials, region: region).modify_network_interface_attribute(
521
+ network_interface_id: iface.network_interface_id,
522
+ groups: iface_groups
523
+ )
524
+ rescue ::Aws::EC2::Errors::AuthFailure
525
+ MU.log "Permission denied attempting to trim Security Group list for #{iface.network_interface_id}", MU::WARN, details: iface.groups.map { |g| g.group_name }.join(",")+" => default"
526
+ end
524
527
  }
525
528
  end
526
529
  end
@@ -537,9 +540,9 @@ module MU
537
540
  end
538
541
 
539
542
  # Cloud-specific configuration properties.
540
- # @param config [MU::Config]: The calling MU::Config object
543
+ # @param _config [MU::Config]: The calling MU::Config object
541
544
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
542
- def self.schema(config)
545
+ def self.schema(_config)
543
546
  toplevel_required = []
544
547
  schema = {
545
548
  "rules" => {
@@ -15,7 +15,7 @@
15
15
  module MU
16
16
  class Cloud
17
17
  class AWS
18
- # A log as configured in {MU::Config::BasketofKittens::logs}
18
+ # A log as configured in {MU::Config::BasketofKittens::folders}
19
19
  class Folder < MU::Cloud::Folder
20
20
 
21
21
  # Initialize this cloud resource object. Calling +super+ will invoke the initializer defined under {MU::Cloud}, which should set the attribtues listed in {MU::Cloud::PUBLIC_ATTRS} as well as applicable dependency shortcuts, like +@vpc+, for us.
@@ -78,20 +78,20 @@ module MU
78
78
  end
79
79
 
80
80
  # Cloud-specific configuration properties.
81
- # @param config [MU::Config]: The calling MU::Config object
81
+ # @param _config [MU::Config]: The calling MU::Config object
82
82
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
83
- def self.schema(config)
83
+ def self.schema(_config)
84
84
  toplevel_required = []
85
85
  schema = {
86
86
  }
87
87
  [toplevel_required, schema]
88
88
  end
89
89
 
90
- # Cloud-specific pre-processing of {MU::Config::BasketofKittens::logs}, bare and unvalidated.
91
- # @param log [Hash]: The resource to process and validate
92
- # @param configurator [MU::Config]: The overall deployment configurator of which this resource is a member
90
+ # Cloud-specific pre-processing of {MU::Config::BasketofKittens::folders}, bare and unvalidated.
91
+ # @param _folder [Hash]: The resource to process and validate
92
+ # @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
93
93
  # @return [Boolean]: True if validation succeeded, False otherwise
94
- def self.validateConfig(log, configurator)
94
+ def self.validateConfig(_folder, _configurator)
95
95
  ok = true
96
96
 
97
97
  ok
@@ -29,12 +29,12 @@ module MU
29
29
  def assign_tag(resource_arn, tag_list, region=@config['region'])
30
30
  begin
31
31
  tag_list.each do |each_pair|
32
- tag_resp = MU::Cloud::AWS.lambda(region: region, credentials: @config['credentials']).tag_resource({
32
+ MU::Cloud::AWS.lambda(region: region, credentials: @config['credentials']).tag_resource({
33
33
  resource: resource_arn,
34
34
  tags: each_pair
35
35
  })
36
36
  end
37
- rescue Exception => e
37
+ rescue StandardError => e
38
38
  MU.log e, MU::ERR
39
39
  end
40
40
  end
@@ -153,7 +153,7 @@ module MU
153
153
 
154
154
  MU.log trigger_properties, MU::DEBUG
155
155
  begin
156
- add_trigger = MU::Cloud::AWS.lambda(region: @config['region'], credentials: @config['credentials']).add_permission(trigger_properties)
156
+ MU::Cloud::AWS.lambda(region: @config['region'], credentials: @config['credentials']).add_permission(trigger_properties)
157
157
  rescue Aws::Lambda::Errors::ResourceConflictException
158
158
  end
159
159
  adjust_trigger(tr['service'], trigger_arn, func_arn, @mu_name)
@@ -176,7 +176,7 @@ module MU
176
176
  begin
177
177
  # XXX There doesn't seem to be an API call to list or view existing
178
178
  # permissions, wtaf. This means we can't intelligently guard this.
179
- add_trigger = MU::Cloud::AWS.lambda(region: @config['region'], credentials: @config['credentials']).add_permission(trigger)
179
+ MU::Cloud::AWS.lambda(region: @config['region'], credentials: @config['credentials']).add_permission(trigger)
180
180
  rescue Aws::Lambda::Errors::ResourceConflictException => e
181
181
  if e.message.match(/already exists/)
182
182
  MU::Cloud::AWS.lambda(region: @config['region'], credentials: @config['credentials']).remove_permission(
@@ -220,15 +220,15 @@ module MU
220
220
 
221
221
  when 'sns'
222
222
  # XXX don't do this, use MU::Cloud::AWS::Notification
223
- sns_client = MU::Cloud::AWS.sns(region: @config['region'], credentials: @config['credentials'])
224
- sub_to_what = sns_client.subscribe({
223
+ sns_client = MU::Cloud::AWS.sns(region: region, credentials: @config['credentials'])
224
+ sns_client.subscribe({
225
225
  topic_arn: trig_arn,
226
226
  protocol: protocol,
227
227
  endpoint: func_arn
228
228
  })
229
229
  when 'event','cloudwatch_event', 'events'
230
230
  # XXX don't do this, use MU::Cloud::AWS::Log
231
- client = MU::Cloud::AWS.cloudwatch_events(region: @config['region'], credentials: @config['credentials']).put_targets({
231
+ MU::Cloud::AWS.cloudwatch_events(region: region, credentials: @config['credentials']).put_targets({
232
232
  rule: @config['trigger']['name'],
233
233
  targets: [
234
234
  {
@@ -271,11 +271,13 @@ module MU
271
271
  # @param region [String]: The cloud provider region
272
272
  # @return [void]
273
273
  def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
274
+ MU.log "AWS::Function.cleanup: need to support flags['known']", MU::DEBUG, details: flags
275
+
274
276
  MU::Cloud::AWS.lambda(credentials: credentials, region: region).list_functions.functions.each { |f|
275
277
  desc = MU::Cloud::AWS.lambda(credentials: credentials, region: region).get_function(
276
278
  function_name: f.function_name
277
279
  )
278
- if desc.tags and desc.tags["MU-ID"] == MU.deploy_id
280
+ if desc.tags and desc.tags["MU-ID"] == MU.deploy_id and (desc.tags["MU-MASTER-IP"] == MU.mu_public_ip or ignoremaster)
279
281
  MU.log "Deleting Lambda function #{f.function_name}"
280
282
  if !noop
281
283
  MU::Cloud::AWS.lambda(credentials: credentials, region: region).delete_function(
@@ -312,7 +314,7 @@ module MU
312
314
  # Reverse-map our cloud description into a runnable config hash.
313
315
  # We assume that any values we have in +@config+ are placeholders, and
314
316
  # calculate our own accordingly based on what's live in the cloud.
315
- def toKitten(rootparent: nil, billing: nil, habitats: nil)
317
+ def toKitten(**_args)
316
318
  bok = {
317
319
  "cloud" => "AWS",
318
320
  "credentials" => @config['credentials'],
@@ -407,9 +409,9 @@ MU.log shortname, MU::NOTICE, details: function.configuration.role
407
409
 
408
410
 
409
411
  # Cloud-specific configuration properties.
410
- # @param config [MU::Config]: The calling MU::Config object
412
+ # @param _config [MU::Config]: The calling MU::Config object
411
413
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
412
- def self.schema(config)
414
+ def self.schema(_config)
413
415
  toplevel_required = ["runtime"]
414
416
  schema = {
415
417
  "triggers" => {
@@ -437,6 +439,7 @@ MU.log shortname, MU::NOTICE, details: function.configuration.role
437
439
  },
438
440
  "code" => {
439
441
  "type" => "object",
442
+ "description" => "Zipped deployment package to upload to our function.",
440
443
  "properties" => {
441
444
  "s3_bucket" => {
442
445
  "type" => "string",
@@ -565,7 +568,7 @@ MU.log shortname, MU::NOTICE, details: function.configuration.role
565
568
  role_name: name.to_s
566
569
  })
567
570
  return role['role']['arn']
568
- rescue Exception => e
571
+ rescue StandardError => e
569
572
  MU.log "#{e}", MU::ERR
570
573
  end
571
574
  nil
@@ -39,7 +39,7 @@ module MU
39
39
  if !@config['use_if_exists']
40
40
  raise MuError, "IAM group #{@mu_name} already exists and use_if_exists is false"
41
41
  end
42
- rescue Aws::IAM::Errors::NoSuchEntity => e
42
+ rescue Aws::IAM::Errors::NoSuchEntity
43
43
  @config['path'] ||= "/"+@deploy.deploy_id+"/"
44
44
  MU.log "Creating IAM group #{@config['path']}#{@mu_name}"
45
45
  MU::Cloud::AWS.iam(credentials: @config['credentials']).create_group(
@@ -99,7 +99,7 @@ module MU
99
99
 
100
100
  if @config['attachable_policies']
101
101
  configured_policies = @config['attachable_policies'].map { |p|
102
- id = if p.is_a?(MU::Config::Ref)
102
+ if p.is_a?(MU::Config::Ref)
103
103
  p.cloud_id
104
104
  else
105
105
  p = MU::Config::Ref.get(p)
@@ -150,13 +150,15 @@ module MU
150
150
  cloud_desc.arn
151
151
  end
152
152
 
153
-
153
+ @cloud_desc_cache = nil
154
154
  # Fetch the AWS API description of this group
155
155
  # return [Struct]
156
- def cloud_desc
157
- MU::Cloud::AWS.iam(credentials: @config['credentials']).get_group(
156
+ def cloud_desc(use_cache: true)
157
+ return @cloud_desc_cache if @cloud_desc_cache and use_cache
158
+ @cloud_desc_cache = MU::Cloud::AWS.iam(credentials: @config['credentials']).get_group(
158
159
  group_name: @mu_name
159
160
  )
161
+ @cloud_desc_cache
160
162
  end
161
163
 
162
164
  # Return the metadata for this group configuration
@@ -183,9 +185,11 @@ module MU
183
185
  # Remove all groups associated with the currently loaded deployment.
184
186
  # @param noop [Boolean]: If true, will only print what would be done
185
187
  # @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
186
- # @param region [String]: The cloud provider region
187
188
  # @return [void]
188
- def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
189
+ def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
190
+ MU.log "AWS::Group.cleanup: need to support flags['known']", MU::DEBUG, details: flags
191
+ MU.log "Placeholder: AWS Group artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
192
+
189
193
  resp = MU::Cloud::AWS.iam(credentials: credentials).list_groups(
190
194
  path_prefix: "/"+MU.deploy_id+"/"
191
195
  )
@@ -259,7 +263,7 @@ module MU
259
263
  # Reverse-map our cloud description into a runnable config hash.
260
264
  # We assume that any values we have in +@config+ are placeholders, and
261
265
  # calculate our own accordingly based on what's live in the cloud.
262
- def toKitten(rootparent: nil, billing: nil, habitats: nil)
266
+ def toKitten(**_args)
263
267
  bok = {
264
268
  "cloud" => "AWS",
265
269
  "credentials" => @config['credentials'],
@@ -315,9 +319,9 @@ module MU
315
319
  end
316
320
 
317
321
  # Cloud-specific configuration properties.
318
- # @param config [MU::Config]: The calling MU::Config object
322
+ # @param _config [MU::Config]: The calling MU::Config object
319
323
  # @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
320
- def self.schema(config)
324
+ def self.schema(_config)
321
325
  toplevel_required = []
322
326
  polschema = MU::Config::Role.schema["properties"]["policies"]
323
327
  polschema.deep_merge!(MU::Cloud::AWS::Role.condition_schema)