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
@@ -5,7 +5,7 @@ require 'chef/resource/aws_subnet'
5
5
  # @see http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_subnet_group-instance_method
6
6
  class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSResource
7
7
  # Note: There isn't actually an SDK class for Elasticache.
8
- aws_sdk_type AWS::ElastiCache, id: :group_name
8
+ aws_sdk_type ::Aws::ElastiCache, id: :group_name
9
9
 
10
10
  # See http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/ElastiCache/Client/V20140930.html#create_cache_subnet_group-instance_method
11
11
  # for information on possible values for each attribute. Values are passed
@@ -24,9 +24,9 @@ class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSRe
24
24
 
25
25
  # Subnets
26
26
  #
27
- # @param :subnets [ String, Array, AwsSubnet, AWS::EC2::Subnet ] One or more subnets in the subnet group.
27
+ # @param :subnets [ String, Array, AwsSubnet, ::Aws::EC2::Subnet ] One or more subnets in the subnet group.
28
28
  attribute :subnets,
29
- kind_of: [ String, Array, AwsSubnet, AWS::EC2::Subnet ],
29
+ kind_of: [ String, Array, AwsSubnet, ::Aws::EC2::Subnet ],
30
30
  required: true,
31
31
  coerce: proc { |v| [v].flatten }
32
32
 
@@ -35,7 +35,7 @@ class Chef::Resource::AwsCacheSubnetGroup < Chef::Provisioning::AWSDriver::AWSRe
35
35
  driver.elasticache
36
36
  .describe_cache_subnet_groups(cache_subnet_group_name: group_name)
37
37
  .data[:cache_subnet_groups].first
38
- rescue AWS::ElastiCache::Errors::CacheSubnetGroupNotFoundFault
38
+ rescue ::Aws::ElastiCache::Errors::CacheSubnetGroupNotFoundFault
39
39
  nil
40
40
  end
41
41
  end
@@ -11,7 +11,7 @@ module AWS
11
11
  end
12
12
 
13
13
  class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSResource
14
- aws_sdk_type ::AWS::CloudSearch::Domain
14
+ aws_sdk_type ::Aws::CloudSearchDomain
15
15
  attribute :name, kind_of: String, name_attribute: true
16
16
  attribute :cloudsearch_api_version, equal_to: ["20130101", "20110201"], default: "20130101"
17
17
 
@@ -14,7 +14,7 @@ class Chef::Resource::AwsCloudwatchAlarm < Chef::Provisioning::AWSDriver::AWSRes
14
14
  attribute :evaluation_periods, :kind_of => Integer
15
15
  attribute :period, :kind_of => [Integer,Float], coerce: proc {|v| v.to_f}
16
16
  attribute :statistic, :kind_of => String
17
- attribute :threshold, :kind_of => Integer
17
+ attribute :threshold, :kind_of => [Integer,Float]
18
18
  attribute :insufficient_data_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
19
19
  attribute :ok_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
20
20
  attribute :alarm_actions, :kind_of => Array, coerce: proc {|v| [v].flatten}
@@ -13,7 +13,7 @@ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
13
13
  class Chef::Resource::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
14
14
  include Chef::Provisioning::AWSDriver::AWSTaggable
15
15
 
16
- aws_sdk_type AWS::EC2::DHCPOptions
16
+ aws_sdk_type ::Aws::EC2::DhcpOptions
17
17
 
18
18
  #
19
19
  # The Chef "idempotence name" of this DHCP options set.
@@ -53,7 +53,14 @@ class Chef::Resource::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSResourc
53
53
 
54
54
  def aws_object
55
55
  driver, id = get_driver_and_id
56
- result = driver.ec2.dhcp_options[id] if id
57
- result && result.exists? ? result : nil
56
+ ec2_resource = ::Aws::EC2::Resource.new(driver.ec2)
57
+ result = ec2_resource.dhcp_options(id) if id
58
+ result && exists?(result) ? result : nil
59
+ end
60
+
61
+ def exists?(result)
62
+ return true if result.data
63
+ rescue ::Aws::EC2::Errors::InvalidDhcpOptionIDNotFound
64
+ return false
58
65
  end
59
66
  end
