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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/chef-provisioning-aws.gemspec +0 -1
  4. data/lib/chef/provider/aws_auto_scaling_group.rb +9 -6
  5. data/lib/chef/provider/aws_dhcp_options.rb +21 -11
  6. data/lib/chef/provider/aws_ebs_volume.rb +26 -24
  7. data/lib/chef/provider/aws_eip_address.rb +11 -12
  8. data/lib/chef/provider/aws_image.rb +1 -1
  9. data/lib/chef/provider/aws_internet_gateway.rb +18 -10
  10. data/lib/chef/provider/aws_key_pair.rb +6 -6
  11. data/lib/chef/provider/aws_launch_configuration.rb +7 -9
  12. data/lib/chef/provider/aws_nat_gateway.rb +2 -2
  13. data/lib/chef/provider/aws_network_acl.rb +11 -8
  14. data/lib/chef/provider/aws_network_interface.rb +34 -29
  15. data/lib/chef/provider/aws_rds_parameter_group.rb +1 -1
  16. data/lib/chef/provider/aws_rds_subnet_group.rb +1 -1
  17. data/lib/chef/provider/aws_route_table.rb +7 -7
  18. data/lib/chef/provider/aws_s3_bucket.rb +24 -12
  19. data/lib/chef/provider/aws_security_group.rb +202 -25
  20. data/lib/chef/provider/aws_server_certificate.rb +3 -4
  21. data/lib/chef/provider/aws_sns_topic.rb +4 -3
  22. data/lib/chef/provider/aws_sqs_queue.rb +7 -3
  23. data/lib/chef/provider/aws_subnet.rb +45 -21
  24. data/lib/chef/provider/aws_vpc.rb +59 -30
  25. data/lib/chef/provisioning/aws_driver/aws_provider.rb +12 -3
  26. data/lib/chef/provisioning/aws_driver/aws_resource.rb +2 -2
  27. data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +1 -1
  28. data/lib/chef/provisioning/aws_driver/aws_tagger.rb +2 -2
  29. data/lib/chef/provisioning/aws_driver/credentials.rb +1 -1
  30. data/lib/chef/provisioning/aws_driver/credentials2.rb +5 -1
  31. data/lib/chef/provisioning/aws_driver/driver.rb +124 -34
  32. data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +4 -4
  33. data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +1 -1
  34. data/lib/chef/provisioning/aws_driver/version.rb +1 -1
  35. data/lib/chef/resource/aws_auto_scaling_group.rb +2 -2
  36. data/lib/chef/resource/aws_cache_cluster.rb +4 -4
  37. data/lib/chef/resource/aws_cache_replication_group.rb +3 -3
  38. data/lib/chef/resource/aws_cache_subnet_group.rb +4 -4
  39. data/lib/chef/resource/aws_cloudsearch_domain.rb +1 -1
  40. data/lib/chef/resource/aws_cloudwatch_alarm.rb +1 -1
  41. data/lib/chef/resource/aws_dhcp_options.rb +10 -3
  42. data/lib/chef/resource/aws_ebs_volume.rb +10 -4
  43. data/lib/chef/resource/aws_eip_address.rb +4 -4
  44. data/lib/chef/resource/aws_elasticsearch_domain.rb +1 -1
  45. data/lib/chef/resource/aws_iam_role.rb +1 -1
  46. data/lib/chef/resource/aws_internet_gateway.rb +11 -4
  47. data/lib/chef/resource/aws_key_pair.rb +4 -3
  48. data/lib/chef/resource/aws_launch_configuration.rb +5 -4
  49. data/lib/chef/resource/aws_load_balancer.rb +14 -3
  50. data/lib/chef/resource/aws_nat_gateway.rb +2 -2
  51. data/lib/chef/resource/aws_network_acl.rb +10 -10
  52. data/lib/chef/resource/aws_network_interface.rb +12 -6
  53. data/lib/chef/resource/aws_rds_parameter_group.rb +6 -6
  54. data/lib/chef/resource/aws_rds_subnet_group.rb +4 -5
  55. data/lib/chef/resource/aws_route53_record_set.rb +1 -1
  56. data/lib/chef/resource/aws_route_table.rb +1 -1
  57. data/lib/chef/resource/aws_s3_bucket.rb +3 -2
  58. data/lib/chef/resource/aws_security_group.rb +6 -6
  59. data/lib/chef/resource/aws_server_certificate.rb +4 -5
  60. data/lib/chef/resource/aws_sns_topic.rb +4 -4
  61. data/lib/chef/resource/aws_sqs_queue.rb +3 -3
  62. data/lib/chef/resource/aws_subnet.rb +5 -5
  63. data/lib/chef/resource/aws_vpc.rb +12 -6
  64. data/lib/chef/resource/aws_vpc_peering_connection.rb +2 -2
  65. data/spec/aws_support.rb +12 -9
  66. data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +15 -5
  67. data/spec/integration/aws_dhcp_options_spec.rb +7 -7
  68. data/spec/integration/aws_ebs_volume_spec.rb +1 -1
  69. data/spec/integration/aws_internet_gateway_spec.rb +19 -18
  70. data/spec/integration/aws_key_pair_spec.rb +1 -1
  71. data/spec/integration/aws_nat_gateway_spec.rb +3 -6
  72. data/spec/integration/aws_network_acl_spec.rb +19 -11
  73. data/spec/integration/aws_network_interface_spec.rb +26 -20
  74. data/spec/integration/aws_rds_instance_spec.rb +6 -7
  75. data/spec/integration/aws_rds_subnet_group_spec.rb +6 -6
  76. data/spec/integration/aws_route53_hosted_zone_spec.rb +1 -1
  77. data/spec/integration/aws_s3_bucket_spec.rb +1 -2
  78. data/spec/integration/aws_security_group_spec.rb +272 -198
  79. data/spec/integration/aws_server_certificate_spec.rb +60 -78
  80. data/spec/integration/aws_subnet_spec.rb +8 -4
  81. data/spec/integration/aws_vpc_spec.rb +29 -23
  82. data/spec/integration/machine_spec.rb +1 -1
  83. data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +13 -0
  84. data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +1 -1
  85. data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +1 -1
  86. metadata +5 -20
  87. data/spec/persistence_file.txt +0 -220
