chef-provisioning-aws 3.0.0.pre.rc1 → 3.0.0.pre.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be58e21bd868bb850a868eb9e28d8cddbd845c7a
4
- data.tar.gz: a700bfd36411280a8b69193c646ff9d413abe911
3
+ metadata.gz: e72b88122b55d297b9a6d1deb67b9382e2970b28
4
+ data.tar.gz: 2524010329c49d98267ccaf4dfe2499ee7909f10
5
5
  SHA512:
6
- metadata.gz: 3020304e7089b18d519ea75b9fc537174af9b553733d12d1a572bca11433184851da1e7aa1eda5f5ec2f9e0e4c786a80a1238ee7fd9ea7ab0dab9df0ce5e3be4
7
- data.tar.gz: a10dac39f023c3fc0bc6ddc5ec7d9c53bc89206d140f44815e86e5853df4f4da8cd819e2a550cd5b0dafe298e851727335505b71bad7d61171c828842f1312ce
6
+ metadata.gz: cf9349ad907b1570078a37b1d9e8cd2f5607bb251b6e16570ffd1570c59ccc52b4173ef2243dcf5bf56f4525b910f555c6701e72fa2b4d959747212d3d7c8ef7
7
+ data.tar.gz: 79d095797fb5d984a73cb01e820e88eda254c0958b960e454203e08714b0940353723480157de79228caf11ce932a171ee6ce0bcde65486b2764888d6483875d
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
4
  gem "chef"
5
+ gem 'rb-readline'
5
6
 
6
7
  gem "chef-zero", ">= 4.0"
7
8
  gem "rspec", "~> 3.0"
@@ -2,7 +2,7 @@ require 'chef/provisioning/aws_driver/aws_provider'
2
2
 
3
3
  class Chef::Provider::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSProvider
4
4
  provides :aws_cache_subnet_group
5
-
5
+
6
6
  protected
7
7
 
8
8
  def create_aws_object
@@ -81,7 +81,12 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
81
81
 
82
82
  def update_index_fields?(domain)
83
83
  if ! new_resource.index_fields.nil?
84
- new_resource.index_fields != index_fields
84
+ index_fields.each do |index_field|
85
+ if ! new_resource.index_fields.include?(index_field.to_h[:options])
86
+ return true
87
+ end
88
+ end
89
+ false
85
90
  else
86
91
  false
87
92
  end
@@ -148,8 +153,9 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
148
153
  end
149
154
 
150
155
  def scaling_parameters(object)
151
- o = get_option(:scaling_parameters)
152
- o.merge(desired_instance_type: object[:search_instance_type])
156
+ scaling_parameters = get_option(:scaling_parameters)
157
+ scaling_parameters.desired_instance_type = object[:search_instance_type]
158
+ scaling_parameters
153
159
  end
154
160
 
155
161
  def access_policies
@@ -157,7 +163,7 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
157
163
  end
158
164
 
159
165
  def index_fields
160
- cs_client.describe_index_fields(domain_name: new_resource.name)[:index_fields]
166
+ cs_client.describe_index_fields(domain_name: new_resource.name).index_fields
161
167
  end
162
168
 
163
169
  def get_option(option_name, key=nil)
@@ -171,6 +177,6 @@ class Chef::Provider::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSP
171
177
  end
172
178
 
173
179
  def cs_client
174
- @cs_client ||= new_resource.driver.cloudsearch(new_resource.cloudsearch_api_version)
180
+ @cs_client ||= new_resource.driver.cloudsearch
175
181
  end
176
182
  end
@@ -51,7 +51,7 @@ class Chef::Provider::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSPro
51
51
  opts[opt].map! do |action|
52
52
  if action.kind_of?(String) && !(action =~ /^arn:/)
53
53
  aws_object = Chef::Resource::AwsSnsTopic.get_aws_object(action, resource: new_resource)
54
- action = aws_object.arn if aws_object
54
+ action = aws_object.attributes["TopicArn"] if aws_object
55
55
  end
56
56
  action
57
57
  end
@@ -20,8 +20,8 @@ class Chef::Provider::AwsLoadBalancer < Chef::Provisioning::AWSDriver::AWSProvid
20
20
  provides :aws_load_balancer
21
21
 
22
22
  def destroy_aws_object(load_balancer)
23
- converge_by "delete load balancer #{new_resource.name} (#{load_balancer.name}) in #{region}" do
24
- load_balancer.delete
23
+ converge_by "delete load balancer #{new_resource.name} (#{load_balancer.load_balancer_name}) in #{region}" do
24
+ new_resource.driver.elb_client.delete_load_balancer(load_balancer_name: load_balancer.load_balancer_name)
25
25
  end
26
26
  end
27
27
  end
@@ -16,7 +16,7 @@ class AWSTagger
16
16
  def_delegators :@tagging_strategy, :desired_tags, :current_tags, :set_tags, :delete_tags
17
17
 
18
18
  def converge_tags
19
- if desired_tags.nil? || desired_tags.empty?
19
+ if desired_tags.nil?
20
20
  Chef::Log.debug "aws_tags not provided, nothing to converge"
21
21
  return
22
22
  end
@@ -159,96 +159,10 @@ module AWSDriver
159
159
  aws_config_2[:region]
160
160
  end
161
161
 
162
- def cloudsearch(api_version="20130101")
163
- @cloudsearch ||= {}
164
- @cloudsearch[api_version] ||= AWS::CloudSearch::Client.const_get("V#{api_version}").new
165
- @cloudsearch[api_version]
162
+ def cloudsearch
163
+ @cloudsearch ||= Aws::CloudSearch::Client.new(aws_config)
166
164
  end