@@ -4,11 +4,11 @@ require 'chef/resource/aws_instance'
4
4
  class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
5
5
  include Chef::Provisioning::AWSDriver::AWSTaggable
6
6
 
7
- aws_sdk_type AWS::EC2::Volume, backcompat_data_bag_name: 'ebs_volumes'
7
+ aws_sdk_type ::Aws::EC2::Volume, backcompat_data_bag_name: 'ebs_volumes'
8
8
 
9
9
  attribute :name, kind_of: String, name_attribute: true
10
10
 
11
- attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance, ::Aws::EC2::Instance ]
11
+ attribute :machine, kind_of: [ String, FalseClass, AwsInstance, ::Aws::EC2::Instance, ::Aws::EC2::Instance ]
12
12
 
13
13
  attribute :availability_zone, kind_of: String, default: 'a'
14
14
  attribute :size, kind_of: Integer, default: 8
@@ -25,7 +25,13 @@ class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceW
25
25
 
26
26
  def aws_object
27
27
  driver, id = get_driver_and_id
28
- result = driver.ec2.volumes[id] if id
29
- result && result.exists? && ![:deleted, :deleting].include?(result.status) ? result : nil
28
+ result = driver.ec2_resource.volume(id) if id
29
+ result && exists?(result) && ![:deleted, :deleting].include?(result.state) ? result : nil
30
+ end
31
+
32
+ def exists?(result)
33
+ return true if result.data
34
+ rescue ::Aws::EC2::Errors::InvalidVolumeNotFound
35
+ return false
30
36
  end
31
37
  end
@@ -1,7 +1,7 @@
1
1
  require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
2
 
3
3
  class Chef::Resource::AwsEipAddress < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
4
- aws_sdk_type AWS::EC2::ElasticIp, option_names: [ :public_ip ], id: :public_ip, managed_entry_id_name: 'public_ip', backcompat_data_bag_name: 'eip_addresses'
4
+ aws_sdk_type ::Aws::OpsWorks::Types::ElasticIp, option_names: [ :public_ip ], id: :public_ip, managed_entry_id_name: 'public_ip', backcompat_data_bag_name: 'eip_addresses'
5
5
 
6
6
  attribute :name, kind_of: String, name_attribute: true
7
7
 
@@ -12,12 +12,12 @@ class Chef::Resource::AwsEipAddress < Chef::Provisioning::AWSDriver::AWSResource
12
12
  # Like other aws_id_attributes, this is read-only - you cannot provide it and expect
13
13
  # aws to honor it
14
14
  attribute :public_ip, kind_of: String, aws_id_attribute: true,
15
- default: lazy { name =~ /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/ ? name : nil }
15
+ default: lazy { name =~ /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/ ? name : nil }
16
16
 
17
17
  def aws_object
18
18
  driver, public_ip = get_driver_and_id
19
- result = driver.ec2.elastic_ips[public_ip] if public_ip
20
- result && result.exists? ? result : nil
19
+ result = driver.ec2.describe_addresses.addresses.find { |b| b.public_ip == public_ip }
20
+ result && !result.empty? ? result : nil
21
21
  end
22
22
 
23
23
  def action(*args)
@@ -10,7 +10,7 @@ end
10
10
  class Chef::Resource::AwsElasticsearchDomain < Chef::Provisioning::AWSDriver::AWSResource
11
11
  include Chef::Provisioning::AWSDriver::AWSTaggable
12
12
 
13
- aws_sdk_type ::AWS::Elasticsearch::Domain
13
+ aws_sdk_type ::Aws::CloudSearchDomain
14
14
 
15
15
  attribute :domain_name, kind_of: String, name_attribute: true
16
16
 
@@ -44,7 +44,7 @@ class Chef::Resource::AwsIamRole < Chef::Provisioning::AWSDriver::AWSResource
44
44
  #
45
45
  # TODO: add when we get a policy resource
46
46
  #
47
- # attribute :managed_policies, kind_of: [Array, String, ::Aws::Iam::Policy, AwsIamPolicy], coerce: proc { |value| [value].flatten }
47
+ # attribute :managed_policies, kind_of: [Array, String, ::Aws::IAM::Policy, AwsIamPolicy], coerce: proc { |value| [value].flatten }
48
48
 