@@ -98,7 +98,7 @@ module AWSDriver
98
98
 
99
99
  def load_default
100
100
  config_file = ENV['AWS_CONFIG_FILE'] || File.expand_path('~/.aws/config')
101
- credentials_file = ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
101
+ credentials_file = ENV['AWS_SHARED_CREDENTIALS_FILE'] || ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
102
102
  if File.file?(config_file)
103
103
  if File.file?(credentials_file)
104
104
  load_inis(config_file, credentials_file)
@@ -27,7 +27,11 @@ module AWSDriver
27
27
  # can be loaded successfully.
28
28
  def get_credentials
29
29
  # http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
30
- shared_creds = ::Aws::SharedCredentials.new(:profile_name => profile_name, :path => ENV["AWS_CONFIG_FILE"])
30
+ credentials_file = ENV.fetch('AWS_SHARED_CREDENTIALS_FILE', ENV['AWS_CONFIG_FILE'])
31
+ shared_creds = ::Aws::SharedCredentials.new(
32
+ :profile_name => profile_name,
33
+ :path => credentials_file
34
+ )
31
35
  instance_profile_creds = ::Aws::InstanceProfileCredentials.new(:retries => 1)
32
36
 
33
37
  if ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"]
@@ -20,14 +20,13 @@ require 'chef/provisioning/aws_driver/credentials2'
20
20
  require 'chef/provisioning/aws_driver/aws_tagger'
21
21
 
22
22
  require 'yaml'
23
- require 'aws-sdk-v1'
24
23
  require 'aws-sdk'
25
24
  require 'retryable'
26
25
  require 'ubuntu_ami'
27
26
  require 'base64'
28
27
 
29
28
  # loads the entire aws-sdk
