cloud-mu 3.4.0 → 3.5.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/ansible/roles/mu-nat/tasks/main.yml +3 -0
- data/bin/mu-aws-setup +41 -7
- data/bin/mu-azure-setup +34 -0
- 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 +8 -6
- 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 +5 -0
- data/cookbooks/mu-tools/files/centos-6/CentOS-Base.repo +47 -0
- data/cookbooks/mu-tools/libraries/helper.rb +12 -2
- data/cookbooks/mu-tools/libraries/monkey.rb +1 -1
- data/cookbooks/mu-tools/recipes/apply_security.rb +6 -0
- data/cookbooks/mu-tools/recipes/aws_api.rb +6 -4
- 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 +5 -2
- data/cookbooks/mu-tools/resources/disk.rb +108 -58
- 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 +9 -9
- data/extras/git_rpm/build.sh +20 -0
- data/extras/git_rpm/mugit.spec +53 -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/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 +1 -1
- data/modules/mu/cloud/ssh_sessions.rb +4 -0
- 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 +2 -2
- 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 +32 -32
- data/modules/mu/deploy.rb +23 -10
- data/modules/mu/groomers/chef.rb +2 -2
- data/modules/mu/master.rb +49 -3
- data/modules/mu/mommacat.rb +8 -5
- data/modules/mu/mommacat/naming.rb +2 -2
- data/modules/mu/mommacat/storage.rb +22 -27
- data/modules/mu/providers/aws.rb +142 -48
- 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 +40 -39
- 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 +28 -28
- 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 +6 -6
- data/modules/mu/providers/aws/loadbalancer.rb +34 -34
- 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 +17 -15
- data/modules/mu/providers/aws/search_domain.rb +10 -10
- data/modules/mu/providers/aws/server.rb +176 -95
- data/modules/mu/providers/aws/server_pool.rb +65 -105
- 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 +103 -51
- data/modules/mu/providers/aws/vpc_subnet.rb +43 -39
- data/modules/mu/providers/azure.rb +78 -12
- data/modules/mu/providers/azure/server.rb +18 -3
- data/modules/mu/providers/cloudformation/server.rb +1 -1
- data/modules/mu/providers/google.rb +19 -4
- 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 +1 -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 +24 -8
|
@@ -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,14 +58,14 @@ 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
67
|
begin
|
|
68
|
-
MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
68
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).create_log_group(
|
|
69
69
|
log_group_name: "/aws/lambda/#{@cloud_id}",
|
|
70
70
|
tags: @tags
|
|
71
71
|
)
|
|
@@ -86,14 +86,14 @@ module MU
|
|
|
86
86
|
}
|
|
87
87
|
if !changes.empty?
|
|
88
88
|
MU.log "Updating Lambda #{@mu_name}", MU::NOTICE, details: changes
|
|
89
|
-
MU::Cloud::AWS.lambda(region: @
|
|
89
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).update_function_configuration(new_props)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
if @code_sha256 and @code_sha256 != cloud_desc.code_sha_256.chomp
|
|
93
93
|
MU.log "Updating code in Lambda #{@mu_name}", MU::NOTICE, details: { "old" => @code_sha256, "new" => cloud_desc.code_sha_256 }
|
|
94
94
|
code_block[:publish] = true
|
|
95
95
|
code_block[:function_name] = @cloud_id
|
|
96
|
-
MU::Cloud::AWS.lambda(region: @
|
|
96
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).update_function_code(code_block)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# tag_function = assign_tag(lambda_func.function_arn, @config['tags'])
|
|
@@ -120,7 +120,7 @@ module MU
|
|
|
120
120
|
|
|
121
121
|
MU.log "Adding #{tr['service']} #{tr['name']} trigger to Lambda function #{@cloud_id}", details: trigger_properties
|
|
122
122
|
begin
|
|
123
|
-
MU::Cloud::AWS.lambda(region: @
|
|
123
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).add_permission(trigger_properties)
|
|
124
124
|
rescue Aws::Lambda::Errors::ResourceConflictException
|
|
125
125
|
# just means the permission is already there
|
|
126
126
|
end
|
|
@@ -138,7 +138,7 @@ module MU
|
|
|
138
138
|
if @config['invoke_on_completion']['payload']
|
|
139
139
|
invoke_params[:payload] = JSON.generate(@config['invoke_on_completion']['payload'])
|
|
140
140
|
end
|
|
141
|
-
resp = MU::Cloud::AWS.lambda(region: @
|
|
141
|
+
resp = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).invoke(invoke_params)
|
|
142
142
|
if resp.status_code == 200
|
|
143
143
|
MU.log "Invoked #{@cloud_id}", MU::NOTICE, details: Base64.decode64(resp.log_result)
|
|
144
144
|
else
|
|
@@ -161,13 +161,13 @@ module MU
|
|
|
161
161
|
begin
|
|
162
162
|
# XXX There doesn't seem to be an API call to list or view existing
|
|
163
163
|
# permissions, wtaf. This means we can't intelligently guard this.
|
|
164
|
-
MU::Cloud::AWS.lambda(region: @
|
|
164
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).add_permission(trigger)
|
|
165
165
|
rescue Aws::Lambda::Errors::ValidationException => e
|
|
166
166
|
MU.log e.message+" (calling_arn: #{calling_arn}, calling_service: #{calling_service}, calling_name: #{calling_name})", MU::ERR, details: trigger
|
|
167
167
|
raise e
|
|
168
168
|
rescue Aws::Lambda::Errors::ResourceConflictException => e
|
|
169
169
|
if e.message.match(/already exists/)
|
|
170
|
-
MU::Cloud::AWS.lambda(region: @
|
|
170
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).remove_permission(
|
|
171
171
|
function_name: @mu_name,
|
|
172
172
|
statement_id: "#{calling_service}-#{calling_name}"
|
|
173
173
|
)
|
|
@@ -187,16 +187,16 @@ module MU
|
|
|
187
187
|
case svc.downcase
|
|
188
188
|
when 'sns'
|
|
189
189
|
sib_sns = @deploy.findLitterMate(name: name, type: "notifiers")
|
|
190
|
-
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}"
|
|
191
191
|
when 'alarm','events', 'event', 'cloudwatch_event'
|
|
192
192
|
sib_event = @deploy.findLitterMate(name: name, type: "job")
|
|
193
|
-
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}"
|
|
194
194
|
when 'dynamodb'
|
|
195
195
|
sib_dynamo = @deploy.findLitterMate(name: name, type: "nosqldb")
|
|
196
|
-
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}"
|
|
197
197
|
when 'apigateway'
|
|
198
198
|
sib_apig = @deploy.findLitterMate(name: name, type: "endpoints")
|
|
199
|
-
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}"
|
|
200
200
|
when 's3'
|
|
201
201
|
arn = ''
|
|
202
202
|
end
|
|
@@ -208,18 +208,18 @@ module MU
|
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
# XXX placeholder, really; this is going end up being done from Endpoint, Log and Notification resources, I think
|
|
211
|
-
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)
|
|
212
212
|
|
|
213
213
|
case trig_type
|
|
214
214
|
|
|
215
215
|
when 'sns'
|
|
216
|
-
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)
|
|
217
217
|
when 'dynamodb'
|
|
218
|
-
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
|
|
219
219
|
# XXX guard this
|
|
220
220
|
MU.log "Adding DynamoDB Stream from #{stream.stream_arn} as trigger for #{@cloud_id}"
|
|
221
221
|
begin
|
|
222
|
-
MU::Cloud::AWS.lambda(region: @
|
|
222
|
+
MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).create_event_source_mapping(
|
|
223
223
|
event_source_arn: stream.stream_arn,
|
|
224
224
|
function_name: @cloud_id,
|
|
225
225
|
starting_position: "TRIM_HORIZON" # ...whatever that is
|
|
@@ -227,10 +227,10 @@ module MU
|
|
|
227
227
|
rescue ::Aws::Lambda::Errors::ResourceConflictException
|
|
228
228
|
end
|
|
229
229
|
|
|
230
|
-
# 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)
|
|
231
231
|
when 'event','cloudwatch_event', 'events'
|
|
232
232
|
# XXX don't do this, use MU::Cloud::AWS::Log
|
|
233
|
-
MU::Cloud::AWS.cloudwatch_events(region: region, credentials: @
|
|
233
|
+
MU::Cloud::AWS.cloudwatch_events(region: region, credentials: @credentials).put_targets({
|
|
234
234
|
rule: @config['trigger']['name'],
|
|
235
235
|
targets: [
|
|
236
236
|
{
|
|
@@ -317,9 +317,9 @@ module MU
|
|
|
317
317
|
def toKitten(**_args)
|
|
318
318
|
bok = {
|
|
319
319
|
"cloud" => "AWS",
|
|
320
|
-
"credentials" => @
|
|
320
|
+
"credentials" => @credentials,
|
|
321
321
|
"cloud_id" => @cloud_id,
|
|
322
|
-
"region" => @
|
|
322
|
+
"region" => @region
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
if !cloud_desc
|
|
@@ -333,20 +333,20 @@ module MU
|
|
|
333
333
|
bok['runtime'] = cloud_desc.runtime
|
|
334
334
|
bok['timeout'] = cloud_desc.timeout
|
|
335
335
|
|
|
336
|
-
function = MU::Cloud::AWS.lambda(region: @
|
|
337
|
-
# 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)
|
|
338
338
|
# if event_srcs and !event_srcs.event_source_mappings.empty?
|
|
339
339
|
# MU.log "dem mappings tho #{@cloud_id}", MU::WARN, details: event_srcs
|
|
340
340
|
# end
|
|
341
341
|
|
|
342
342
|
# begin
|
|
343
|
-
# 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)
|
|
344
344
|
# MU.log "invoke config #{@cloud_id}", MU::WARN, details: invoke_cfg
|
|
345
345
|
# rescue ::Aws::Lambda::Errors::ResourceNotFoundException
|
|
346
346
|
# end
|
|
347
347
|
|
|
348
348
|
# MU.log @cloud_id, MU::WARN, details: cloud_desc if @cloud_id == "Espier-Scheduled-Scanner"
|
|
349
|
-
# 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"
|
|
350
350
|
|
|
351
351
|
|
|
352
352
|
if function.code.repository_type == "S3"
|
|
@@ -415,7 +415,7 @@ module MU
|
|
|
415
415
|
end
|
|
416
416
|
|
|
417
417
|
begin
|
|
418
|
-
pol = MU::Cloud::AWS.lambda(region: @
|
|
418
|
+
pol = MU::Cloud::AWS.lambda(region: @region, credentials: @credentials).get_policy(function_name: @cloud_id).policy
|
|
419
419
|
MU.log @cloud_id, MU::WARN, details: JSON.parse(pol) if @cloud_id == "ESPIER-DEV-2020080900-LN-ON-DEMAND-SCANNER"
|
|
420
420
|
if pol
|
|
421
421
|
bok['triggers'] ||= []
|
|
@@ -542,7 +542,7 @@ MU.log @cloud_id, MU::WARN, details: JSON.parse(pol) if @cloud_id == "ESPIER-DEV
|
|
|
542
542
|
end
|
|
543
543
|
|
|
544
544
|
if mu_type
|
|
545
|
-
MU::Config.addDependency(function, t['name'], mu_type,
|
|
545
|
+
MU::Config.addDependency(function, t['name'], mu_type, my_phase: "groom")
|
|
546
546
|
end
|
|
547
547
|
}
|
|
548
548
|
end
|
|
@@ -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,7 +50,7 @@ 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']
|
|
@@ -89,7 +89,7 @@ module MU
|
|
|
89
89
|
target_params << this_target
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
MU::Cloud::AWS.cloudwatchevents(region: @
|
|
92
|
+
MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).put_targets(
|
|
93
93
|
rule: @cloud_id,
|
|
94
94
|
event_bus_name: cloud_desc.event_bus_name,
|
|
95
95
|
targets: target_params
|
|
@@ -176,9 +176,9 @@ module MU
|
|
|
176
176
|
def toKitten(**_args)
|
|
177
177
|
bok = {
|
|
178
178
|
"cloud" => "AWS",
|
|
179
|
-
"credentials" => @
|
|
179
|
+
"credentials" => @credentials,
|
|
180
180
|
"cloud_id" => @cloud_id,
|
|
181
|
-
"region" => @
|
|
181
|
+
"region" => @region
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
if !cloud_desc
|
|
@@ -217,7 +217,7 @@ module MU
|
|
|
217
217
|
)
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
targets = MU::Cloud::AWS.cloudwatchevents(region: @
|
|
220
|
+
targets = MU::Cloud::AWS.cloudwatchevents(region: @region, credentials: @credentials).list_targets_by_rule(
|
|
221
221
|
rule: @cloud_id,
|
|
222
222
|
event_bus_name: cloud_desc.event_bus_name
|
|
223
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,12 +585,12 @@ 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
596
|
if @targetgroups.nil?
|
|
@@ -600,11 +600,11 @@ module MU
|
|
|
600
600
|
@deploy.deployment['loadbalancers'][@config['name']] and
|
|
601
601
|
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"]
|
|
602
602
|
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"].each_pair { |tg_name, tg_arn|
|
|
603
|
-
@targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @
|
|
603
|
+
@targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
604
604
|
}
|
|
605
605
|
else
|
|
606
606
|
pp @config['targetgroups']
|
|
607
|
-
MU::Cloud::AWS.elb2(region: @
|
|
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
608
|
tg_name = tg.target_group_name
|
|
609
609
|
if @config['targetgroups']
|
|
610
610
|
@config['targetgroups'].each { |tg_cfg|
|
|
@@ -618,7 +618,7 @@ module MU
|
|
|
618
618
|
}
|
|
619
619
|
# @config['targetgroups'].each { |tg|
|
|
620
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: @
|
|
621
|
+
# @targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
622
622
|
# }
|
|
623
623
|
end
|
|
624
624
|
end
|
|
@@ -649,7 +649,7 @@ module MU
|
|
|
649
649
|
def registerNode(instance_id, targetgroups: nil)
|
|
650
650
|
if @config['classic'] or !@config.has_key?("classic")
|
|
651
651
|
MU.log "Registering #{instance_id} to ELB #{@cloud_id}"
|
|
652
|
-
MU::Cloud::AWS.elb(region: @
|
|
652
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).register_instances_with_load_balancer(
|
|
653
653
|
load_balancer_name: @cloud_id,
|
|
654
654
|
instances: [
|
|
655
655
|
{instance_id: instance_id}
|
|
@@ -665,7 +665,7 @@ module MU
|
|
|
665
665
|
end
|
|
666
666
|
targetgroups.each { |tg|
|
|
667
667
|
MU.log "Registering #{instance_id} to Target Group #{tg}"
|
|
668
|
-
MU::Cloud::AWS.elb2(region: @
|
|
668
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).register_targets(
|
|
669
669
|
target_group_arn: @targetgroups[tg].target_group_arn,
|
|
670
670
|
targets: [
|
|
671
671
|
{id: instance_id}
|