49
49
  def aws_object
50
50
  driver.iam_resource.role(name).load
@@ -12,7 +12,7 @@
12
12
  class Chef::Resource::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
13
13
  include Chef::Provisioning::AWSDriver::AWSTaggable
14
14
 
15
- aws_sdk_type AWS::EC2::InternetGateway, id: :id
15
+ aws_sdk_type ::Aws::EC2::InternetGateway, id: :id
16
16
 
17
17
  require 'chef/resource/aws_vpc'
18
18
 
@@ -34,7 +34,7 @@ class Chef::Resource::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSRes
34
34
  # - An actual `aws_vpc` resource.
35
35
  # - An AWS `VPC` object.
36
36
  #
37
- attribute :vpc, kind_of: [ String, AwsVpc, AWS::EC2::VPC ]
37
+ attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
38
38
 
39
39
  attribute :internet_gateway_id, kind_of: String, aws_id_attribute: true, default: lazy {
40
40
  name =~ /^igw-[a-f0-9]{8}$/ ? name : nil
@@ -42,7 +42,14 @@ class Chef::Resource::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSRes
42
42
 
43
43
  def aws_object
44
44
  driver, id = get_driver_and_id
45
- result = driver.ec2.internet_gateways[id] if id
46
- result && result.exists? ? result : nil
45
+ ec2_resource = ::Aws::EC2::Resource.new(driver.ec2)
46
+ result = ec2_resource.internet_gateway(id) if id
47
+ result && exists?(result) ? result : nil
48
+ end
49
+
50
+ def exists?(result)
51
+ return true if result.data
52
+ rescue ::Aws::EC2::Errors::InvalidInternetGatewayIDNotFound
53
+ return false
47
54
  end
48
55
  end
@@ -1,7 +1,7 @@
1
1
  require 'chef/provisioning/aws_driver/aws_resource'
2
2
 
3
3
  class Chef::Resource::AwsKeyPair < Chef::Provisioning::AWSDriver::AWSResource
4
- aws_sdk_type AWS::EC2::KeyPair, id: :name
4
+ aws_sdk_type ::Aws::EC2::KeyPair, id: :name
5
5
 
6
6
  # Private key to use as input (will be generated if it does not exist)
7
7
  attribute :private_key_path, :kind_of => String
@@ -14,7 +14,8 @@ class Chef::Resource::AwsKeyPair < Chef::Provisioning::AWSDriver::AWSResource
14
14
  attribute :allow_overwrite, :kind_of => [TrueClass, FalseClass], :default => false
15
15
 
16
16
  def aws_object
17
- result = driver.ec2.key_pairs[name]
18
- result && result.exists? ? result : nil
17
+ resource = ::Aws::EC2::Resource.new(driver.ec2)
18
+ result = resource.key_pairs.find{|b| b.name==name}
19
+ result
19
20
  end
20
21
  end
@@ -1,15 +1,16 @@
1
1
  require 'chef/provisioning/aws_driver/aws_resource'
2
2
 
3
3
  class Chef::Resource::AwsLaunchConfiguration < Chef::Provisioning::AWSDriver::AWSResource
4
- aws_sdk_type AWS::AutoScaling::LaunchConfiguration, id: :name
4
+ aws_sdk_type ::Aws::AutoScaling::LaunchConfiguration, id: :name
5
5
 
6
6
  attribute :name, kind_of: String, name_attribute: true
7
- attribute :image, kind_of: [ String, AWS::EC2::Image, ::Aws::EC2::Image ]
7
+ attribute :image, kind_of: [ String, ::Aws::EC2::Image, ::Aws::EC2::Image ]
8
8
  attribute :instance_type, kind_of: String
9
9
  attribute :options, kind_of: Hash, default: {}
10
10
 
11
11
  def aws_object
12
- result = driver.auto_scaling.launch_configurations[name]
13
- result && result.exists? ? result : nil
12
+ launchconfig = ::Aws::AutoScaling::LaunchConfiguration.new(name,{client: driver.auto_scaling_client} )
13
+ result = launchconfig.data
14
+ result
14
15
  end
15
16
  end
@@ -4,7 +4,7 @@ require 'chef/provisioning/aws_driver/aws_taggable'
4
4
  class Chef::Resource::AwsLoadBalancer < Chef::Provisioning::AWSDriver::AWSResource
5
5
  include Chef::Provisioning::AWSDriver::AWSTaggable
6
6
 
7
- aws_sdk_type AWS::ELB::LoadBalancer
7
+ aws_sdk_type ::Aws::AutoScaling::LoadBalancer
8
8
 
9
9
  attribute :name, kind_of: String, name_attribute: true
10
10
 
@@ -13,7 +13,18 @@ class Chef::Resource::AwsLoadBalancer < Chef::Provisioning::AWSDriver::AWSResour
13
13
  }