30
- AWS.eager_autoload!
29
+ Aws.eager_autoload!
31
30
  AWS_V2_SERVICES = {
32
31
  "EC2" => "ec2",
33
32
  "Route53" => "route53",
@@ -112,11 +111,11 @@ module AWSDriver
112
111
  region = nil if region && region.empty?
113
112
 
114
113
  credentials = profile_name ? aws_credentials[profile_name] : aws_credentials.default
115
- @aws_config = AWS.config(
114
+ @aws_config = Aws.config.update(
116
115
  access_key_id: credentials[:aws_access_key_id],
117
116
  secret_access_key: credentials[:aws_secret_access_key],
118
117
  region: region || credentials[:region],
119
- proxy_uri: credentials[:proxy_uri] || nil,
118
+ http_proxy: credentials[:proxy_uri] || nil,
120
119
  session_token: credentials[:aws_session_token] || nil,
121
120
  logger: Chef::Log.logger
122
121
  )
@@ -197,7 +196,7 @@ module AWSDriver
197
196
  end
198
197
 
199
198
  def rds
200
- @rds ||= AWS::RDS.new(config: aws_config)
199
+ @rds ||= ::Aws::RDS::Client.new(aws_config)
201
200
  end
202
201
 
203
202
  def s3
@@ -205,11 +204,11 @@ module AWSDriver
205
204
  end
206
205
 
207
206
  def sns
208
- @sns ||= AWS::SNS.new(config: aws_config)
207
+ @sns ||= Aws::SNS::Client.new(config: aws_config)
209
208
  end
210
209
 
211
210
  def sqs
212
- @sqs ||= AWS::SQS.new(config: aws_config)
211
+ @sqs ||= AWS::SQS::Client.new(config: aws_config)
213
212
  end
214
213
 
215
214
  def auto_scaling
@@ -291,10 +290,10 @@ module AWSDriver
291
290
 
292
291
  old_elb = nil
293
292
  actual_elb = load_balancer_for(lb_spec)
294
- if !actual_elb || !actual_elb.exists?
293
+ if !actual_elb
295
294
  lb_options[:listeners] ||= get_listeners(:http)
296
295
  if !lb_options[:subnets] && !lb_options[:availability_zones] && machine_specs
297
- lb_options[:subnets] = machine_specs.map { |s| ec2.instances[s.reference['instance_id']].subnet }.uniq
296
+ lb_options[:subnets] = machine_specs.map { |s| ec2_resource.instances[s.reference['instance_id']].subnet }.uniq
298
297
  end
299
298
 
300
299
  perform_action = proc { |desc, &block| action_handler.perform_action(desc, &block) }
@@ -309,8 +308,9 @@ module AWSDriver
309
308
 
310
309
  action_handler.perform_action updates do
311
310
  # IAM says the server certificate exists, but ELB throws this error
312
- Chef::Provisioning::AWSDriver::AWSProvider.retry_with_backoff(AWS::ELB::Errors::CertificateNotFound) do
313
- actual_elb = elb.load_balancers.create(lb_spec.name, lb_options)
311
+ Chef::Provisioning::AWSDriver::AWSProvider.retry_with_backoff(::Aws::ElasticLoadBalancing::Errors::CertificateNotFound) do
312
+ lb_options[:load_balancer_name]=lb_spec.name
313
+ actual_elb = elb.create_load_balancer(lb_options)
314
314
  end
315
315
 
316
316
  lb_spec.reference = {
@@ -334,12 +334,12 @@ module AWSDriver
334
334
 
335
335
  # Update security groups
336
336
  if lb_options[:security_groups]
337
- current = actual_elb.security_group_ids
337
+ current = actual_elb.security_groups
338
338
  desired = lb_options[:security_groups]
339
339
  if current != desired
340
340
  perform_action.call(" updating security groups to #{desired.to_a}") do
341
- elb.client.apply_security_groups_to_load_balancer(
342
- load_balancer_name: actual_elb.name,
341
+ elb_client.apply_security_groups_to_load_balancer(
342
+ load_balancer_name: actual_elb.load_balancer_name,
343
343
  security_groups: desired.to_a
344
344
  )
345
345
  end
@@ -362,7 +362,7 @@ module AWSDriver
362
362
  # an unecessary ones
363
363
  actual_zones_subnets = {}
364
364
  actual_elb.subnets.each do |subnet|
365
- actual_zones_subnets[subnet.id] = subnet.availability_zone.name
365
+ actual_zones_subnets[subnet] = Chef::Resource::AwsSubnet.get_aws_object(subnet, driver: self).availability_zone
366
366
  end
367
367
 
368
368
  # Only 1 of subnet or AZ will be populated b/c of our check earlier
@@ -376,7 +376,7 @@ module AWSDriver
376
376
  {:name => 'availabilityZone', :values => [zone]},
377
377
  {:name => 'defaultForAz', :values => ['true']}
378
378
  ]
379
- default_subnet = ec2.client.describe_subnets(:filters => filters)[:subnet_set]
379
+ default_subnet = ec2_client.describe_subnets(:filters => filters)[:subnets]
380
380
  if default_subnet.size != 1
381
381
  raise "Could not find default subnet in availability zone #{zone}"
382
382
  end
@@ -385,7 +385,7 @@ module AWSDriver
385
385
  end
386
386
  end
387
387
  unless lb_options[:subnets].nil? || lb_options[:subnets].empty?
388
- subnet_query = ec2.client.describe_subnets(:subnet_ids => lb_options[:subnets])[:subnet_set]
388
+ subnet_query = ec2_client.describe_subnets(:subnet_ids => lb_options[:subnets])[:subnets]
389
389
  # AWS raises an error on an unknown subnet, but not an unknown AZ
390
390
  subnet_query.each do |subnet|
391
391
  zone = subnet[:availability_zone].downcase
@@ -405,7 +405,7 @@ module AWSDriver
405
405
  load_balancer_name: actual_elb.name,
406
406
  subnets: attach_subnets
407
407
  )
408
- rescue AWS::ELB::Errors::InvalidConfigurationRequest => e
408
+ rescue ::Aws::ElasticLoadBalancing::Errors::InvalidConfigurationRequest => e
409
409
  Chef::Log.error "You cannot currently move from 1 subnet to another in the same availability zone. " +
410
410
  "Amazon does not have an atomic operation which allows this. You must create a new " +
411
411
  "ELB with the correct subnets and move instances into it. Tried to attach subets " +
@@ -433,7 +433,7 @@ module AWSDriver
433
433
  # Update listeners - THIS IS NOT ATOMIC
434
434
  if lb_options[:listeners]
435
435
  add_listeners = {}
436
- lb_options[:listeners].each { |l| add_listeners[l[:port]] = l }
436
+ lb_options[:listeners].each { |l| add_listeners[l[:load_balancer_port]] = l }
437
437
  actual_elb.listeners.each do |listener|
438
438
  desired_listener = add_listeners.delete(listener.port)
439
439
  if desired_listener
@@ -470,7 +470,7 @@ module AWSDriver
470
470
  end
471
471
  end
472
472
  add_listeners.values.each do |listener|
473
- updates = [ " add listener #{listener[:port]}" ]
473
+ updates = [ " add listener #{listener[:load_balanacer_port]}" ]
474
474
  updates << " set protocol to #{listener[:protocol].inspect}"
475
475
  updates << " set instance port to #{listener[:instance_port].inspect}"
476
476
  updates << " set instance protocol to #{listener[:instance_protocol].inspect}"
@@ -640,10 +640,10 @@ module AWSDriver
640
640
  return if lb_spec == nil
641
641
 
642
642
  actual_elb = load_balancer_for(lb_spec)
643
- if actual_elb && actual_elb.exists?
643
+ if actual_elb
644
644
  # Remove ELB from AWS
645
645
  action_handler.perform_action "Deleting EC2 ELB #{lb_spec.id}" do
646
- actual_elb.delete
646
+ elb.delete_load_balancer({load_balancer_name: actual_elb.load_balancer_name })
647
647
  end
648
648
  end
649
649
 
@@ -868,6 +868,96 @@ EOD
868
868
  strategy.cleanup_convergence(action_handler, machine_spec)
869
869
  end
870
870
 
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
+ def ec2
878
+ @ec2 ||= ::Aws::EC2::Client.new(aws_config)
879
+ end
880
+
881
+ AWS_V2_SERVICES.each do |load_name, short_name|
882
+ class_eval <<-META
883
+
884
+ def #{short_name}_client
885
+ @#{short_name}_client ||= ::Aws::#{load_name}::Client.new(**aws_config_2)
886
+ end
887
+
888
+ def #{short_name}_resource
889
+ @#{short_name}_resource ||= ::Aws::#{load_name}::Resource.new(**(aws_config_2.merge({client: #{short_name}_client})))
890
+ end
891
+
892
+ META
893
+ end
894
+
895
+ def elb
896
+ @elb ||= ::Aws::ElasticLoadBalancing::Client.new(aws_config)
897
+ end
898
+
899
+ def elasticache
900
+ @elasticache ||= ::Aws::ElastiCache::Client.new(config: aws_config)
901
+ end
902
+
903
+ def iam
904
+ @iam ||= ::Aws::IAM::Client.new(aws_config)
905
+ end
906
+
907
+ def rds
908
+ @rds ||= ::Aws::RDS::Client.new(aws_config)
909
+ end
910
+
911
+ def s3_client
912
+ @s3 ||= ::Aws::S3::Client.new( aws_config)
913
+ end
914
+
915
+ def sns
916
+ @sns ||= ::Aws::SNS::Client.new(aws_config)
917
+ end
918
+
919
+ def sqs
920
+ @sqs ||= ::Aws::SQS::Client.new(aws_config)
921
+ end
922
+
923
+ def auto_scaling
924
+ @auto_scaling ||= ::Aws::AutoScaling.new(config: aws_config)
925
+ end
926
+
927
+ def build_arn(partition: 'aws', service: nil, region: aws_config[:region], account_id: self.account_id, resource: nil)
928
+ "arn:#{partition}:#{service}:#{region}:#{account_id}:#{resource}"
929
+ end
930
+
931
+ def parse_arn(arn)
932
+ parts = arn.split(':', 6)
933
+ {
934
+ partition: parts[1],
935
+ service: parts[2],
936
+ region: parts[3],
937
+ account_id: parts[4],
938
+ resource: parts[5]
939
+ }
940
+ end
941
+
942
+ def account_id
943
+ begin
944
+ # We've got an AWS account root credential or an IAM admin with access rights
945
+ current_user = iam.get_user
946
+ arn = current_user[:user][:arn]
947
+ rescue ::Aws::IAM::Errors::AccessDenied => e
948
+ # If we don't have access, the error message still tells us our account ID and user ...
949
+ # https://forums.aws.amazon.com/thread.jspa?messageID=394344
950
+ if e.to_s !~ /\b(arn:aws:iam::[0-9]{12}:\S*)/
951
+ raise "IAM error response for GetUser did not include user ARN. Can't retrieve account ID."
952
+ end
953
+ arn = $1
954
+ end
955
+ parse_arn(arn)[:account_id]
956
+ end
957
+
958
+ # For creating things like AWS keypairs exclusively
959
+ @@chef_default_lock = Mutex.new
960
+
871
961
  def machine_for(machine_spec, machine_options, instance = nil)
872
962
  instance ||= instance_for(machine_spec)
873
963
 
@@ -982,9 +1072,9 @@ EOD
982
1072
  def keypair_for(bootstrap_options)
983
1073
  if bootstrap_options[:key_name]
984
1074
  keypair_name = bootstrap_options[:key_name]
985
- actual_key_pair = ec2.key_pairs[keypair_name]
1075
+ actual_key_pair = ec2_resource.key_pair(keypair_name)
986
1076
  if !actual_key_pair.exists?
987
- ec2.key_pairs.create(keypair_name)
1077
+ ec2_resource.key_pairs.create(keypair_name)
988
1078
  end
989
1079
  actual_key_pair
990
1080
  end
@@ -1367,7 +1457,7 @@ EOD
1367
1457
  instance ||= instance_for(machine_spec)
1368
1458
  sleep_time = 10
1369
1459
  transport = transport_for(machine_spec, machine_options, instance)
1370
- unless transport.available?
1460
+ unless instance.state.name.eql?("running")
1371
1461
  if action_handler.should_perform_actions
1372
1462
  action_handler.report_progress "waiting for #{machine_spec.name} (#{instance.id} on #{driver_url}) to be connectable (transport up and running) ..."
1373
1463
  max_wait_time = Chef::Config.chef_provisioning[:machine_max_wait_time] || 120
@@ -1487,7 +1577,7 @@ EOD
1487
1577
  def converge_elb_tags(aws_object, tags, action_handler)
1488
1578
  elb_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::ELB.new(
1489
1579
  elb_client,
1490
- aws_object.name,
1580
+ aws_object,
1491
1581
  tags
1492
1582
  )
1493
1583
  aws_tagger = Chef::Provisioning::AWSDriver::AWSTagger.new(elb_strategy, action_handler)
@@ -1553,7 +1643,7 @@ EOD
1553
1643
  from.delete(:instance_port)
1554
1644
  from.delete(:instance_protocol)
1555
1645
  to = get_listener(to)
1556
- to.delete(:port)
1646
+ to.delete(:load_balancer_port)
1557
1647
  to.delete(:protocol)
1558
1648
  to.merge(from)
1559
1649
  end
@@ -1573,21 +1663,21 @@ EOD
1573
1663
  when Hash
1574
1664
  result.merge!(listener)
1575
1665
  when Array
1576
- result[:port] = listener[0] if listener.size >= 1
1666
+ result[:load_balancer_port] = listener[0] if listener.size >= 1
1577
1667
  result[:protocol] = listener[1] if listener.size >= 2
1578
1668
  when Symbol,String
1579
1669
  result[:protocol] = listener
1580
1670
  when Integer
1581
- result[:port] = listener
1671
+ result[:load_balancer_port] = listener
1582
1672
  else
1583
1673
  raise "Invalid listener #{listener}"
1584
1674
  end
1585
1675
 
1586
1676
  # If either port or protocol are set, set the other
1587
- if result[:port] && !result[:protocol]
1588
- result[:protocol] = PROTOCOL_DEFAULTS[result[:port]]
1589
- elsif result[:protocol] && !result[:port]
1590
- result[:port] = PORT_DEFAULTS[result[:protocol]]
1677
+ if result[:load_balancer_port] && !result[:protocol]
1678
+ result[:protocol] = PROTOCOL_DEFAULTS[result[:load_balancer_port]]
1679
+ elsif result[:protocol] && !result[:load_balancer_port]
1680
+ result[:load_balancer_port] = PORT_DEFAULTS[result[:protocol]]
1591
1681
  end
1592
1682
  if result[:instance_port] && !result[:instance_protocol]
1593
1683
  result[:instance_protocol] = PROTOCOL_DEFAULTS[result[:instance_port]]
@@ -1596,7 +1686,7 @@ EOD
1596
1686
  end
1597
1687
 
1598
1688
  # If instance_port is still unset, copy port/protocol over
1599
- result[:instance_port] ||= result[:port]
1689
+ result[:instance_port] ||= result[:load_balancer_port]
1600
1690
  result[:instance_protocol] ||= result[:protocol]
1601
1691
 
1602
1692
  result
@@ -12,7 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
12
12
  def aws_tagger
13
13
  @aws_tagger ||= begin
14
14
  rds_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::RDS.new(
15
- new_resource.driver.rds.client,
15
+ new_resource.driver.rds,
16
16
  construct_arn(new_resource),
17
17
  new_resource.aws_tags
18
18
  )
@@ -26,15 +26,15 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
26
26
  # http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN
27
27
  def construct_arn(new_resource)
28
28
  @arn ||= begin
29
- region = new_resource.driver.region
29
+ region = new_resource.driver.aws_config[:region]
30
30
  name = new_resource.name
31
31
  rds_type = new_resource.rds_tagging_type
32
32
  # Taken from example on https://forums.aws.amazon.com/thread.jspa?threadID=108012
33
33
  account_id = begin
34
- u = new_resource.driver.iam.client.get_user
34
+ u = new_resource.driver.iam.get_user
35
35
  # We've got an AWS account root credential or an IAM admin with access rights
36
36
  u[:user][:arn].match('^arn:aws:iam::([0-9]{12}):.*$')[1]
37
- rescue AWS::IAM::Errors::AccessDenied => e
37
+ rescue ::Aws::IAM::Errors::AccessDenied => e
38
38
  # We've got an AWS IAM Credential
39
39
  e.to_s.match('^User: arn:aws:iam::([0-9]{12}):.*$')[1]
40
40
  end
@@ -16,7 +16,7 @@ class S3
16
16
  bucket: bucket_name
17
17
  })
