cloud-mu 3.3.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ansible/roles/mu-nat/tasks/main.yml +3 -0
- data/bin/mu-aws-setup +41 -7
- data/bin/mu-azure-setup +36 -2
- data/bin/mu-configure +214 -119
- data/bin/mu-gcp-setup +37 -2
- data/bin/mu-node-manage +3 -0
- data/bin/mu-refresh-ssl +67 -0
- data/bin/mu-run-tests +14 -4
- data/bin/mu-self-update +30 -10
- data/bin/mu-upload-chef-artifacts +30 -26
- data/cloud-mu.gemspec +9 -7
- data/cookbooks/mu-master/attributes/default.rb +5 -1
- data/cookbooks/mu-master/metadata.rb +2 -2
- data/cookbooks/mu-master/recipes/default.rb +81 -26
- data/cookbooks/mu-master/recipes/init.rb +197 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +1 -1
- data/cookbooks/mu-master/recipes/vault.rb +78 -77
- data/cookbooks/mu-master/templates/default/mods/rewrite.conf.erb +1 -0
- data/cookbooks/mu-master/templates/default/nagios.conf.erb +103 -0
- data/cookbooks/mu-master/templates/default/web_app.conf.erb +14 -30
- data/cookbooks/mu-tools/attributes/default.rb +12 -0
- data/cookbooks/mu-tools/files/centos-6/CentOS-Base.repo +47 -0
- data/cookbooks/mu-tools/libraries/helper.rb +98 -4
- data/cookbooks/mu-tools/libraries/monkey.rb +1 -1
- data/cookbooks/mu-tools/recipes/apply_security.rb +31 -9
- data/cookbooks/mu-tools/recipes/aws_api.rb +8 -2
- data/cookbooks/mu-tools/recipes/base_repositories.rb +1 -1
- data/cookbooks/mu-tools/recipes/gcloud.rb +2 -9
- data/cookbooks/mu-tools/recipes/google_api.rb +7 -0
- data/cookbooks/mu-tools/recipes/rsyslog.rb +8 -1
- data/cookbooks/mu-tools/resources/disk.rb +113 -42
- data/cookbooks/mu-tools/resources/mommacat_request.rb +1 -2
- data/cookbooks/mu-tools/templates/centos-8/sshd_config.erb +215 -0
- data/extras/Gemfile.lock.bootstrap +394 -0
- data/extras/bucketstubs/error.html +0 -0
- data/extras/bucketstubs/index.html +0 -0
- data/extras/clean-stock-amis +11 -3
- data/extras/generate-stock-images +6 -3
- data/extras/git_rpm/build.sh +20 -0
- data/extras/git_rpm/mugit.spec +53 -0
- data/extras/image-generators/AWS/centos7.yaml +19 -16
- data/extras/image-generators/AWS/{rhel7.yaml → rhel71.yaml} +0 -0
- data/extras/image-generators/AWS/{win2k12.yaml → win2k12r2.yaml} +0 -0
- data/extras/image-generators/VMWare/centos8.yaml +15 -0
- data/extras/openssl_rpm/build.sh +19 -0
- data/extras/openssl_rpm/mussl.spec +46 -0
- data/extras/python_rpm/muthon.spec +14 -4
- data/extras/ruby_rpm/muby.spec +9 -5
- data/extras/sqlite_rpm/build.sh +19 -0
- data/extras/sqlite_rpm/muqlite.spec +47 -0
- data/install/installer +7 -5
- data/modules/mommacat.ru +2 -2
- data/modules/mu.rb +12 -5
- data/modules/mu/cloud/machine_images.rb +1 -1
- data/modules/mu/cloud/providers.rb +6 -1
- data/modules/mu/cloud/resource_base.rb +7 -4
- data/modules/mu/cloud/ssh_sessions.rb +5 -1
- data/modules/mu/cloud/wrappers.rb +16 -7
- data/modules/mu/config.rb +28 -12
- data/modules/mu/config/database.rb +2 -2
- data/modules/mu/config/firewall_rule.rb +1 -1
- data/modules/mu/config/ref.rb +3 -3
- data/modules/mu/config/schema_helpers.rb +12 -3
- data/modules/mu/config/server.rb +10 -4
- data/modules/mu/config/server_pool.rb +2 -2
- data/modules/mu/config/vpc.rb +10 -10
- data/modules/mu/defaults/AWS.yaml +96 -96
- data/modules/mu/deploy.rb +27 -14
- data/modules/mu/groomers/chef.rb +2 -2
- data/modules/mu/master.rb +49 -3
- data/modules/mu/mommacat.rb +27 -9
- data/modules/mu/mommacat/naming.rb +2 -2
- data/modules/mu/mommacat/search.rb +16 -5
- data/modules/mu/mommacat/storage.rb +67 -32
- data/modules/mu/providers/aws.rb +185 -71
- data/modules/mu/providers/aws/alarm.rb +3 -3
- data/modules/mu/providers/aws/bucket.rb +19 -19
- data/modules/mu/providers/aws/cache_cluster.rb +22 -22
- data/modules/mu/providers/aws/cdn.rb +2 -2
- data/modules/mu/providers/aws/collection.rb +14 -14
- data/modules/mu/providers/aws/container_cluster.rb +27 -27
- data/modules/mu/providers/aws/database.rb +49 -45
- data/modules/mu/providers/aws/dnszone.rb +5 -5
- data/modules/mu/providers/aws/endpoint.rb +35 -35
- data/modules/mu/providers/aws/firewall_rule.rb +26 -23
- data/modules/mu/providers/aws/function.rb +35 -32
- data/modules/mu/providers/aws/group.rb +7 -7
- data/modules/mu/providers/aws/habitat.rb +2 -2
- data/modules/mu/providers/aws/job.rb +35 -32
- data/modules/mu/providers/aws/loadbalancer.rb +58 -37
- data/modules/mu/providers/aws/log.rb +14 -14
- data/modules/mu/providers/aws/msg_queue.rb +10 -10
- data/modules/mu/providers/aws/nosqldb.rb +8 -8
- data/modules/mu/providers/aws/notifier.rb +7 -7
- data/modules/mu/providers/aws/role.rb +69 -47
- data/modules/mu/providers/aws/search_domain.rb +10 -10
- data/modules/mu/providers/aws/server.rb +198 -110
- data/modules/mu/providers/aws/server_pool.rb +71 -119
- data/modules/mu/providers/aws/storage_pool.rb +17 -9
- data/modules/mu/providers/aws/user.rb +1 -1
- data/modules/mu/providers/aws/vpc.rb +106 -51
- data/modules/mu/providers/aws/vpc_subnet.rb +43 -39
- data/modules/mu/providers/azure.rb +82 -16
- data/modules/mu/providers/azure/server.rb +18 -3
- data/modules/mu/providers/cloudformation/server.rb +1 -1
- data/modules/mu/providers/google.rb +20 -5
- data/modules/mu/providers/google/folder.rb +6 -2
- data/modules/mu/providers/google/function.rb +65 -30
- data/modules/mu/providers/google/role.rb +2 -1
- data/modules/mu/providers/google/vpc.rb +27 -2
- data/modules/tests/aws-servers-with-handrolled-iam.yaml +37 -0
- data/modules/tests/k8s.yaml +1 -1
- metadata +32 -15
|
@@ -38,10 +38,10 @@ module MU
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# Tag this Lambda function
|
|
41
|
-
def assign_tag(resource_arn, tag_list, region=@
|
|
41
|
+
def assign_tag(resource_arn, tag_list, region=@region)
|
|
42
42
|
begin
|
|
43
43
|
tag_list.each do |each_pair|
|
|
44
|
-
MU::Cloud::AWS.lambda(region: region, credentials: @
|
|
44
|
+
MU::Cloud::AWS.lambda(region: region, credentials: @credentials).tag_resource({
|
|
45
45
|
resource: resource_arn,
|
|
46
46
|
tags: each_pair
|
|
47
47
|
})
|
|
@@ -58,16 +58,19 @@ module MU
|
|
|
58
58
|
lambda_properties = get_properties
|
|
59
59
|
|
|
60
60
|
MU.retrier([Aws::Lambda::Errors::InvalidParameterValueException], max: 5, wait: 10) {
|
|
61
|
-
resp = MU::Cloud::AWS.lambda(region: @
|
|
61
|
+
resp = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).create_function(lambda_properties)
|
|
62
62
|
@cloud_id = resp.function_name
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
# the console does this and docs expect it to be there, so mimic the
|
|
66
66
|
# behavior
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
begin
|
|
68
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).create_log_group(
|
|
69
|
+
log_group_name: "/aws/lambda/#{@cloud_id}",
|
|
70
|
+
tags: @tags
|
|
71
|
+
)
|
|
72
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException
|
|
73
|
+
end
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
# Called automatically by {MU::Deploy#createResources}
|
|
@@ -83,14 +86,14 @@ module MU
|
|
|
83
86
|
}
|
|
84
87
|
if !changes.empty?
|
|
85
88
|
MU.log "Updating Lambda #{@mu_name}", MU::NOTICE, details: changes
|
|
86
|
-
MU::Cloud::AWS.lambda(region: @
|
|
89
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).update_function_configuration(new_props)
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
if @code_sha256 and @code_sha256 != cloud_desc.code_sha_256.chomp
|
|
90
93
|
MU.log "Updating code in Lambda #{@mu_name}", MU::NOTICE, details: { "old" => @code_sha256, "new" => cloud_desc.code_sha_256 }
|
|
91
94
|
code_block[:publish] = true
|
|
92
95
|
code_block[:function_name] = @cloud_id
|
|
93
|
-
MU::Cloud::AWS.lambda(region: @
|
|
96
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).update_function_code(code_block)
|
|
94
97
|
end
|
|
95
98
|
|
|
96
99
|
# tag_function = assign_tag(lambda_func.function_arn, @config['tags'])
|
|
@@ -117,7 +120,7 @@ module MU
|
|
|
117
120
|
|
|
118
121
|
MU.log "Adding #{tr['service']} #{tr['name']} trigger to Lambda function #{@cloud_id}", details: trigger_properties
|
|
119
122
|
begin
|
|
120
|
-
MU::Cloud::AWS.lambda(region: @
|
|
123
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).add_permission(trigger_properties)
|
|
121
124
|
rescue Aws::Lambda::Errors::ResourceConflictException
|
|
122
125
|
# just means the permission is already there
|
|
123
126
|
end
|
|
@@ -135,7 +138,7 @@ module MU
|
|
|
135
138
|
if @config['invoke_on_completion']['payload']
|
|
136
139
|
invoke_params[:payload] = JSON.generate(@config['invoke_on_completion']['payload'])
|
|
137
140
|
end
|
|
138
|
-
resp = MU::Cloud::AWS.lambda(region: @
|
|
141
|
+
resp = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).invoke(invoke_params)
|
|
139
142
|
if resp.status_code == 200
|
|
140
143
|
MU.log "Invoked #{@cloud_id}", MU::NOTICE, details: Base64.decode64(resp.log_result)
|
|
141
144
|
else
|
|
@@ -158,13 +161,13 @@ module MU
|
|
|
158
161
|
begin
|
|
159
162
|
# XXX There doesn't seem to be an API call to list or view existing
|
|
160
163
|
# permissions, wtaf. This means we can't intelligently guard this.
|
|
161
|
-
MU::Cloud::AWS.lambda(region: @
|
|
164
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).add_permission(trigger)
|
|
162
165
|
rescue Aws::Lambda::Errors::ValidationException => e
|
|
163
166
|
MU.log e.message+" (calling_arn: #{calling_arn}, calling_service: #{calling_service}, calling_name: #{calling_name})", MU::ERR, details: trigger
|
|
164
167
|
raise e
|
|
165
168
|
rescue Aws::Lambda::Errors::ResourceConflictException => e
|
|
166
169
|
if e.message.match(/already exists/)
|
|
167
|
-
MU::Cloud::AWS.lambda(region: @
|
|
170
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).remove_permission(
|
|
168
171
|
function_name: @mu_name,
|
|
169
172
|
statement_id: "#{calling_service}-#{calling_name}"
|
|
170
173
|
)
|
|
@@ -184,16 +187,16 @@ module MU
|
|
|
184
187
|
case svc.downcase
|
|
185
188
|
when 'sns'
|
|
186
189
|
sib_sns = @deploy.findLitterMate(name: name, type: "notifiers")
|
|
187
|
-
arn = sib_sns ? sib_sns.arn : "arn:aws:sns:#{@
|
|
190
|
+
arn = sib_sns ? sib_sns.arn : "arn:aws:sns:#{@region}:#{MU::Cloud::AWS.credToAcct(@credentials)}:#{name}"
|
|
188
191
|
when 'alarm','events', 'event', 'cloudwatch_event'
|
|
189
192
|
sib_event = @deploy.findLitterMate(name: name, type: "job")
|
|
190
|
-
arn = sib_event ? sib_event.arn : "arn:aws:events:#{@
|
|
193
|
+
arn = sib_event ? sib_event.arn : "arn:aws:events:#{@region}:#{MU::Cloud::AWS.credToAcct(@credentials)}:rule/#{name}"
|
|
191
194
|
when 'dynamodb'
|
|
192
195
|
sib_dynamo = @deploy.findLitterMate(name: name, type: "nosqldb")
|
|
193
|
-
arn = sib_dynamo ? sib_dynamo.arn : "arn:aws:dynamodb:#{@
|
|
196
|
+
arn = sib_dynamo ? sib_dynamo.arn : "arn:aws:dynamodb:#{@region}:#{MU::Cloud::AWS.credToAcct(@credentials)}:table/#{name}"
|
|
194
197
|
when 'apigateway'
|
|
195
198
|
sib_apig = @deploy.findLitterMate(name: name, type: "endpoints")
|
|
196
|
-
arn = sib_apig ? sib_apig.arn : "arn:aws:apigateway:#{@
|
|
199
|
+
arn = sib_apig ? sib_apig.arn : "arn:aws:apigateway:#{@region}:#{MU::Cloud::AWS.credToAcct(@credentials)}:#{name}"
|
|
197
200
|
when 's3'
|
|
198
201
|
arn = ''
|
|
199
202
|
end
|
|
@@ -205,18 +208,18 @@ module MU
|
|
|
205
208
|
end
|
|
206
209
|
|
|
207
210
|
# XXX placeholder, really; this is going end up being done from Endpoint, Log and Notification resources, I think
|
|
208
|
-
def adjust_trigger(trig_type, trig_arn, func_arn, func_id=nil, protocol='lambda',region=@
|
|
211
|
+
def adjust_trigger(trig_type, trig_arn, func_arn, func_id=nil, protocol='lambda',region=@region)
|
|
209
212
|
|
|
210
213
|
case trig_type
|
|
211
214
|
|
|
212
215
|
when 'sns'
|
|
213
|
-
MU::Cloud.resourceClass("AWS", "Notifier").subscribe(trig_arn, arn, "lambda", region: @
|
|
216
|
+
MU::Cloud.resourceClass("AWS", "Notifier").subscribe(trig_arn, arn, "lambda", region: @region, credentials: @credentials)
|
|
214
217
|
when 'dynamodb'
|
|
215
|
-
stream = MU::Cloud::AWS.dynamostream(region: @
|
|
218
|
+
stream = MU::Cloud::AWS.dynamostream(region: @region, credentials: @credentials).list_streams(table_name: trig_arn.sub(/.*?:table\//, '')).streams.first
|
|
216
219
|
# XXX guard this
|
|
217
220
|
MU.log "Adding DynamoDB Stream from #{stream.stream_arn} as trigger for #{@cloud_id}"
|
|
218
221
|
begin
|
|
219
|
-
MU::Cloud::AWS.lambda(region: @
|
|
222
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).create_event_source_mapping(
|
|
220
223
|
event_source_arn: stream.stream_arn,
|
|
221
224
|
function_name: @cloud_id,
|
|
222
225
|
starting_position: "TRIM_HORIZON" # ...whatever that is
|
|
@@ -224,10 +227,10 @@ module MU
|
|
|
224
227
|
rescue ::Aws::Lambda::Errors::ResourceConflictException
|
|
225
228
|
end
|
|
226
229
|
|
|
227
|
-
# MU::Cloud.resourceClass("AWS", "NoSQLDB").subscribe(trig_arn, arn, "lambda", region: @
|
|
230
|
+
# MU::Cloud.resourceClass("AWS", "NoSQLDB").subscribe(trig_arn, arn, "lambda", region: @region, credentials: @credentials)
|
|
228
231
|
when 'event','cloudwatch_event', 'events'
|
|
229
232
|
# XXX don't do this, use MU::Cloud::AWS::Log
|
|
230
|
-
MU::Cloud::AWS.cloudwatch_events(region: region, credentials: @
|
|
233
|
+
MU::Cloud::AWS.cloudwatch_events(region: region, credentials: @credentials).put_targets({
|
|
231
234
|
rule: @config['trigger']['name'],
|
|
232
235
|
targets: [
|
|
233
236
|
{
|
|
@@ -314,9 +317,9 @@ module MU
|
|
|
314
317
|
def toKitten(**_args)
|
|
315
318
|
bok = {
|
|
316
319
|
"cloud" => "AWS",
|
|
317
|
-
"credentials" => @
|
|
320
|
+
"credentials" => @credentials,
|
|
318
321
|
"cloud_id" => @cloud_id,
|
|
319
|
-
"region" => @
|
|
322
|
+
"region" => @region
|
|
320
323
|
}
|
|
321
324
|
|
|
322
325
|
if !cloud_desc
|
|
@@ -330,20 +333,20 @@ module MU
|
|
|
330
333
|
bok['runtime'] = cloud_desc.runtime
|
|
331
334
|
bok['timeout'] = cloud_desc.timeout
|
|
332
335
|
|
|
333
|
-
function = MU::Cloud::AWS.lambda(region: @
|
|
334
|
-
# event_srcs = MU::Cloud::AWS.lambda(region: @
|
|
336
|
+
function = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).get_function(function_name: bok['name'])
|
|
337
|
+
# event_srcs = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).list_event_source_mappings(function_name: @cloud_id)
|
|
335
338
|
# if event_srcs and !event_srcs.event_source_mappings.empty?
|
|
336
339
|
# MU.log "dem mappings tho #{@cloud_id}", MU::WARN, details: event_srcs
|
|
337
340
|
# end
|
|
338
341
|
|
|
339
342
|
# begin
|
|
340
|
-
# invoke_cfg = MU::Cloud::AWS.lambda(region: @
|
|
343
|
+
# invoke_cfg = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).get_function_event_invoke_config(function_name: @cloud_id)
|
|
341
344
|
# MU.log "invoke config #{@cloud_id}", MU::WARN, details: invoke_cfg
|
|
342
345
|
# rescue ::Aws::Lambda::Errors::ResourceNotFoundException
|
|
343
346
|
# end
|
|
344
347
|
|
|
345
348
|
# MU.log @cloud_id, MU::WARN, details: cloud_desc if @cloud_id == "Espier-Scheduled-Scanner"
|
|
346
|
-
# MU.log "configuration #{@cloud_id}", MU::WARN, details: MU::Cloud::AWS.lambda(region: @
|
|
349
|
+
# MU.log "configuration #{@cloud_id}", MU::WARN, details: MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).get_function_configuration(function_name: @cloud_id) if @cloud_id == "Espier-Scheduled-Scanner"
|
|
347
350
|
|
|
348
351
|
|
|
349
352
|
if function.code.repository_type == "S3"
|
|
@@ -412,7 +415,7 @@ module MU
|
|
|
412
415
|
end
|
|
413
416
|
|
|
414
417
|
begin
|
|
415
|
-
pol = MU::Cloud::AWS.lambda(region: @
|
|
418
|
+
pol = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).get_policy(function_name: @cloud_id).policy
|
|
416
419
|
MU.log @cloud_id, MU::WARN, details: JSON.parse(pol) if @cloud_id == "ESPIER-DEV-2020080900-LN-ON-DEMAND-SCANNER"
|
|
417
420
|
if pol
|
|
418
421
|
bok['triggers'] ||= []
|
|
@@ -539,7 +542,7 @@ MU.log @cloud_id, MU::WARN, details: JSON.parse(pol) if @cloud_id == "ESPIER-DEV
|
|
|
539
542
|
end
|
|
540
543
|
|
|
541
544
|
if mu_type
|
|
542
|
-
MU::Config.addDependency(function, t['name'], mu_type,
|
|
545
|
+
MU::Config.addDependency(function, t['name'], mu_type, my_phase: "groom")
|
|
543
546
|
end
|
|
544
547
|
}
|
|
545
548
|
end
|
|
@@ -705,7 +708,7 @@ MU.log @cloud_id, MU::WARN, details: JSON.parse(pol) if @cloud_id == "ESPIER-DEV
|
|
|
705
708
|
}
|
|
706
709
|
if @config['tags']
|
|
707
710
|
@config['tags'].each { |tag|
|
|
708
|
-
lambda_properties[:tags][tag
|
|
711
|
+
lambda_properties[:tags][tag['key']] = tag['value']
|
|
709
712
|
}
|
|
710
713
|
end
|
|
711
714
|
|
|
@@ -32,7 +32,7 @@ module MU
|
|
|
32
32
|
# Called automatically by {MU::Deploy#createResources}
|
|
33
33
|
def create
|
|
34
34
|
begin
|
|
35
|
-
MU::Cloud::AWS.iam(credentials: @
|
|
35
|
+
MU::Cloud::AWS.iam(credentials: @credentials).get_group(
|
|
36
36
|
group_name: @mu_name,
|
|
37
37
|
path: @config['path']
|
|
38
38
|
)
|
|
@@ -42,7 +42,7 @@ module MU
|
|
|
42
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
|
-
MU::Cloud::AWS.iam(credentials: @
|
|
45
|
+
MU::Cloud::AWS.iam(credentials: @credentials).create_group(
|
|
46
46
|
group_name: @mu_name,
|
|
47
47
|
path: @config['path']
|
|
48
48
|
)
|
|
@@ -64,7 +64,7 @@ module MU
|
|
|
64
64
|
if found.size == 1
|
|
65
65
|
userdesc = found.values.first
|
|
66
66
|
MU.log "Adding IAM user #{userdesc.path}#{userdesc.user_name} to group #{@mu_name}", MU::NOTICE
|
|
67
|
-
MU::Cloud::AWS.iam(credentials: @
|
|
67
|
+
MU::Cloud::AWS.iam(credentials: @credentials).add_user_to_group(
|
|
68
68
|
user_name: userid,
|
|
69
69
|
group_name: @mu_name
|
|
70
70
|
)
|
|
@@ -77,7 +77,7 @@ module MU
|
|
|
77
77
|
extras = cloud_desc.users.map { |u| u.user_name } - @config['members']
|
|
78
78
|
extras.each { |user_name|
|
|
79
79
|
MU.log "Purging user #{user_name} from IAM group #{@cloud_id}", MU::NOTICE
|
|
80
|
-
MU::Cloud::AWS.iam(credentials: @
|
|
80
|
+
MU::Cloud::AWS.iam(credentials: @credentials).remove_user_from_group(
|
|
81
81
|
user_name: user_name,
|
|
82
82
|
group_name: @cloud_id
|
|
83
83
|
)
|
|
@@ -156,7 +156,7 @@ module MU
|
|
|
156
156
|
def cloud_desc(use_cache: true)
|
|
157
157
|
return @cloud_desc_cache if @cloud_desc_cache and use_cache
|
|
158
158
|
return nil if !@mu_name
|
|
159
|
-
@cloud_desc_cache = MU::Cloud::AWS.iam(credentials: @
|
|
159
|
+
@cloud_desc_cache = MU::Cloud::AWS.iam(credentials: @credentials).get_group(
|
|
160
160
|
group_name: @mu_name
|
|
161
161
|
)
|
|
162
162
|
@cloud_desc_cache
|
|
@@ -267,7 +267,7 @@ module MU
|
|
|
267
267
|
def toKitten(**_args)
|
|
268
268
|
bok = {
|
|
269
269
|
"cloud" => "AWS",
|
|
270
|
-
"credentials" => @
|
|
270
|
+
"credentials" => @credentials,
|
|
271
271
|
"cloud_id" => @cloud_id
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -292,7 +292,7 @@ module MU
|
|
|
292
292
|
if resp and resp.policy_names and resp.policy_names.size > 0
|
|
293
293
|
resp.policy_names.each { |pol_name|
|
|
294
294
|
pol = MU::Cloud::AWS.iam(credentials: @credentials).get_group_policy(group_name: @cloud_id, policy_name: pol_name)
|
|
295
|
-
doc = JSON.parse(
|
|
295
|
+
doc = JSON.parse(CGI.unescape(pol.policy_document))
|
|
296
296
|
bok["inline_policies"] = MU::Cloud.resourceClass("AWS", "Role").doc2MuPolicies(pol.policy_name, doc, bok["inline_policies"])
|
|
297
297
|
}
|
|
298
298
|
end
|
|
@@ -34,7 +34,7 @@ module MU
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
MU.log "Creating AWS account #{@mu_name} with contact email #{@config['email']}"
|
|
37
|
-
resp = MU::Cloud::AWS.orgs(credentials: @
|
|
37
|
+
resp = MU::Cloud::AWS.orgs(credentials: @credentials).create_account(
|
|
38
38
|
account_name: @mu_name,
|
|
39
39
|
email: @config['email']
|
|
40
40
|
)
|
|
@@ -42,7 +42,7 @@ module MU
|
|
|
42
42
|
createid = resp.create_account_status.id
|
|
43
43
|
|
|
44
44
|
begin
|
|
45
|
-
resp = MU::Cloud::AWS.orgs(credentials: @
|
|
45
|
+
resp = MU::Cloud::AWS.orgs(credentials: @credentials).describe_create_account_status(
|
|
46
46
|
create_account_request_id: createid
|
|
47
47
|
)
|
|
48
48
|
if !["SUCCEEDED", "IN_PROGRESS"].include?(resp.create_account_status.state)
|
|
@@ -33,7 +33,7 @@ module MU
|
|
|
33
33
|
|
|
34
34
|
MU.log "Creating CloudWatch Event #{@mu_name}", MU::NOTICE, details: params
|
|
35
35
|
|
|
36
|
-
MU::Cloud::AWS.cloudwatchevents(region: @
|
|
36
|
+
MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).put_rule(params)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Called automatically by {MU::Deploy#createResources}
|
|
@@ -50,43 +50,46 @@ module MU
|
|
|
50
50
|
|
|
51
51
|
if params.size > 0
|
|
52
52
|
MU.log "Updating CloudWatch Event #{@cloud_id}", MU::NOTICE, details: params
|
|
53
|
-
MU::Cloud::AWS.cloudwatchevents(region: @
|
|
53
|
+
MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).put_rule(new_props)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
if @config['targets']
|
|
57
57
|
target_params = []
|
|
58
58
|
@config['targets'].each { |t|
|
|
59
59
|
MU.retrier([MuNonFatal], max:5, wait: 9) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
raise MuError.new "Failed to fetch object from role reference", details: t['role'].to_h if !role_obj
|
|
79
|
-
params[:role_arn] = role_obj.arn
|
|
80
|
-
end
|
|
81
|
-
[:input, :input_path, :input_transformer, :kinesis_parameters, :run_command_parameters, :batch_parameters, :sqs_parameters, :ecs_parameters].each { |attr|
|
|
82
|
-
if t[attr.to_s]
|
|
83
|
-
this_target[attr] = MU.structToHash(t[attr.to_s])
|
|
60
|
+
target_ref = MU::Config::Ref.get(t)
|
|
61
|
+
target_obj = target_ref.kitten(@deploy, cloud: "AWS")
|
|
62
|
+
this_target = if target_ref.is_mu_type? and target_obj and
|
|
63
|
+
!target_obj.arn.nil?
|
|
64
|
+
if target_ref.type == "functions"
|
|
65
|
+
target_obj.addTrigger(arn, "events", @mu_name)
|
|
66
|
+
end
|
|
67
|
+
{
|
|
68
|
+
id: target_obj.cloud_id,
|
|
69
|
+
arn: target_obj.arn
|
|
70
|
+
}
|
|
71
|
+
elsif target_ref.id and target_ref.id.match(/^arn:/)
|
|
72
|
+
{
|
|
73
|
+
id: target_ref.id || target_ref.name,
|
|
74
|
+
arn: target_ref.id
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
raise MuNonFatal.new "Failed to retrieve ARN from CLoudWatch Event target descriptor", details: target_ref.to_h
|
|
84
78
|
end
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if t['role']
|
|
80
|
+
role_obj = MU::Config::Ref.get(t['role']).kitten(@deploy, cloud: "AWS")
|
|
81
|
+
raise MuError.new "Failed to fetch object from role reference", details: t['role'].to_h if !role_obj
|
|
82
|
+
params[:role_arn] = role_obj.arn
|
|
83
|
+
end
|
|
84
|
+
[:input, :input_path, :input_transformer, :kinesis_parameters, :run_command_parameters, :batch_parameters, :sqs_parameters, :ecs_parameters].each { |attr|
|
|
85
|
+
if t[attr.to_s]
|
|
86
|
+
this_target[attr] = MU.structToHash(t[attr.to_s])
|
|
87
|
+
end
|
|
88
|
+
}
|
|
89
|
+
target_params << this_target
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
MU::Cloud::AWS.cloudwatchevents(region: @
|
|
92
|
+
MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).put_targets(
|
|
90
93
|
rule: @cloud_id,
|
|
91
94
|
event_bus_name: cloud_desc.event_bus_name,
|
|
92
95
|
targets: target_params
|
|
@@ -173,9 +176,9 @@ module MU
|
|
|
173
176
|
def toKitten(**_args)
|
|
174
177
|
bok = {
|
|
175
178
|
"cloud" => "AWS",
|
|
176
|
-
"credentials" => @
|
|
179
|
+
"credentials" => @credentials,
|
|
177
180
|
"cloud_id" => @cloud_id,
|
|
178
|
-
"region" => @
|
|
181
|
+
"region" => @region
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
if !cloud_desc
|
|
@@ -214,7 +217,7 @@ module MU
|
|
|
214
217
|
)
|
|
215
218
|
end
|
|
216
219
|
|
|
217
|
-
targets = MU::Cloud::AWS.cloudwatchevents(region: @
|
|
220
|
+
targets = MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).list_targets_by_rule(
|
|
218
221
|
rule: @cloud_id,
|
|
219
222
|
event_bus_name: cloud_desc.event_bus_name
|
|
220
223
|
).targets
|
|
@@ -41,8 +41,8 @@ module MU
|
|
|
41
41
|
# Called automatically by {MU::Deploy#createResources}
|
|
42
42
|
def create
|
|
43
43
|
if @config["zones"] == nil
|
|
44
|
-
@config["zones"] = MU::Cloud::AWS.listAZs(region: @
|
|
45
|
-
MU.log "Using zones from #{@
|
|
44
|
+
@config["zones"] = MU::Cloud::AWS.listAZs(region: @region)
|
|
45
|
+
MU.log "Using zones from #{@region}", MU::DEBUG, details: @config['zones']
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
lb_options = {
|
|
@@ -122,15 +122,15 @@ module MU
|
|
|
122
122
|
begin
|
|
123
123
|
if @config['classic']
|
|
124
124
|
MU.log "Creating Elastic Load Balancer #{@mu_name}", details: lb_options
|
|
125
|
-
lb = MU::Cloud::AWS.elb(region: @
|
|
125
|
+
lb = MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_load_balancer(lb_options)
|
|
126
126
|
else
|
|
127
127
|
MU.log "Creating Application Load Balancer #{@mu_name}", details: lb_options
|
|
128
|
-
lb = MU::Cloud::AWS.elb2(region: @
|
|
128
|
+
lb = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_load_balancer(lb_options).load_balancers.first
|
|
129
129
|
begin
|
|
130
130
|
if lb.state.code != "active"
|
|
131
131
|
MU.log "Waiting for ALB #{@mu_name} to enter 'active' state", MU::NOTICE
|
|
132
132
|
sleep 20
|
|
133
|
-
lb = MU::Cloud::AWS.elb2(region: @
|
|
133
|
+
lb = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_load_balancers(
|
|
134
134
|
names: [@mu_name]
|
|
135
135
|
).load_balancers.first
|
|
136
136
|
end
|
|
@@ -170,7 +170,7 @@ module MU
|
|
|
170
170
|
if zones_to_try.size < @config["zones"].size
|
|
171
171
|
zones_to_try.each { |zone|
|
|
172
172
|
begin
|
|
173
|
-
MU::Cloud::AWS.elb(region: @
|
|
173
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).enable_availability_zones_for_load_balancer(
|
|
174
174
|
load_balancer_name: @mu_name,
|
|
175
175
|
availability_zones: [zone]
|
|
176
176
|
)
|
|
@@ -183,7 +183,7 @@ module MU
|
|
|
183
183
|
@targetgroups = {}
|
|
184
184
|
if !@config['healthcheck'].nil? and @config['classic']
|
|
185
185
|
MU.log "Configuring custom health check for ELB #{@mu_name}", details: @config['healthcheck']
|
|
186
|
-
MU::Cloud::AWS.elb(region: @
|
|
186
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).configure_health_check(
|
|
187
187
|
load_balancer_name: @mu_name,
|
|
188
188
|
health_check: {
|
|
189
189
|
target: @config['healthcheck']['target'],
|
|
@@ -229,9 +229,9 @@ module MU
|
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
|
|
232
|
-
tg_resp = MU::Cloud::AWS.elb2(region: @
|
|
232
|
+
tg_resp = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_target_group(tg_descriptor)
|
|
233
233
|
@targetgroups[tg['name']] = tg_resp.target_groups.first
|
|
234
|
-
MU::Cloud::AWS.elb2(region: @
|
|
234
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).add_tags(
|
|
235
235
|
resource_arns: [tg_resp.target_groups.first.target_group_arn],
|
|
236
236
|
tags: lb_options[:tags]
|
|
237
237
|
)
|
|
@@ -285,7 +285,7 @@ module MU
|
|
|
285
285
|
"ELBSecurityPolicy-TLS-1-2-2017-01"
|
|
286
286
|
end
|
|
287
287
|
end
|
|
288
|
-
listen_resp = MU::Cloud::AWS.elb2(region: @
|
|
288
|
+
listen_resp = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_listener(listen_descriptor).listeners.first
|
|
289
289
|
if !l['rules'].nil?
|
|
290
290
|
l['rules'].each { |rule|
|
|
291
291
|
rule_descriptor = {
|
|
@@ -307,14 +307,14 @@ module MU
|
|
|
307
307
|
}
|
|
308
308
|
end
|
|
309
309
|
}
|
|
310
|
-
MU::Cloud::AWS.elb2(region: @
|
|
310
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_rule(rule_descriptor)
|
|
311
311
|
}
|
|
312
312
|
end
|
|
313
313
|
}
|
|
314
314
|
else
|
|
315
315
|
@config["listeners"].each { |l|
|
|
316
316
|
if l['ssl_certificate_id']
|
|
317
|
-
MU::Cloud::AWS.elb(region: @
|
|
317
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(
|
|
318
318
|
load_balancer_name: @cloud_id,
|
|
319
319
|
load_balancer_port: l['lb_port'],
|
|
320
320
|
policy_names: [
|
|
@@ -347,7 +347,7 @@ module MU
|
|
|
347
347
|
if @config['cross_zone_unstickiness']
|
|
348
348
|
MU.log "Enabling cross-zone un-stickiness on #{lb.dns_name}"
|
|
349
349
|
if @config['classic']
|
|
350
|
-
MU::Cloud::AWS.elb(region: @
|
|
350
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
351
351
|
load_balancer_name: @mu_name,
|
|
352
352
|
load_balancer_attributes: {
|
|
353
353
|
cross_zone_load_balancing: {
|
|
@@ -357,7 +357,7 @@ module MU
|
|
|
357
357
|
)
|
|
358
358
|
else
|
|
359
359
|
@targetgroups.values.each { |tg|
|
|
360
|
-
MU::Cloud::AWS.elb2(region: @
|
|
360
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
361
361
|
target_group_arn: tg.target_group_arn,
|
|
362
362
|
attributes: [
|
|
363
363
|
{
|
|
@@ -373,7 +373,7 @@ module MU
|
|
|
373
373
|
if !@config['idle_timeout'].nil?
|
|
374
374
|
MU.log "Setting idle timeout to #{@config['idle_timeout']} #{lb.dns_name}"
|
|
375
375
|
if @config['classic']
|
|
376
|
-
MU::Cloud::AWS.elb(region: @
|
|
376
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
377
377
|
load_balancer_name: @mu_name,
|
|
378
378
|
load_balancer_attributes: {
|
|
379
379
|
connection_settings: {
|
|
@@ -382,7 +382,7 @@ module MU
|
|
|
382
382
|
}
|
|
383
383
|
)
|
|
384
384
|
else
|
|
385
|
-
MU::Cloud::AWS.elb2(region: @
|
|
385
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
386
386
|
load_balancer_arn: lb.load_balancer_arn,
|
|
387
387
|
attributes: [
|
|
388
388
|
{
|
|
@@ -398,7 +398,7 @@ module MU
|
|
|
398
398
|
if @config['classic']
|
|
399
399
|
if @config['connection_draining_timeout'] >= 0
|
|
400
400
|
MU.log "Setting connection draining timeout to #{@config['connection_draining_timeout']} on #{lb.dns_name}"
|
|
401
|
-
MU::Cloud::AWS.elb(region: @
|
|
401
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
402
402
|
load_balancer_name: @mu_name,
|
|
403
403
|
load_balancer_attributes: {
|
|
404
404
|
connection_draining: {
|
|
@@ -409,7 +409,7 @@ module MU
|
|
|
409
409
|
)
|
|
410
410
|
else
|
|
411
411
|
MU.log "Disabling connection draining on #{lb.dns_name}"
|
|
412
|
-
MU::Cloud::AWS.elb(region: @
|
|
412
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
413
413
|
load_balancer_name: @mu_name,
|
|
414
414
|
load_balancer_attributes: {
|
|
415
415
|
connection_draining: {
|
|
@@ -427,7 +427,7 @@ module MU
|
|
|
427
427
|
MU.log "Disabling connection draining on #{lb.dns_name}"
|
|
428
428
|
end
|
|
429
429
|
@targetgroups.values.each { |tg|
|
|
430
|
-
MU::Cloud::AWS.elb2(region: @
|
|
430
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
431
431
|
target_group_arn: tg.target_group_arn,
|
|
432
432
|
attributes: [
|
|
433
433
|
{
|
|
@@ -443,7 +443,7 @@ module MU
|
|
|
443
443
|
if !@config['access_log'].nil?
|
|
444
444
|
MU.log "Setting access log params for #{lb.dns_name}", details: @config['access_log']
|
|
445
445
|
if @config['classic']
|
|
446
|
-
MU::Cloud::AWS.elb(region: @
|
|
446
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
447
447
|
load_balancer_name: @mu_name,
|
|
448
448
|
load_balancer_attributes: {
|
|
449
449
|
access_log: {
|
|
@@ -455,7 +455,7 @@ module MU
|
|
|
455
455
|
}
|
|
456
456
|
)
|
|
457
457
|
else
|
|
458
|
-
MU::Cloud::AWS.elb2(region: @
|
|
458
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
459
459
|
load_balancer_arn: lb.load_balancer_arn,
|
|
460
460
|
attributes: [
|
|
461
461
|
{
|
|
@@ -485,7 +485,7 @@ module MU
|
|
|
485
485
|
if !@config['lb_cookie_stickiness_policy']['timeout'].nil?
|
|
486
486
|
cookie_policy[:cookie_expiration_period] = @config['lb_cookie_stickiness_policy']['timeout']
|
|
487
487
|
end
|
|
488
|
-
MU::Cloud::AWS.elb(region: @
|
|
488
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_lb_cookie_stickiness_policy(cookie_policy)
|
|
489
489
|
lb_policy_names = Array.new
|
|
490
490
|
lb_policy_names << @config['lb_cookie_stickiness_policy']['name']
|
|
491
491
|
listener_policy = {
|
|
@@ -495,12 +495,12 @@ module MU
|
|
|
495
495
|
lb_options[:listeners].each do |listener|
|
|
496
496
|
if listener[:protocol].upcase == 'HTTP' or listener[:protocol].upcase == 'HTTPS'
|
|
497
497
|
listener_policy[:load_balancer_port] = listener[:load_balancer_port]
|
|
498
|
-
MU::Cloud::AWS.elb(region: @
|
|
498
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(listener_policy)
|
|
499
499
|
end
|
|
500
500
|
end
|
|
501
501
|
else
|
|
502
502
|
@targetgroups.values.each { |tg|
|
|
503
|
-
MU::Cloud::AWS.elb2(region: @
|
|
503
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
504
504
|
target_group_arn: tg.target_group_arn,
|
|
505
505
|
attributes: [
|
|
506
506
|
{
|
|
@@ -529,7 +529,7 @@ module MU
|
|
|
529
529
|
policy_name: @config['app_cookie_stickiness_policy']['name'],
|
|
530
530
|
cookie_name: @config['app_cookie_stickiness_policy']['cookie']
|
|
531
531
|
}
|
|
532
|
-
MU::Cloud::AWS.elb(region: @
|
|
532
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_app_cookie_stickiness_policy(cookie_policy)
|
|
533
533
|
lb_policy_names = Array.new
|
|
534
534
|
lb_policy_names << @config['app_cookie_stickiness_policy']['name']
|
|
535
535
|
listener_policy = {
|
|
@@ -539,7 +539,7 @@ module MU
|
|
|
539
539
|
lb_options[:listeners].each do |listener|
|
|
540
540
|
if listener[:protocol].upcase == 'HTTP' or listener[:protocol].upcase == 'HTTPS'
|
|
541
541
|
listener_policy[:load_balancer_port] = listener[:load_balancer_port]
|
|
542
|
-
MU::Cloud::AWS.elb(region: @
|
|
542
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(listener_policy)
|
|
543
543
|
end
|
|
544
544
|
end
|
|
545
545
|
else
|
|
@@ -573,7 +573,7 @@ module MU
|
|
|
573
573
|
# @return [String]
|
|
574
574
|
def arn
|
|
575
575
|
if @config['classic']
|
|
576
|
-
"arn:"+(MU::Cloud::AWS.isGovCloud?(@
|
|
576
|
+
"arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":elasticloadbalancing:"+@region+":"+MU::Cloud::AWS.credToAcct(@credentials)+":loadbalancer/"+@cloud_id
|
|
577
577
|
else
|
|
578
578
|
cloud_desc.load_balancer_arn
|
|
579
579
|
end
|
|
@@ -585,21 +585,42 @@ module MU
|
|
|
585
585
|
return @cloud_desc_cache if @cloud_desc_cache and use_cache
|
|
586
586
|
return nil if !@cloud_id
|
|
587
587
|
if @config['classic']
|
|
588
|
-
@cloud_desc_cache = MU::Cloud::AWS.elb(region: @
|
|
588
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb(region: @region, credentials: @credentials).describe_load_balancers(
|
|
589
589
|
load_balancer_names: [@cloud_id]
|
|
590
590
|
).load_balancer_descriptions.first
|
|
591
591
|
return @cloud_desc_cache
|
|
592
592
|
else
|
|
593
|
-
@cloud_desc_cache = MU::Cloud::AWS.elb2(region: @
|
|
593
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_load_balancers(
|
|
594
594
|
names: [@cloud_id]
|
|
595
595
|
).load_balancers.first
|
|
596
|
-
if @targetgroups.nil?
|
|
597
|
-
@deploy.deployment['loadbalancers'].has_key?(@config['name']) and
|
|
598
|
-
@deploy.deployment['loadbalancers'][@config['name']].has_key?("targetgroups")
|
|
596
|
+
if @targetgroups.nil?
|
|
599
597
|
@targetgroups = {}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
598
|
+
if !@deploy.nil? and
|
|
599
|
+
@deploy.deployment['loadbalancers'] and
|
|
600
|
+
@deploy.deployment['loadbalancers'][@config['name']] and
|
|
601
|
+
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"]
|
|
602
|
+
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"].each_pair { |tg_name, tg_arn|
|
|
603
|
+
@targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
604
|
+
}
|
|
605
|
+
else
|
|
606
|
+
pp @config['targetgroups']
|
|
607
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(load_balancer_arn: @cloud_desc_cache.load_balancer_arn).target_groups.each { |tg|
|
|
608
|
+
tg_name = tg.target_group_name
|
|
609
|
+
if @config['targetgroups']
|
|
610
|
+
@config['targetgroups'].each { |tg_cfg|
|
|
611
|
+
if tg_name = @deploy.getResourceName(tg_cfg["name"], max_length: 32, disallowed_chars: /[^A-Za-z0-9-]/)
|
|
612
|
+
tg_name = tg_cfg['name']
|
|
613
|
+
break
|
|
614
|
+
end
|
|
615
|
+
}
|
|
616
|
+
end
|
|
617
|
+
@targetgroups[tg_name] = tg
|
|
618
|
+
}
|
|
619
|
+
# @config['targetgroups'].each { |tg|
|
|
620
|
+
# tg_name = @deploy.getResourceName(tg["name"], max_length: 32, disallowed_chars: /[^A-Za-z0-9-]/)
|
|
621
|
+
# @targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
622
|
+
# }
|
|
623
|
+
end
|
|
603
624
|
end
|
|
604
625
|
|
|
605
626
|
return @cloud_desc_cache
|
|
@@ -628,7 +649,7 @@ module MU
|
|
|
628
649
|
def registerNode(instance_id, targetgroups: nil)
|
|
629
650
|
if @config['classic'] or !@config.has_key?("classic")
|
|
630
651
|
MU.log "Registering #{instance_id} to ELB #{@cloud_id}"
|
|
631
|
-
MU::Cloud::AWS.elb(region: @
|
|
652
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).register_instances_with_load_balancer(
|
|
632
653
|
load_balancer_name: @cloud_id,
|
|
633
654
|
instances: [
|
|
634
655
|
{instance_id: instance_id}
|
|
@@ -644,7 +665,7 @@ module MU
|
|
|
644
665
|
end
|
|
645
666
|
targetgroups.each { |tg|
|
|
646
667
|
MU.log "Registering #{instance_id} to Target Group #{tg}"
|
|
647
|
-
MU::Cloud::AWS.elb2(region: @
|
|
668
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).register_targets(
|
|
648
669
|
target_group_arn: @targetgroups[tg].target_group_arn,
|
|
649
670
|
targets: [
|
|
650
671
|
{id: instance_id}
|