14
14
 
15
15
  def aws_object
16
- result = driver.elb.load_balancers[name]
17
- result && result.exists? ? result : nil
16
+ result=nil
17
+ begin
18
+ result = driver.elb.describe_load_balancers({ load_balancer_names: [name] }).load_balancer_descriptions
19
+ if result.length == 1
20
+ result = result[0]
21
+ else
22
+ raise "Must have 0 or 1 load balancers which match name!"
23
+ end
24
+ rescue ::Aws::ElasticLoadBalancing::Errors::LoadBalancerNotFound => e
25
+ Chef::Log.debug("No loadbalancer named #{name} - returning nil!")
26
+ result = nil
27
+ end
28
+ result
18
29
  end
19
30
  end
@@ -15,7 +15,7 @@
15
15
  # We provide this class because the AWS SDK V2 does not provide it (as of
16
16
  # May 2016). We copied the pattern in their SDK so when they do add a real
17
17
  # resource there shouldn't be a need for much translation.
18
- class Aws::EC2::NatGateway < Aws::Resources::Resource
18
+ class Aws::EC2::NatGateway < ::Aws::Resources::Resource
19
19
  attr_reader :resource, :id, :nat_gateway_id, :vpc_id, :subnet_id, :nat_gateway_addresses
20
20
 
21
21
  def initialize(id, options = {})
@@ -84,7 +84,7 @@ class Chef::Resource::AwsNatGateway < Chef::Provisioning::AWSDriver::AWSResource
84
84
  # - An actual `aws_eip_address` resource.
85
85
  # - nil, meaning that no EIP exists yet and needs to be created.
86
86
  #
87
- attribute :eip_address, kind_of: [ String, AWS::EC2::ElasticIp, AwsEipAddress, nil ], default: nil
87
+ attribute :eip_address, kind_of: [ String, ::Aws::OpsWorks::Types::ElasticIp, AwsEipAddress, nil ], default: nil
88
88
 
89
89
  attribute :nat_gateway_id, kind_of: String, aws_id_attribute: true, default: lazy {
90
90
  name =~ /^nat-[A-Fa-f0-9]{17}$/ ? name : nil
@@ -5,7 +5,7 @@ require 'chef/resource/aws_subnet'
5
5
  class Chef::Resource::AwsNetworkAcl < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
6
6
  include Chef::Provisioning::AWSDriver::AWSTaggable
7
7
 
8
- aws_sdk_type AWS::EC2::NetworkACL
8
+ aws_sdk_type ::Aws::EC2::NetworkAcl
9
9
 
10
10
  #
11
11
  # The name of this network acl.
@@ -20,7 +20,7 @@ class Chef::Resource::AwsNetworkAcl < Chef::Provisioning::AWSDriver::AWSResource
20
20
  # - An actual `aws_vpc` resource.
21
21
  # - An AWS `VPC` object.
22
22
  #
23
- attribute :vpc, kind_of: [ String, AwsVpc, AWS::EC2::VPC ]
23
+ attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
24
24
 
25
25
  #
26
26
  # Accepts rules in the format:
@@ -50,14 +50,14 @@ class Chef::Resource::AwsNetworkAcl < Chef::Provisioning::AWSDriver::AWSResource
50
50
 
51
51
  def aws_object
52
52
  driver, id = get_driver_and_id
53
- result = driver.ec2.network_acls[id] if id
54
- begin
55
- # network_acls don't have an `exists?` method so have to query an attribute
56
- result.vpc_id
57
- result
58
- rescue AWS::EC2::Errors::InvalidNetworkAclID::NotFound
59
- nil
60
- end
53
+ result = driver.ec2_resource.network_acl(id) if id
54
+ result && exists?(result) ? result : nil
55
+ end
56
+
57
+ def exists?(result)
58
+ return true if result.data
59
+ rescue ::Aws::EC2::Errors::InvalidNetworkAclIDNotFound
60
+ return false
61
61
  end
62
62
 
63
63
  end
@@ -5,7 +5,7 @@ require 'chef/resource/aws_eip_address'
5
5
  class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
6
6
  include Chef::Provisioning::AWSDriver::AWSTaggable
7
7
 
8
- aws_sdk_type AWS::EC2::NetworkInterface, option_names: []
8
+ aws_sdk_type ::Aws::EC2::NetworkInterface, option_names: []
9
9
 
10
10
  attribute :name, kind_of: String, name_attribute: true
11
11
 
@@ -13,7 +13,7 @@ class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSRe
13
13
  name =~ /^eni-[a-f0-9]{8}$/ ? name : nil
14
14
  }