18
18
  Hash[resp.tag_set.map {|t| [t.key, t.value]}]
19
- rescue Aws::S3::Errors::NoSuchTagSet => e
19
+ rescue ::Aws::S3::Errors::NoSuchTagSet => e
20
20
  # Instead of returning nil or empty, AWS raises an error :)
21
21
  {}
22
22
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module AWSDriver
4
- VERSION = '2.2.2'
4
+ VERSION = '3.0.0-rc1'
5
5
  end
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ require 'chef/provisioning/aws_driver/aws_resource'
3
3
  class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSResource
4
4
  include Chef::Provisioning::AWSDriver::AWSTaggable
5
5
 
6
- aws_sdk_type AWS::AutoScaling::Group
6
+ aws_sdk_type ::Aws::AutoScaling::AutoScalingGroup
7
7
 
8
8
  attribute :name, kind_of: String, name_attribute: true
9
9
  attribute :options, kind_of: Hash, default: {}
@@ -17,7 +17,7 @@ class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSRe
17
17
  attribute :scaling_policies, kind_of: Hash, default: {}
18
18
 
19
19
  def aws_object
20
- result = driver.auto_scaling.groups[name]
20
+ result = driver.auto_scaling_resource.group(name)
21
21
  result && result.exists? ? result : nil