167
-
168
- def ec2
169
- @ec2 ||= AWS::EC2.new(config: aws_config)
170
- end
171
-
172
- AWS_V2_SERVICES.each do |load_name, short_name|
173
- class_eval <<-META
174
-
175
- def #{short_name}_client
176
- @#{short_name}_client ||= ::Aws::#{load_name}::Client.new(**aws_config_2)
177
- end
178
-
179
- def #{short_name}_resource
180
- @#{short_name}_resource ||= ::Aws::#{load_name}::Resource.new(**(aws_config_2.merge({client: #{short_name}_client})))
181
- end
182
-
183
- META
184
- end
185
-
186
- def elb
187
- @elb ||= AWS::ELB.new(config: aws_config)
188
- end
189
-
190
- def elasticache
191
- @elasticache ||= AWS::ElastiCache::Client.new(config: aws_config)
192
- end
193
-
194
- def iam
195
- @iam ||= AWS::IAM.new(config: aws_config)
196
- end
197
-
198
- def rds
199
- @rds ||= ::Aws::RDS::Client.new(aws_config)
200
- end
201
-
202
- def s3
203
- @s3 ||= AWS::S3.new(config: aws_config)
204
- end
205
-
206
- def sns
207
- @sns ||= Aws::SNS::Client.new(config: aws_config)
208
- end
209
-
210
- def sqs
211
- @sqs ||= AWS::SQS::Client.new(config: aws_config)
212
- end
213
-
214
- def auto_scaling
215
- @auto_scaling ||= AWS::AutoScaling.new(config: aws_config)
216
- end
217
-
218
- def build_arn(partition: 'aws', service: nil, region: self.region, account_id: self.account_id, resource: nil)
219
- "arn:#{partition}:#{service}:#{region}:#{account_id}:#{resource}"
220
- end
221
-
222
- def parse_arn(arn)
223
- parts = arn.split(':', 6)
224
- {
225
- partition: parts[1],
226
- service: parts[2],
227
- region: parts[3],
228
- account_id: parts[4],
229
- resource: parts[5]
230
- }
231
- end
232
-
233
- def account_id
234
- begin
235
- # We've got an AWS account root credential or an IAM admin with access rights
236
- current_user = iam.client.get_user
237
- arn = current_user[:user][:arn]
238
- rescue AWS::IAM::Errors::AccessDenied => e
239
- # If we don't have access, the error message still tells us our account ID and user ...
240
- # https://forums.aws.amazon.com/thread.jspa?messageID=394344
241
- if e.to_s !~ /\b(arn:aws:iam::[0-9]{12}:\S*)/
242
- raise "IAM error response for GetUser did not include user ARN. Can't retrieve account ID."
243
- end
244
- arn = $1
245
- end
246
- parse_arn(arn)[:account_id]
247
- end
248
-
249
- # For creating things like AWS keypairs exclusively
250
- @@chef_default_lock = Mutex.new
251
-
165
+
252
166
  def self.canonicalize_url(driver_url, config)
253
167
  [ driver_url, config ]
254
168
  end
@@ -281,6 +195,13 @@ module AWSDriver
281
195
  def allocate_load_balancer(action_handler, lb_spec, lb_options, machine_specs)
282
196
  lb_options = deep_symbolize_keys(lb_options)
283
197
  lb_options = AWSResource.lookup_options(lb_options, managed_entry_store: lb_spec.managed_entry_store, driver: self)
198
+
199
+ # renaming lb_options[:port] to lb_options[:load_balancer_port]
200
+ if lb_options[:listeners]
201
+ lb_options[:listeners].each do |listener|
202
+ listener[:load_balancer_port] = listener.delete(:port) if listener[:port]
203
+ end
204
+ end
284
205
  # We delete the attributes, tags, health check, and sticky sessions here because they are not valid in the create call
285
206
  # and must be applied afterward
286
207
  lb_attributes = lb_options.delete(:attributes)
@@ -290,10 +211,11 @@ module AWSDriver
290
211
 
291
212
  old_elb = nil
292
213
  actual_elb = load_balancer_for(lb_spec)
293
- if !actual_elb
214
+ if actual_elb.nil?
294
215
  lb_options[:listeners] ||= get_listeners(:http)
216
+
295
217
  if !lb_options[:subnets] && !lb_options[:availability_zones] && machine_specs
296
- lb_options[:subnets] = machine_specs.map { |s| ec2_resource.instances[s.reference['instance_id']].subnet }.uniq
218
+ lb_options[:subnets] = machine_specs.map { |s| ec2_resource.instance(s.reference['instance_id']).subnet.id }.uniq
297
219
  end
298
220
 
299
221
  perform_action = proc { |desc, &block| action_handler.perform_action(desc, &block) }
@@ -309,10 +231,20 @@ module AWSDriver
309
231
  action_handler.perform_action updates do
310
232
  # IAM says the server certificate exists, but ELB throws this error
311
233
  Chef::Provisioning::AWSDriver::AWSProvider.retry_with_backoff(::Aws::ElasticLoadBalancing::Errors::CertificateNotFound) do
234
+ lb_options[:listeners].each do |listener|
235
+ if listener.has_key?(:server_certificate)
236
+ listener[:ssl_certificate_id] = listener.delete(:server_certificate)
237
+ listener[:ssl_certificate_id] = listener[:ssl_certificate_id][:arn]
238
+ end
239
+ end
240
+
312
241
  lb_options[:load_balancer_name]=lb_spec.name
313
242
  actual_elb = elb.create_load_balancer(lb_options)
314
243
  end
315
244
 