15
15
 
16
- attribute :subnet, kind_of: [ String, AWS::EC2::Subnet, AwsSubnet ]
16
+ attribute :subnet, kind_of: [ String, ::Aws::EC2::Subnet, AwsSubnet ]
17
17
 
18
18
  attribute :private_ip_address, kind_of: String
19
19
 
@@ -21,16 +21,22 @@ class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSRe
21
21
 
22
22
  attribute :security_groups, kind_of: Array #(Array<SecurityGroup>, Array<String>)
23
23
 
24
- attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance, ::Aws::EC2::Instance ]
24
+ attribute :machine, kind_of: [ String, FalseClass, AwsInstance, ::Aws::EC2::Instance, ::Aws::EC2::Instance ]
25
25
 
26
26
  attribute :device_index, kind_of: Integer
27
27
 
28
28
  # TODO implement eip address association
29
- #attribute :elastic_ip_address, kind_of: [ String, AWS::EC2::ElasticIp, AwsEipAddress, FalseClass ]
29
+ #attribute :elastic_ip_address, kind_of: [ String, ::Aws::OpsWorks::Types::ElasticIp, AwsEipAddress, FalseClass ]
30
30
 
31
31
  def aws_object
32
32
  driver, id = get_driver_and_id
33
- result = driver.ec2.network_interfaces[id] if id
34
- result && result.exists? ? result : nil
33
+ result = driver.ec2_resource.network_interface(id) if id
34
+ result && exists?(result) ? result : nil
35
+ end
36
+
37
+ def exists?(result)
38
+ return true if result.data
39
+ rescue ::Aws::EC2::Errors::InvalidNetworkInterfaceIDNotFound
40
+ return false
35
41
  end
36
42
  end
@@ -5,7 +5,7 @@ class Chef::Resource::AwsRdsParameterGroup < Chef::Provisioning::AWSDriver::AWSR
5
5
  include Chef::Provisioning::AWSDriver::AWSTaggable
6
6
 
7
7
  # there is no class for a parameter group specifically
8
- aws_sdk_type AWS::RDS
8
+ aws_sdk_type ::Aws::RDS
9
9
 
10
10
  attribute :name, kind_of: String, name_attribute: true
11
11
  attribute :db_parameter_group_family, kind_of: String, required: true
@@ -13,21 +13,21 @@ class Chef::Resource::AwsRdsParameterGroup < Chef::Provisioning::AWSDriver::AWSR
13
13
  attribute :parameters, kind_of: Array, default: []
14
14
 
15
15
  def aws_object
16
- object = driver.rds.client.describe_db_parameter_groups(db_parameter_group_name: name)[:db_parameter_groups].first
16
+ object = driver.rds.describe_db_parameter_groups(db_parameter_group_name: name)[:db_parameter_groups].first
17
17
 
18
18
  # use paginated API to get all options
19
- initial_request = driver.rds.client.describe_db_parameters(db_parameter_group_name: name, max_records: 100)
19
+ initial_request = driver.rds.describe_db_parameters(db_parameter_group_name: name, max_records: 100)
20
20
  marker = initial_request[:marker]