22
22
  end
23
23
  end
@@ -6,7 +6,7 @@ require 'chef/resource/aws_security_group'
6
6
  # @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_cluster-instance_method
7
7
  class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResource
8
8
  # Note: There isn't actually an SDK class for Elasticache.
9
- aws_sdk_type AWS::ElastiCache
9
+ aws_sdk_type ::Aws::ElastiCache
10
10
 
11
11
  # See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_cluster-instance_method
12
12
  # for information on possible values for each attribute. Values are passed
@@ -63,9 +63,9 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
63
63
 
64
64
  # Security Groups
65
65
  #
66
- # @param :security_groups [String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup] one or more VPC security groups associated with the cache cluster.
66
+ # @param :security_groups [String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup] one or more VPC security groups associated with the cache cluster.
67
67
  attribute :security_groups,
68
- kind_of: [ String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup ],
68
+ kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
69
69
  required: true,
70
70
  coerce: proc { |v| [v].flatten }
71
71
 
@@ -74,7 +74,7 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
74
74
  driver.elasticache
75
75
  .describe_cache_clusters(cache_cluster_id: cluster_name)
76
76
  .data[:cache_clusters].first
77
- rescue AWS::ElastiCache::Errors::CacheClusterNotFound
77
+ rescue ::Aws::ElastiCache::Errors::CacheClusterNotFound
78
78
  nil