245
+ # load aws object for load balancer after create
246
+ actual_elb =load_balancer_for(lb_spec)
247
+
316
248
  lb_spec.reference = {
317
249
  'driver_version' => Chef::Provisioning::AWSDriver::VERSION,
318
250
  'allocated_at' => Time.now.utc.to_s,
@@ -401,8 +333,8 @@ module AWSDriver
401
333
  action += " (availability zones #{enable_zones.join(', ')})"
402
334
  perform_action.call(action) do
403
335
  begin
404
- elb.client.attach_load_balancer_to_subnets(
405
- load_balancer_name: actual_elb.name,
336
+ elb.attach_load_balancer_to_subnets(
337
+ load_balancer_name: actual_elb.load_balancer_name,
406
338
  subnets: attach_subnets
407
339
  )
408
340
  rescue ::Aws::ElasticLoadBalancing::Errors::InvalidConfigurationRequest => e
@@ -410,7 +342,7 @@ module AWSDriver
410
342
  "Amazon does not have an atomic operation which allows this. You must create a new " +
411
343
  "ELB with the correct subnets and move instances into it. Tried to attach subets " +
412
344
  "#{attach_subnets.join(', ')} (availability zones #{enable_zones.join(', ')}) to " +
413
- "existing ELB named #{actual_elb.name}"
345
+ "existing ELB named #{actual_elb.load_balancer_name}"
414
346
  raise e
415
347
  end
416
348
  end
@@ -422,8 +354,8 @@ module AWSDriver
422
354
  disable_zones = (actual_zones_subnets.map {|s,z| z if detach_subnets.include?(s)}).compact
423
355
  action += " (availability zones #{disable_zones.join(', ')})"
424
356
  perform_action.call(action) do
425
- elb.client.detach_load_balancer_from_subnets(
426
- load_balancer_name: actual_elb.name,
357
+ elb.detach_load_balancer_from_subnets(
358
+ load_balancer_name: actual_elb.load_balancer_name,
427
359
  subnets: detach_subnets
428
360
  )
429
361
  end
@@ -434,49 +366,58 @@ module AWSDriver
434
366
  if lb_options[:listeners]
435
367
  add_listeners = {}
436
368
  lb_options[:listeners].each { |l| add_listeners[l[:load_balancer_port]] = l }
437
- actual_elb.listeners.each do |listener|
438
- desired_listener = add_listeners.delete(listener.port)
439
- if desired_listener
369
+ actual_elb.listener_descriptions.each do |listener_description|
370
+ listener = listener_description.listener
371
+ desired_listener = add_listeners.delete(listener.load_balancer_port)
440
372
 
373
+ if desired_listener
441
374
  # listener.(port|protocol|instance_port|instance_protocol) are immutable for the life
442
375
  # of the listener - must create a new one and delete old one
443
376
  immutable_updates = []
444
- if listener.protocol != desired_listener[:protocol].to_sym.downcase
377
+ if listener.protocol != desired_listener[:protocol].to_s.upcase
445
378
  immutable_updates << " update protocol from #{listener.protocol.inspect} to #{desired_listener[:protocol].inspect}"
446
379
  end
380
+
447
381
  if listener.instance_port != desired_listener[:instance_port]
448
382
  immutable_updates << " update instance port from #{listener.instance_port.inspect} to #{desired_listener[:instance_port].inspect}"
449
383
  end
450
- if listener.instance_protocol != desired_listener[:instance_protocol].to_sym.downcase
384
+
385
+ if listener.instance_protocol != desired_listener[:instance_protocol].to_s.upcase
451
386
  immutable_updates << " update instance protocol from #{listener.instance_protocol.inspect} to #{desired_listener[:instance_protocol].inspect}"
452
387
  end
388
+
453
389
  if !immutable_updates.empty?
454
390
  perform_action.call(immutable_updates) do
455
- listener.delete
456
- actual_elb.listeners.create(desired_listener)
391
+ elb.delete_load_balancer_listeners({load_balancer_name: actual_elb.load_balancer_name, load_balancer_ports: [listener.load_balancer_port]})
392
+ elb.create_load_balancer_listeners({ listeners: [desired_listener], load_balancer_name: actual_elb.load_balancer_name })
393
+ # actual_elb.listeners.create(desired_listener)
457
394
  end
458
- elsif ! server_certificate_eql?(listener.server_certificate,
395
+ elsif listener.ssl_certificate_id && ! server_certificate_eql?(listener.ssl_certificate_id,
459
396
  server_cert_from_spec(desired_listener))
460
397
  # Server certificate is mutable - if no immutable changes required a full recreate, update cert
461
- perform_action.call(" update server certificate from #{listener.server_certificate} to #{server_cert_from_spec(desired_listener)}") do
462
- listener.server_certificate = server_cert_from_spec(desired_listener)
398
+ perform_action.call(" update server certificate from #{listener.ssl_certificate_id} to #{server_cert_from_spec(desired_listener)}") do
399
+ elb.set_load_balancer_listener_ssl_certificate({
400
+ load_balancer_name: actual_elb.load_balancer_name,
401
+ load_balancer_port: listener.load_balancer_port,
402
+ ssl_certificate_id: server_cert_from_spec(desired_listener)
403
+ })
463
404
  end
464
405
  end
465
-
466
406
  else
467
- perform_action.call(" remove listener #{listener.port}") do
468
- listener.delete
407
+ perform_action.call(" remove listener #{listener.load_balancer_port}") do
408
+ elb.delete_load_balancer_listeners({load_balancer_name: actual_elb.load_balancer_name, load_balancer_ports: [listener.load_balancer_port]})
469
409
  end
470
410
  end
471
411
  end
412
+
472
413
  add_listeners.values.each do |listener|
473
- updates = [ " add listener #{listener[:load_balanacer_port]}" ]
414
+ updates = [ " add listener #{listener[:load_balancer_port]}" ]
474
415
  updates << " set protocol to #{listener[:protocol].inspect}"
475
416
  updates << " set instance port to #{listener[:instance_port].inspect}"
476
417
  updates << " set instance protocol to #{listener[:instance_protocol].inspect}"
477
418
  updates << " set server certificate to #{server_cert_from_spec(listener)}" if server_cert_from_spec(listener)
478
419
  perform_action.call(updates) do
479
- actual_elb.listeners.create(listener)
420
+ elb.create_load_balancer_listeners({ listeners: [listener], load_balancer_name: actual_elb.load_balancer_name })
480
421
  end
481
422
  end
482
423
  end
@@ -486,13 +427,13 @@ module AWSDriver
486
427
 
487
428
  # Update load balancer attributes
488
429
  if lb_attributes
489
- current = elb.client.describe_load_balancer_attributes(load_balancer_name: actual_elb.name)[:load_balancer_attributes]
430
+ current = elb.describe_load_balancer_attributes(load_balancer_name: actual_elb.load_balancer_name)[:load_balancer_attributes].to_hash
490
431
  # Need to do a deep copy w/ Marshal load/dump to avoid overwriting current
491
432
  desired = deep_merge!(lb_attributes, Marshal.load(Marshal.dump(current)))
492
433
  if current != desired
493
434
  perform_action.call(" updating attributes to #{desired.inspect}") do
494
- elb.client.modify_load_balancer_attributes(
495
- load_balancer_name: actual_elb.name,
435
+ elb.modify_load_balancer_attributes(
436
+ load_balancer_name: actual_elb.load_balancer_name,
496
437
  load_balancer_attributes: desired.to_hash
497
438
  )
498
439
  end
@@ -501,12 +442,12 @@ module AWSDriver
501
442
 
502
443
  # Update the load balancer health check, as above
503
444
  if health_check
504
- current = elb.client.describe_load_balancers(load_balancer_names: [actual_elb.name])[:load_balancer_descriptions][0][:health_check]
445
+ current = elb.describe_load_balancers(load_balancer_names: [actual_elb.load_balancer_name])[:load_balancer_descriptions][0][:health_check].to_hash
505
446
  desired = deep_merge!(health_check, Marshal.load(Marshal.dump(current)))
506
447
  if current != desired
507
448
  perform_action.call(" updating health check to #{desired.inspect}") do
508
- elb.client.configure_health_check(
509
- load_balancer_name: actual_elb.name,
449
+ elb.configure_health_check(
450
+ load_balancer_name: actual_elb.load_balancer_name,
510
451
  health_check: desired.to_hash
511
452
  )
512
453
  end
@@ -515,8 +456,8 @@ module AWSDriver
515
456
 
516
457
  # Update the load balancer sticky sessions
517
458
  if sticky_sessions
518
- policy_name = "#{actual_elb.name}-sticky-session-policy"
519
- policies = elb.client.describe_load_balancer_policies(load_balancer_name: actual_elb.name)
459
+ policy_name = "#{actual_elb.load_balancer_name}-sticky-session-policy"
460
+ policies = elb.describe_load_balancer_policies(load_balancer_name: actual_elb.load_balancer_name)
520
461
 
521
462
  existing_cookie_policy = policies[:policy_descriptions].detect { |pd| pd[:policy_type_name] == 'AppCookieStickinessPolicyType' && pd[:policy_name] == policy_name}
522
463
  existing_cookie_name = existing_cookie_policy ? (existing_cookie_policy[:policy_attribute_descriptions].detect { |pad| pad[:attribute_name] == 'CookieName' })[:attribute_value] : nil
@@ -525,20 +466,20 @@ module AWSDriver
525
466
  # Create or update the policy to have the desired cookie_name
526
467
  if existing_cookie_policy.nil?
527
468
  perform_action.call(" creating sticky sessions with cookie_name #{desired_cookie_name}") do
528
- elb.client.create_app_cookie_stickiness_policy(
529
- load_balancer_name: actual_elb.name,
469
+ elb.create_app_cookie_stickiness_policy(
470
+ load_balancer_name: actual_elb.load_balancer_name,
530
471
  policy_name: policy_name,
531
472
  cookie_name: desired_cookie_name
532
473
  )
533
474
  end
534
475
  elsif existing_cookie_name && existing_cookie_name != desired_cookie_name
535
476
  perform_action.call(" updating sticky sessions from cookie_name #{existing_cookie_name} to cookie_name #{desired_cookie_name}") do
536
- elb.client.delete_load_balancer_policy(
537
- load_balancer_name: actual_elb.name,
477
+ elb.delete_load_balancer_policy(
478
+ load_balancer_name: actual_elb.load_balancer_name,
538
479
  policy_name: policy_name
539
480
  )
540
- elb.client.create_app_cookie_stickiness_policy(
541
- load_balancer_name: actual_elb.name,
481
+ elb.create_app_cookie_stickiness_policy(
482
+ load_balancer_name: actual_elb.load_balancer_name,
542
483
  policy_name: policy_name,
543
484
  cookie_name: desired_cookie_name
544
485
  )
@@ -546,7 +487,7 @@ module AWSDriver
546
487
  end
547
488
 
548
489
  # Ensure the policy is attached to the appropriate listener
549
- elb_description = elb.client.describe_load_balancers(load_balancer_names: [actual_elb.name])[:load_balancer_descriptions].first
490
+ elb_description = elb.describe_load_balancers(load_balancer_names: [actual_elb.load_balancer_name])[:load_balancer_descriptions].first
550
491
  listeners = elb_description[:listener_descriptions]
551
492
 
552
493
  sticky_sessions[:ports].each do |ss_port|
@@ -558,8 +499,8 @@ module AWSDriver
558
499
  unless policy_names.include?(policy_name)
559
500
  policy_names << policy_name
560
501
 
561
- elb.client.set_load_balancer_policies_of_listener(
562
- load_balancer_name: actual_elb.name,
502
+ elb.set_load_balancer_policies_of_listener(
503
+ load_balancer_name: actual_elb.load_balancer_name,
563
504
  load_balancer_port: ss_port,
564
505
  policy_names: policy_names
565
506
  )
@@ -570,22 +511,27 @@ module AWSDriver
570
511
 
571
512
  # Update instance list, but only if there are machines specified
572
513
  if machine_specs
573
- assigned_instance_ids = actual_elb.instances.map { |i| i.instance_id }
574
-
575
- instances_to_add = machine_specs.select { |s| !assigned_instance_ids.include?(s.reference['instance_id']) }
576
- instance_ids_to_remove = assigned_instance_ids - machine_specs.map { |s| s.reference['instance_id'] }
514
+ instances_to_add = []
515
+ if actual_elb.instances
516
+ assigned_instance_ids = actual_elb.instances.map { |i| i.instance_id }
517
+ instances_to_add = machine_specs.select { |s| !assigned_instance_ids.include?(s.reference['instance_id']) }
518
+ instance_ids_to_remove = assigned_instance_ids - machine_specs.map { |s| s.reference['instance_id'] }
519
+ end
577
520
 
578
521
  if instances_to_add.size > 0
579
522
  perform_action.call(" add machines #{instances_to_add.map { |s| s.name }.join(', ')}") do
580
523
  instance_ids_to_add = instances_to_add.map { |s| s.reference['instance_id'] }
581
- Chef::Log.debug("Adding instances #{instance_ids_to_add.join(', ')} to load balancer #{actual_elb.name} in region #{region}")
582
- actual_elb.instances.add(instance_ids_to_add)
524
+ Chef::Log.debug("Adding instances #{instance_ids_to_add.join(', ')} to load balancer #{actual_elb.load_balancer_name} in region #{region}")
525
+ instances_to_add.each do |instance|
526
+ elb.register_instances_with_load_balancer({ instances: [ { instance_id: instance.reference['instance_id'] }], load_balancer_name: actual_elb.load_balancer_name})
527
+ end
583
528
  end
584
529
  end
585
530
 
586
531
  if instance_ids_to_remove.size > 0
587
532
  perform_action.call(" remove instances #{instance_ids_to_remove}") do
588
- actual_elb.instances.remove(instance_ids_to_remove)
533
+ instances_to_remove = Hash[instance_ids_to_remove.map {|id| [:instance_id, id]}]
534
+ elb.deregister_instances_from_load_balancer({ instances: [instances_to_remove], load_balancer_name: actual_elb.load_balancer_name})
589
535
  end
590
536
  end
591
537
  end
@@ -599,7 +545,7 @@ module AWSDriver
599
545
  # Something went wrong before we could moved instances from the old ELB to the new one
600
546
  # Don't delete the old ELB, but warn users there could now be 2 ELBs with the same name
601
547
  unless old_elb.nil?
602
- Chef::Log.warn("It is possible there are now 2 ELB instances - #{old_elb.name} and #{actual_elb.name}. " +
548
+ Chef::Log.warn("It is possible there are now 2 ELB instances - #{old_elb.load_balancer_name} and #{actual_elb.load_balancer_name}. " +
603
549
  "Determine which is correct and manually clean up the other.")
604
550
  end
605
551
  end
@@ -613,8 +559,8 @@ module AWSDriver
613
559
  end
614
560
 
615
561
  def server_cert_to_string(cert)
616
- if cert.respond_to?(:arn)
617
- cert.arn
562
+ if cert.is_a?(Hash) && cert.has_key?(:arn)
563
+ cert[:arn]
618
564
  else
619
565
  cert
620
566
  end
@@ -868,12 +814,6 @@ EOD
868
814
  strategy.cleanup_convergence(action_handler, machine_spec)
869
815
  end
870
816
 
871
- def cloudsearch(api_version="20130101")
872
- @cloudsearch ||= {}
873
- @cloudsearch[api_version] ||= ::Aws::CloudSearch::Client.const_get("V#{api_version}").new
874
- @cloudsearch[api_version]
875
- end
876
-
877
817
  def ec2
878
818
  @ec2 ||= ::Aws::EC2::Client.new(aws_config)
879
819
  end
@@ -897,7 +837,7 @@ EOD
897
837
  end
898
838
 
899
839
  def elasticache
900
- @elasticache ||= ::Aws::ElastiCache::Client.new(config: aws_config)
840
+ @elasticache ||= ::Aws::ElastiCache::Client.new(aws_config)
901
841
  end
902
842
 
903
843
  def iam
@@ -1577,7 +1517,7 @@ EOD
1577
1517
  def converge_elb_tags(aws_object, tags, action_handler)
1578
1518
  elb_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::ELB.new(
1579
1519
  elb_client,
1580
- aws_object,
1520
+ aws_object.load_balancer_name,
1581
1521
  tags
1582
1522
  )
1583
1523
  aws_tagger = Chef::Provisioning::AWSDriver::AWSTagger.new(elb_strategy, action_handler)
@@ -22,16 +22,26 @@ class S3
22
22
  end
23
23
 
24
24
  def set_tags(tags)
25
+ return if @is_set_tag
26
+ # It will also run from delete_tags to prevent two times execution of same api class variable is defined
27
+ @is_set_tag = true
25
28
  # http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#put_bucket_tagging-instance_method
26
29
  s3_client.put_bucket_tagging({
27
30
  bucket: bucket_name,
28
31
  tagging: {
29
- tag_set: tags.map {|k,v| {key: k, value: v} }
32
+ tag_set: desired_tags.map {|k,v| {key: k.to_s, value: v.to_s} }
30
33
  }
31
34
  })
32
35
  end
33
36
 
34
37
  def delete_tags(tag_keys)
38
+ if desired_tags.empty?
39
+ s3_client.delete_bucket_tagging({
40
+ bucket: bucket_name
41
+ })
42
+ else
43
+ set_tags(desired_tags)
44
+ end
35
45
  # S3 doesn't have a client action for deleting individual tags, just ALL tags. But the
36
46
  # put_bucket_tagging method will set the tags to what is provided so we don't need to
37
47
  # worry about this
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module AWSDriver
4
- VERSION = '3.0.0-rc1'
4
+ VERSION = '3.0.0-rc2'
5
5
  end
6
6
  end
7
7
  end
@@ -43,4 +43,10 @@ class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSR
43
43
  def aws_object
44
44
  driver.cloudsearch.describe_domains(domain_names: [name])[:domain_status_list].find {|d| !d[:deleted] }
45
45
  end
46
+
47
+ def cloudsearch_api_version(arg=nil)
48
+ unless arg.nil?
49
+ Chef::Log.warn("The ':cloudsearch_api_version' has been deprecated since it has been removed in AWS SDK version 2.")
50
+ end
51
+ end
46
52
  end
@@ -24,7 +24,7 @@ class Chef::Resource::AwsRdsParameterGroup < Chef::Provisioning::AWSDriver::AWSR
24
24
  parameters += more_results[:parameters]
25
25
  marker = more_results[:marker]
26
26
  end
27
- # object[:parameters] = parameters
27
+ driver.rds.reset_db_parameter_group(db_parameter_group_name: name, parameters: parameters)
28
28
 
29
29
  object
30
30
  rescue ::Aws::RDS::Errors::DBParameterGroupNotFound
@@ -52,6 +52,10 @@ module AWSSupport
52
52
 
53
53
  example.instance_exec aws_object, &custom_matcher if custom_matcher
54
54
 
55
+ # We get response as a Struct for aws_cache_subnet_group resource.
56
+ # Hence converting it into a hash.
57
+ aws_object = aws_object.to_hash if resource_name == :aws_cache_subnet_group
58
+
55
59
  # Check existence
56
60
  if aws_object.nil?
57
61
  differences << "#{resource_name}[#{name}] was not created!"
@@ -22,6 +22,7 @@ describe Chef::Resource::AwsCacheSubnetGroup do
22
22
  subnets [ 'test_subnet' ]
23
23
  end
24
24
  }.to create_an_aws_cache_subnet_group('test-subnet-group',
25
+ vpc_id: test_vpc.aws_object.id,
25
26
  subnets: [
26
27
  { subnet_identifier: test_subnet.aws_object.id }
27
28
  ]
@@ -77,9 +77,9 @@ describe Chef::Resource::AwsCloudwatchAlarm do
77
77
  value: "bar2"
78
78
  }
79
79
  ],
80
- insufficient_data_actions: [mytesttopic1.aws_object.arn],
81
- ok_actions: [mytesttopic1.aws_object.arn],
82
- alarm_actions: [mytesttopic1.aws_object.arn],
80
+ insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
81
+ ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
82
+ alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
83
83
  actions_enabled: false,
84
84
  alarm_description: "description",
85
85
  unit: "Percent",
@@ -142,9 +142,9 @@ describe Chef::Resource::AwsCloudwatchAlarm do
142
142
  value: "bar2"
143
143
  }
144
144
  ],
145
- insufficient_data_actions: [mytesttopic1.aws_object.arn],
146
- ok_actions: [mytesttopic1.aws_object.arn],
147
- alarm_actions: [mytesttopic1.aws_object.arn],
145
+ insufficient_data_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
146
+ ok_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
147
+ alarm_actions: [mytesttopic1.aws_object.attributes["TopicArn"]],
148
148
  actions_enabled: false,
149
149
  alarm_description: "description",
150
150
  unit: "Percent",
@@ -217,9 +217,9 @@ describe Chef::Resource::AwsCloudwatchAlarm do
217
217
  value: "bar3"
218
218
  }
219
219
  ],
220
- insufficient_data_actions: [mytesttopic2.aws_object.arn],
221
- ok_actions: Set[mytesttopic1.aws_object.arn, mytesttopic2.aws_object.arn],
222
- alarm_actions: [mytesttopic2.aws_object.arn],
220
+ insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
221
+ ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
222
+ alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
223
223
  actions_enabled: true,
224
224
  alarm_description: "description2",
225
225
  unit: "Bits",
@@ -245,9 +245,9 @@ describe Chef::Resource::AwsCloudwatchAlarm do
245
245
  value: "bar3"
246
246
  }
247
247
  ],
248
- insufficient_data_actions: [mytesttopic2.aws_object.arn],
249
- ok_actions: Set[mytesttopic1.aws_object.arn, mytesttopic2.aws_object.arn],
250
- alarm_actions: [mytesttopic2.aws_object.arn],
248
+ insufficient_data_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
249
+ ok_actions: Set[mytesttopic1.aws_object.attributes["TopicArn"], mytesttopic2.aws_object.attributes["TopicArn"]],
250
+ alarm_actions: [mytesttopic2.aws_object.attributes["TopicArn"]],
251
251
  actions_enabled: true,
252
252
  alarm_description: "description2",
253
253
  unit: "Gigabytes",
@@ -46,8 +46,7 @@ describe Chef::Resource::AwsRdsParameterGroup do
46
46
  )
47
47
 
48
48
  expect(results.parameters).to eq([{:parameter_name => "max_connections", :parameter_value => "250", :apply_method => "pending-reboot"}])
49
-
50
- results.aws_object[:parameters].each do |parameter|
49
+ results.parameters.each do |parameter|
51
50
  expect(parameter[:parameter_value]).to eq("250") if parameter[:parameter_name] == "max_connections"
52
51
  end
53
52
  end
@@ -82,7 +81,7 @@ describe Chef::Resource::AwsRdsParameterGroup do
82
81
  end
83
82
  }
84
83
  expect(results_2.parameters).to eq(updated_parameters)
85
- results_2.aws_object[:parameters].each do |parameter|
84
+ results_2.parameters.each do |parameter|
86
85
  expect(parameter[:parameter_value]).to eq(final_max_connection_value) if parameter[:parameter_name] == "max_connections"
87
86
  expect(parameter[:parameter_value]).to eq(final_application_name_value) if parameter[:parameter_name] == "application_name"
88
87
 
@@ -108,20 +108,18 @@ describe Chef::Resource::AwsSecurityGroup do
108
108
  ).and be_idempotent