21
21
  parameters = initial_request[:parameters]
22
22
  while !marker.nil?
23
- more_results = driver.rds.client.describe_db_parameters(db_parameter_group_name: name, max_records: 100, marker: marker)
23
+ more_results = driver.rds.describe_db_parameters(db_parameter_group_name: name, max_records: 100, marker: marker)
24
24
  parameters += more_results[:parameters]
25
25
  marker = more_results[:marker]
26
26
  end
27
- object[:parameters] = parameters
27
+ # object[:parameters] = parameters
28
28
 
29
29
  object
30
- rescue AWS::RDS::Errors::DBParameterGroupNotFound
30
+ rescue ::Aws::RDS::Errors::DBParameterGroupNotFound
31
31
  nil
32
32
  end
33
33
 
@@ -5,19 +5,18 @@ require 'chef/resource/aws_subnet'
5
5
  class Chef::Resource::AwsRdsSubnetGroup < Chef::Provisioning::AWSDriver::AWSRDSResource
6
6
  include Chef::Provisioning::AWSDriver::AWSTaggable
7
7
 
8
- aws_sdk_type AWS::RDS
8
+ aws_sdk_type ::Aws::RDS
9
9
 
10
10
  attribute :name, kind_of: String, name_attribute: true
11
11
  attribute :description, kind_of: String, required: true
12
12
  attribute :subnets,
13
- kind_of: [ String, Array, AwsSubnet, AWS::EC2::Subnet ],
13
+ kind_of: [ String, Array, AwsSubnet, ::Aws::EC2::Subnet ],
14
14
  required: true,
15
15
  coerce: proc { |v| [v].flatten }
16
16
 
17
17
  def aws_object
18
- driver.rds.client
19
- .describe_db_subnet_groups(db_subnet_group_name: name)[:db_subnet_groups].first
20
- rescue AWS::RDS::Errors::DBSubnetGroupNotFoundFault
18
+ driver.rds.describe_db_subnet_groups(db_subnet_group_name: name)[:db_subnet_groups].first
19
+ rescue ::Aws::RDS::Errors::DBSubnetGroupNotFoundFault
21
20
  # triggered by describe_db_subnet_groups when the group can't
22
21
  # be found
23
22
  nil
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- class Aws::Route53::Types::ResourceRecordSet
18
+ class ::Aws::Route53::Types::ResourceRecordSet
19
19
  # removing AWS's trailing dots may not be the best thing, but otherwise our job gets much harder.
20
20
  def aws_key
21
21
  "#{name.sub(/\.$/, '')}"
@@ -33,7 +33,7 @@ class Chef::Resource::AwsRouteTable < Chef::Provisioning::AWSDriver::AWSResource
33
33
  #
34
34
  # This is required for new route tables.
35
35
  #
36
- attribute :vpc, kind_of: [ String, AwsVpc, AWS::EC2::VPC ], required: true
36
+ attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ], required: true
37
37
 
38
38
  #
39
39
  # Enable route propagation from one or more virtual private gateways
@@ -3,7 +3,7 @@ require 'chef/provisioning/aws_driver/aws_resource'
3
3
  class Chef::Resource::AwsS3Bucket < Chef::Provisioning::AWSDriver::AWSResource
4
4
  include Chef::Provisioning::AWSDriver::AWSTaggable
5
5
 
6
- aws_sdk_type AWS::S3::Bucket, id: :name
6
+ aws_sdk_type ::Aws::S3::Bucket, id: :name
7
7
 
8
8
  attribute :name, :kind_of => String, :name_attribute => true
9
9
  attribute :options, :kind_of => Hash, :default => {}
@@ -12,7 +12,8 @@ class Chef::Resource::AwsS3Bucket < Chef::Provisioning::AWSDriver::AWSResource
12
12
  attribute :recursive_delete, :kind_of => [TrueClass, FalseClass], :default => false
13
13
 
14
14
  def aws_object
15
- result = driver.s3.buckets[name]
15
+ resource = ::Aws::S3::Resource.new(driver.s3_client)
16
+ result = resource.buckets.find{|b| b.name==name}
16
17
  result && result.exists? ? result : nil
17
18
  end
18
19
  end