79
79
  end
80
80
  end
@@ -5,7 +5,7 @@ require 'chef/resource/aws_security_group'
5
5
  # @see See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
6
6
  class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::AWSResource
7
7
  # Note: There isn't actually an SDK class for Elasticache.
8
- aws_sdk_type AWS::ElastiCache
8
+ aws_sdk_type ::Aws::ElastiCache
9
9
 
10
10
  # See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_replication_group-instance_method
11
11
  # for information on possible values for each attribute. Values are passed
@@ -56,7 +56,7 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
56
56
  #
57
57
  # @param
58
58
  attribute :security_groups,
59
- kind_of: [ String, Array, AwsSecurityGroup, AWS::EC2::SecurityGroup ],
59
+ kind_of: [ String, Array, AwsSecurityGroup, ::Aws::EC2::SecurityGroup ],
60
60
  required: true,
61
61
  coerce: proc { |v| [v].flatten }
62
62
 
@@ -72,7 +72,7 @@ class Chef::Resource::AwsCacheReplicationGroup < Chef::Provisioning::AWSDriver::
72
72
  driver.elasticache
73
73
  .describe_replication_groups(replication_group_id: group_name)
74
74
  .data[:replication_groups].first
75
- rescue AWS::ElastiCache::Errors::ReplicationGroupNotFoundFault
75
+ rescue ::Aws::ElastiCache::Errors::ReplicationGroupNotFoundFault
76
76
  nil
77
77
  end
78
78
  end