109
109
  end
110
110
  end
111
-
112
111
  end
113
112
 
114
113
  with_aws "in a VPC" do
115
114
  purge_all
116
115
  setup_public_vpc
117
116
 
118
- # TODO Uncomment and test spec once the load balancer resource is fixed as per version 2
119
- # load_balancer "testloadbalancer" do
120
- # load_balancer_options({
121
- # subnets: ["test_public_subnet"],
122
- # security_groups: ["test_security_group"]
123
- # })
124
- # end
117
+ load_balancer "testloadbalancer" do
118
+ load_balancer_options({
119
+ subnets: ["test_public_subnet"],
120
+ security_groups: ["test_security_group"]
121
+ })
122
+ end
125
123
 
126
124
  it "aws_security_group 'test_sg' with no attributes works" do
127
125
  expect_recipe {
@@ -219,60 +217,57 @@ describe Chef::Resource::AwsSecurityGroup do
219
217
  ).and be_idempotent
220
218
  end
221
219
 
220
+ it "adds inbound and outbound_rules for source load_balancer" do
221
+ expect_recipe {
222
+ aws_security_group 'test_sg' do
223
+ vpc 'test_vpc'
224
+ inbound_rules(
225
+ testloadbalancer.aws_object => 1206,
226
+ {load_balancer: 'testloadbalancer'} => 1207,
227
+ )
228
+ outbound_rules(
229
+ 1206 => testloadbalancer.aws_object,
230
+ 1207 => {load_balancer: 'testloadbalancer'},
231
+ )
232
+ end
233
+ }.to create_an_aws_security_group('test_sg',
234
+ vpc_id: test_vpc.aws_object.id,
235
+ ip_permissions: [
236
+ set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
237
+ set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
238
+ ],
239
+ ip_permissions_egress: [
240
+ set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
241
+ set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
242
+ ]
243
+ ).and be_idempotent
244
+ end
222
245
 
223
-
224
- # TODO : ADD when load balancer resource is fixed as per version 2
225
- # it "adds inbound and outbound_rules for source load_balancer" do
226
- # expect_recipe {
227
- # aws_security_group 'test_sg' do
228
- # vpc 'test_vpc'
229
- # inbound_rules(
230
- # testloadbalancer.aws_object => 1206,
231
- # {load_balancer: 'testloadbalancer'} => 1207,
232
- # )
233
- # outbound_rules(
234
- # 1206 => testloadbalancer.aws_object,
235
- # 1207 => {load_balancer: 'testloadbalancer'},
236
- # )
237
- # end
238
- # }.to create_an_aws_security_group('test_sg',
239
- # vpc_id: test_vpc.aws_object.id,
240
- # ip_permissions: [
241
- # set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
242
- # set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
243
- # ],
244
- # ip_permissions_egress: [
245
- # set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
246
- # set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
247
- # ]
248
- # ).and be_idempotent
249
- # end
250
-
251
- # it "adds inbound and outbound_rules for source load_balancer specified in hash" do
252
- # expect_recipe {
253
- # aws_security_group 'test_sg' do
254
- # vpc 'test_vpc'
255
- # inbound_rules([
256
- # { port: 1206, sources: testloadbalancer.aws_object },
257
- # { port: 1207, sources: {load_balancer: 'testloadbalancer'}}
258
- # ])
259
- # outbound_rules([
260
- # { port: 1206, destinations: testloadbalancer.aws_object },
261
- # { port: 1207, destinations: {load_balancer: 'testloadbalancer'}}
262
- # ])
263
- # end
264
- # }.to create_an_aws_security_group('test_sg',
265
- # vpc_id: test_vpc.aws_object.id,
266
- # ip_permissions: [
267
- # set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
268
- # set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
269
- # ],
270
- # ip_permissions_egress: [
271
- # set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
272
- # set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
273
- # ]
274
- # ).and be_idempotent
275
- # end
246
+ it "adds inbound and outbound_rules for source load_balancer specified in hash" do
247
+ expect_recipe {
248
+ aws_security_group 'test_sg' do
249
+ vpc 'test_vpc'
250
+ inbound_rules([
251
+ { port: 1206, sources: testloadbalancer.aws_object },
252
+ { port: 1207, sources: {load_balancer: 'testloadbalancer'}}
253
+ ])
254
+ outbound_rules([
255
+ { port: 1206, destinations: testloadbalancer.aws_object },
256
+ { port: 1207, destinations: {load_balancer: 'testloadbalancer'}}
257
+ ])
258
+ end
259
+ }.to create_an_aws_security_group('test_sg',
260
+ vpc_id: test_vpc.aws_object.id,
261
+ ip_permissions: [
262
+ set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
263
+ set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
264
+ ],
265
+ ip_permissions_egress: [
266
+ set_ip_pemissions_mock_object(from_port: 1207, to_port: 1207, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)]),
267
+ set_ip_pemissions_mock_object(from_port: 1206, to_port: 1206, ip_protocol: "tcp", ip_ranges: [], user_id_group_pairs: [Aws::EC2::Types::UserIdGroupPair.new(group_id: test_security_group.aws_object.id, group_name: nil, peering_status: nil, user_id: test_security_group.aws_object.owner_id, vpc_id: nil, vpc_peering_connection_id: nil)])
268
+ ]
269
+ ).and be_idempotent
270
+ end
276
271
 
277
272
  it "can specify rules as a mapping from source/destination to port and protocol" do
278
273
  expect_recipe {
@@ -45,7 +45,7 @@ describe Chef::Resource::LoadBalancer do
45
45
  :protocol => :https,
46
46
  :instance_port => 81,
47
47
  :instance_protocol => :http,
48
- :ssl_certificate_id => load_balancer_cert.aws_object.arn
48
+ :ssl_certificate_id => load_balancer_cert.aws_object.server_certificate_metadata.arn
49
49
  }
50
50
  ],
51
51
  subnets: ["test_public_subnet"],
@@ -91,33 +91,9 @@ describe Chef::Resource::LoadBalancer do
91
91
  # availability_zones: [test_public_subnet.aws_object.availability_zone_name]
92
92
  })
93
93
  end
94
- }.to create_an_aws_load_balancer('test-load-balancer', {
95
- listeners: Set[
96
- {
97
- :port => 80,
98
- :protocol => :http,
99
- :instance_port => 80,
100
- :instance_protocol => :http,
101
- },
102
- {
103
- :port => 443,
104
- :protocol => :https,
105
- :instance_port => 81,
106
- :instance_protocol => :http,
107
- :server_certificate => {arn: load_balancer_cert.aws_object.arn}
108
- }
109
- ],
110
- subnets: [test_public_subnet.aws_object],
111
- security_groups: [test_security_group.aws_object],
112
- health_check: {
113
- target: "HTTP:80/",
114
- interval: 10,
115
- timeout: 5,
116
- unhealthy_threshold: 2,
117
- healthy_threshold: 2
118
- },
119
- scheme: "internal"
120
- }).and be_idempotent
94
+ }.to create_an_aws_load_balancer('test-load-balancer',
95
+ driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0]
96
+ ).and be_idempotent
121
97
  expect(
122
98
  driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
123
99
  ).to eq(load_balancer_attributes: {
@@ -184,7 +160,7 @@ describe Chef::Resource::LoadBalancer do
184
160
  :protocol => :https,
185
161
  :instance_port => 80,
186
162
  :instance_protocol => :http,
187
- :ssl_certificate_id => load_balancer_cert.aws_object.arn
163
+ :ssl_certificate_id => load_balancer_cert.aws_object.server_certificate_metadata.arn
188
164
  }],
189
165
  subnets: ["test_public_subnet"],
190
166
  security_groups: ["test_security_group"],
@@ -230,14 +206,14 @@ describe Chef::Resource::LoadBalancer do
230
206
  :protocol => :https,
231
207
  :instance_port => 8080,
232
208
  :instance_protocol => :http,
233
- :ssl_certificate_id => load_balancer_cert.aws_object.arn
209
+ :ssl_certificate_id => load_balancer_cert.aws_object.server_certificate_metadata.arn
234
210
  },
235
211
  {
236
212
  :port => 8443,
237
213
  :protocol => :https,
238
214
  :instance_port => 80,
239
215
  :instance_protocol => :http,
240
- :ssl_certificate_id => load_balancer_cert_2.aws_object.arn
216
+ :ssl_certificate_id => load_balancer_cert_2.aws_object.server_certificate_metadata.arn
241
217
  }],
242
218
  subnets: ["test_public_subnet2"],
243
219
  security_groups: ["test_security_group2"],
@@ -274,32 +250,7 @@ describe Chef::Resource::LoadBalancer do
274
250
  }
275
251
  })
276
252
  end
277
- }.to update_an_aws_load_balancer('test-load-balancer', {
278
- listeners: [{
279
- :port => 443,
280
- :protocol => :https,
281
- :instance_port => 8080,
282
- :instance_protocol => :http,
283
- :server_certificate => {arn: load_balancer_cert.aws_object.arn}
284
- },
285
- {
286
- :port => 8443,
287
- :protocol => :https,
288
- :instance_port => 80,
289
- :instance_protocol => :http,
290
- :server_certificate => {arn: load_balancer_cert_2.aws_object.arn}
291
- }],
292
- subnets: [test_public_subnet2.aws_object],
293
- security_groups: [test_security_group2.aws_object],
294
- health_check: {
295
- target: "HTTP:8080/",
296
- interval: 15,
297
- timeout: 4,
298
- unhealthy_threshold: 3,
299
- healthy_threshold: 3
300
- },
301
- scheme: "internal"
302
- }).and be_idempotent
253
+ }.to update_an_aws_load_balancer('test-load-balancer', driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0]).and be_idempotent
303
254
 
304
255
  expect(
305
256
  driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
@@ -360,9 +311,10 @@ describe Chef::Resource::LoadBalancer do
360
311
  })
361
312
  machines ['test_load_balancer_machine1']
362
313
  end
363
- }.to create_an_aws_load_balancer('test-load-balancer',
364
- :instances => [{id: test_load_balancer_machine1.aws_object.id}]
365
- ).and be_idempotent
314
+ }.to create_an_aws_load_balancer('test-load-balancer') { |aws_object|
315
+ ids = aws_object.instances.map {|i| i.instance_id}
316
+ expect([test_load_balancer_machine1.aws_object.id]).to eq(ids)
317
+ }.and be_idempotent
366
318
  end
367
319
 
368
320
  it "can reference machines by name or id" do
@@ -375,8 +327,7 @@ describe Chef::Resource::LoadBalancer do
375
327
  machines ['test_load_balancer_machine1', test_load_balancer_machine2.aws_object.id]
376
328
  end
377
329
  }.to create_an_aws_load_balancer('test-load-balancer') { |aws_object|
378
- instances = aws_object.instances
379
- ids = instances.map {|i| i.id}
330
+ ids = aws_object.instances.map {|i| i.instance_id}
380
331
  expect(ids.to_set).to eq([test_load_balancer_machine1.aws_object.id, test_load_balancer_machine2.aws_object.id].to_set)
381
332
  }.and be_idempotent
382
333
  end
@@ -399,9 +350,10 @@ describe Chef::Resource::LoadBalancer do
399
350
  })
400
351
  machines ['test_load_balancer_machine2']
401
352
  end
402
- }.to match_an_aws_load_balancer('test-load-balancer',
403
- :instances => [{id: test_load_balancer_machine2.aws_object.id}]
404
- ).and be_idempotent
353
+ }.to match_an_aws_load_balancer('test-load-balancer') { |aws_object|
354
+ ids = aws_object.instances.map {|i| i.instance_id}
355
+ expect([test_load_balancer_machine2.aws_object.id]).to eq(ids)
356
+ }.and be_idempotent
405
357
  end
406
358
  end
407
359
  end
@@ -427,7 +379,8 @@ describe Chef::Resource::LoadBalancer do
427
379
  aws_tags key1: "value"
428
380
  load_balancer_options subnets: ["test_public_subnet"]
429
381
  end
430
- }.to create_an_aws_load_balancer('test-load-balancer')
382
+ }.to create_an_aws_load_balancer('test-load-balancer',
383
+ driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0])
431
384
  .and have_aws_load_balancer_tags('test-load-balancer',
432
385
  {
433
386
  'key1' => 'value'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.rc1
4
+ version: 3.0.0.pre.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Ball
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-13 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-provisioning