chef-provisioning-aws 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -0
  3. data/README.md +26 -39
  4. data/Rakefile +13 -5
  5. data/lib/chef/provider/aws_iam_instance_profile.rb +60 -0
  6. data/lib/chef/provider/aws_iam_role.rb +98 -0
  7. data/lib/chef/provider/aws_image.rb +1 -1
  8. data/lib/chef/provider/aws_internet_gateway.rb +75 -0
  9. data/lib/chef/provider/aws_route_table.rb +3 -2
  10. data/lib/chef/provider/aws_s3_bucket.rb +4 -1
  11. data/lib/chef/provider/aws_security_group.rb +1 -1
  12. data/lib/chef/provider/aws_vpc.rb +50 -45
  13. data/lib/chef/provisioning/aws_driver.rb +22 -1
  14. data/lib/chef/provisioning/aws_driver/aws_provider.rb +13 -5
  15. data/lib/chef/provisioning/aws_driver/aws_resource.rb +173 -165
  16. data/lib/chef/provisioning/aws_driver/credentials.rb +12 -0
  17. data/lib/chef/provisioning/aws_driver/driver.rb +82 -37
  18. data/lib/chef/provisioning/aws_driver/super_lwrp.rb +56 -43
  19. data/lib/chef/provisioning/aws_driver/version.rb +1 -1
  20. data/lib/chef/resource/aws_dhcp_options.rb +1 -1
  21. data/lib/chef/resource/aws_ebs_volume.rb +1 -1
  22. data/lib/chef/resource/aws_eip_address.rb +1 -1
  23. data/lib/chef/resource/aws_iam_instance_profile.rb +33 -0
  24. data/lib/chef/resource/aws_iam_role.rb +55 -0
  25. data/lib/chef/resource/aws_image.rb +1 -1
  26. data/lib/chef/resource/aws_instance.rb +1 -1
  27. data/lib/chef/resource/aws_internet_gateway.rb +36 -6
  28. data/lib/chef/resource/aws_load_balancer.rb +1 -1
  29. data/lib/chef/resource/aws_network_acl.rb +1 -1
  30. data/lib/chef/resource/aws_network_interface.rb +1 -1
  31. data/lib/chef/resource/aws_route53_hosted_zone.rb +261 -0
  32. data/lib/chef/resource/aws_route53_record_set.rb +162 -0
  33. data/lib/chef/resource/aws_route_table.rb +1 -1
  34. data/lib/chef/resource/aws_security_group.rb +1 -1
  35. data/lib/chef/resource/aws_sns_topic.rb +1 -1
  36. data/lib/chef/resource/aws_subnet.rb +1 -1
  37. data/lib/chef/resource/aws_vpc.rb +1 -1
  38. data/lib/chef/resource/aws_vpc_peering_connection.rb +1 -1
  39. data/spec/aws_support.rb +11 -13
  40. data/spec/aws_support/matchers/create_an_aws_object.rb +7 -1
  41. data/spec/aws_support/matchers/have_aws_object_tags.rb +1 -1
  42. data/spec/aws_support/matchers/match_an_aws_object.rb +7 -1
  43. data/spec/aws_support/matchers/update_an_aws_object.rb +8 -2
  44. data/spec/integration/aws_eip_address_spec.rb +74 -0
  45. data/spec/integration/aws_iam_instance_profile_spec.rb +159 -0
  46. data/spec/integration/aws_iam_role_spec.rb +177 -0
  47. data/spec/integration/aws_internet_gateway_spec.rb +161 -0
  48. data/spec/integration/aws_network_interface_spec.rb +3 -4
  49. data/spec/integration/aws_route53_hosted_zone_spec.rb +522 -0
  50. data/spec/integration/aws_route_table_spec.rb +52 -4
  51. data/spec/integration/aws_s3_bucket_spec.rb +1 -1
  52. data/spec/integration/load_balancer_spec.rb +303 -8
  53. data/spec/integration/machine_batch_spec.rb +1 -0
  54. data/spec/integration/machine_image_spec.rb +32 -17
  55. data/spec/integration/machine_spec.rb +11 -29
  56. data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +0 -1
  57. data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +105 -0
  58. metadata +48 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e520aad6f6cafb84d380454daf8dd65285e194cd
4
- data.tar.gz: b2ec1a747718d0cad0c4bdc9ca6561d1e0daeb6f
3
+ metadata.gz: 1ac3b4009283033918629bde10eae733c25b8a73
4
+ data.tar.gz: 486f831a4168454ad62c9b5ebccd48e7f57249d5
5
5
  SHA512:
6
- metadata.gz: 0c3d1891e4c22d14f3b03506f39105a884dae7bc00ad7dc2ace729f5325f7fbc935b29be11631387563529b19efcad224bb0e2447b77a0365dfd5f6969cfcc1c
7
- data.tar.gz: a52717acff8c3ccf2945863f616fd8fce022b11fa813b0c8ace68b737be6a797dbb8364cdd94d74884e206357ea786741c657cc1d581ec90502459e8d7e1f6b4
6
+ metadata.gz: 83fc3ef810c239b52c0c00246f08ba97fa5f4b4af3ab116324a7cdf52929815e9006ecc89e92837f1311510b0b9960ca43c41a50385e856bcc12a022a602efa6
7
+ data.tar.gz: 2dd1b0c595deccae3767740d0abe2d6058c2322ef214a16640dc4386c8586b09efcd39ad667ec29f21aadedbb835aba29b37556b67fb84e0d5bbf661946d5afd
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+ gem "simplecov"
3
+ gemspec
4
+
5
+ #gem 'chef-provisioning', path: '../chef-provisioning'
6
+ #gem 'chef-provisioning', github: 'chef/chef-provisioning', branch: 'master'
7
+ #gem "pry-byebug"
8
+ #gem "pry-stack_explorer"
data/README.md CHANGED
@@ -6,12 +6,20 @@ This README is a work in progress. Please add to it!
6
6
 
7
7
  ## Credentials
8
8
 
9
- AWS credentials should be specified in your `~/.aws/credentials` file as documented [here](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files). We support the use of profiles as well. If you do not specify a profile then we use the `default` profile.
9
+ There are 3 ways you can provide your AWS Credentials. We will look for credentials in the order from below and use the first one found. This precedence order is taken from http://docs.aws.amazon.com/sdkforruby/api/index.html#Configuration:
10
10
 
11
- You can specify a profile as the middle section of the semi-colon seperated driver url. For example, a driver url of `aws:staging:us-east-1` would use the profile `staging`.
11
+ 1. Through the environment variables `ENV["AWS_ACCESS_KEY_ID"]`, `ENV["AWS_SECRET_ACCESS_KEY"]` and optionally `ENV["AWS_SESSION_TOKEN"]`
12
+ 2. The shared credentials ini file. The default location is `~/.aws/credentials` but you can overwrite this by specifying `ENV["AWS_CONFIG_FILE"]`. You can specify
13
+ multiple profiles in this file and select one with the `ENV["AWS_DEFAULT_PROFILE"]`
14
+ environment variable or via the driver url. For example, a driver url of `aws:staging:us-east-1` would use the profile `staging`. If you do not specify a profile then the `default` one is used. Read
15
+ [this](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) for more information about profiles.
16
+ 3. From an instance profile when running on EC2. This accesses the local
17
+ metadata service to discover the local instance's IAM instance profile.
12
18
 
13
19
  ## Configurable Options
14
20
 
21
+ ### aws_retry_limit
22
+
15
23
  When using `machine_batch` with a large number of machines it is possible to overwhelm the AWS SDK until it starts returning `AWS::EC2::Errors::RequestLimitExceeded`. You can configure the AWS SDK to retry these errors automatically by specifying
16
24
 
17
25
  ```ruby
@@ -20,14 +28,22 @@ chef_provisioning({:aws_retry_limit => 10})
20
28
 
21
29
  in your client.rb for the provisioning workstation. The default `:aws_retry_limit` is 5.
22
30
 
31
+ ### image_max_wait_time and machine_max_wait_time
32
+
33
+ By default, the time we will wait for a `machine` to become ready or for the transport to become ready is 120 seconds (each).
34
+ For a `machine_image` we wait 300 seconds for the AMI to be created. These timeouts can be configured with
35
+
36
+ ```ruby
37
+ chef_provisioning({:image_max_wait_time => 600, :machine_max_wait_time => 240})
38
+ ```
39
+
40
+ in your client.rb for the provisioning workstation.
41
+
23
42
  # Resources
24
43
 
25
44
  TODO: List out weird/unique things about resources here. We don't need to document every resource
26
45
  because users can look at the resource model.
27
46
 
28
- TODO: document `aws_object` and `get_aws_object` and how you can get the aws object for a base
29
- chef-provisioning resource like machine or load_balancer
30
-
31
47
  ## aws_key_pair
32
48
 
33
49
  You can specify an existing key pair to upload by specifying the following:
@@ -171,7 +187,6 @@ The available parameters for `load_balancer_options` can be viewed in the [aws d
171
187
  NOTES:
172
188
 
173
189
  1. You can specify either `ssl_certificate_id` or `server_certificate` in a listener but the value to both parameters should be the ARN of an existing IAM::ServerCertificate object.
174
- 2. Instead of specifying `tags` in the `load_balancer_options`, you should specify `aws_tags`. See the note on [tagging base resources](https://github.com/chef/chef-provisioning-aws#base-resources).
175
190
 
176
191
  # RDS Instance Options
177
192
 
@@ -260,8 +275,11 @@ Finally, you should add 3 standard tests for taggable objects - 1) Tags can be c
260
275
 
261
276
  ## \#aws\_object
262
277
 
263
- All chef-provisioning-aws resources have a `aws_object` method that will return the AWS object. The AWS
264
- object won't exist until the resource converges, however. An example of how to do this looks like:
278
+ All chef-provisioning-aws resources have a `aws_object` method that will return the AWS object. The base
279
+ resources `machine`, `machine_image` and `load_balancer` are monkeypatched to also include the `aws_object`
280
+ method and should respond to it like all other resources.
281
+
282
+ The AWS object won't exist until the resource converges, however. An example of how to do this looks like:
265
283
 
266
284
  ```ruby
267
285
  my_vpc = aws_vpc 'my_vpc' do
@@ -336,37 +354,6 @@ perform [lookup_options](https://github.com/chef/chef-provisioning-aws/blob/mast
336
354
  This tries to turn elements with names like `vpc`, `security_group_ids`, `machines`, `launch_configurations`,
337
355
  `load_balancers`, etc. to the correct AWS object.
338
356
 
339
- ## Looking up chef-provisioning resources
340
-
341
- The base chef-provisioning resources (machine, machine_batch, load_balancer, machine_image) don't
342
- have the `aws_object` method defined on them because they are not `AWSResource` classes. To
343
- look them up use the class method `get_aws_object` defined on the chef-provisioning-aws specific
344
- resource:
345
-
346
- ```ruby
347
- machine_image 'my_image' do
348
- ...
349
- end
350
-
351
- ruby_block "look up machine_image object" do
352
- block do
353
- aws_object = Chef::Resource::AwsImage.get_aws_object(
354
- 'my_image',
355
- run_context: run_context,
356
- driver: run_context.chef_provisioning.current_driver,
357
- managed_entry_store: Chef::Provisioning.chef_managed_entry_store(run_context.cheffish.current_chef_server)
358
- )
359
- end
360
- end
361
- ```
362
-
363
- To look up a machine, use the `AwsInstance` class, to look up a load balancer use the `AwsLoadBalancer`
364
- class, etc. The first parameter you pass should be the same resource name as used in the base
365
- chef-provisioning resource.
366
-
367
- Again, the AWS object will not exist until the converge phase, so the aws_object will only be
368
- available using a `lazy` attribute modifier or in a `ruby_block`.
369
-
370
357
  # Running Integration Tests
371
358
 
372
359
  To run the integration tests execute `bundle exec rspec`. If you have not set it up,
data/Rakefile CHANGED
@@ -14,14 +14,15 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
14
14
  end
15
15
 
16
16
  desc "run integration specs"
17
- RSpec::Core::RakeTask.new(:integration) do |spec|
18
- spec.pattern = 'spec/integration/**/*_spec.rb'
17
+ RSpec::Core::RakeTask.new(:integration, [:pattern]) do |spec, args|
18
+ spec.pattern = args[:pattern] || 'spec/integration/**/*_spec.rb'
19
+ spec.rspec_opts = "-b"
19
20
  end
20
21
 
21
22
  desc "run :super_slow specs (machine/machine_image)"
22
- RSpec::Core::RakeTask.new(:slow) do |spec|
23
- spec.pattern = 'spec/**/*_spec.rb'
24
- spec.rspec_opts = "-t super_slow"
23
+ RSpec::Core::RakeTask.new(:super_slow, [:pattern]) do |spec, args|
24
+ spec.pattern = args[:pattern] || 'spec/integration/**/*_spec.rb'
25
+ spec.rspec_opts = "-b -t super_slow"
25
26
  end
26
27
 
27
28
  desc "run all specs, except :super_slow"
@@ -35,3 +36,10 @@ task :all_slow do
35
36
  Rake::Task[t].invoke
36
37
  end
37
38
  end
39
+
40
+ desc "travis specific task - runs CI integration tests (regular and super_slow in parallel) and sets up travis specific ENV variables"
41
+ task :travis, [:sub_task] do |t, args|
42
+ pattern = "load_balancer_spec.rb,machine_image_spec.rb" # This is a comma seperated list
43
+ pattern = pattern.split(",").map {|p| "spec/integration/**/*#{p}"}.join(",")
44
+ Rake::Task[args[:sub_task]].invoke(pattern)
45
+ end
@@ -0,0 +1,60 @@
1
+ require 'chef/provisioning/aws_driver/aws_provider'
2
+
3
+ class Chef::Provider::AwsInstanceProfile < Chef::Provisioning::AWSDriver::AWSProvider
4
+ provides :aws_iam_instance_profile
5
+
6
+ def action_create
7
+ iam_instance_profile = super
8
+
9
+ update_attached_role(iam_instance_profile)
10
+ end
11
+
12
+
13
+ protected
14
+
15
+ def detach_role(iam_instance_profile)
16
+ iam_instance_profile.roles.each do |r|
17
+ converge_by "detaching role #{r.name} from instance profile #{new_resource.name}" do
18
+ iam_instance_profile.remove_role(role_name: r.name)
19
+ end
20
+ end
21
+ end
22
+
23
+ def update_attached_role(iam_instance_profile)
24
+ options = Chef::Provisioning::AWSDriver::AWSResource.lookup_options({ iam_role: new_resource.role }, resource: new_resource)
25
+ role = options[:iam_role]
26
+
27
+ if new_resource.role && !iam_instance_profile.roles.map(&:name).include?(role)
28
+ detach_role(iam_instance_profile)
29
+ converge_by "associating role #{role} with instance profile #{new_resource.name}" do
30
+ # Despite having collection methods for roles, instance profile can only have single role associated
31
+ iam_instance_profile.add_role({
32
+ role_name: role
33
+ })
34
+ end
35
+ end
36
+ end
37
+
38
+ def create_aws_object
39
+ converge_by "create IAM instance profile #{new_resource.name}" do
40
+ new_resource.driver.iam_resource.create_instance_profile({
41
+ path: new_resource.path || "/",
42
+ instance_profile_name: new_resource.name
43
+ })
44
+ end
45
+ end
46
+
47
+ def update_aws_object(iam_instance_profile)
48
+ # Nothing to update on our object because the role relationship is managed
49
+ # through the action
50
+ iam_instance_profile
51
+ end
52
+
53
+ def destroy_aws_object(iam_instance_profile)
54
+ detach_role(iam_instance_profile)
55
+ converge_by "delete #{iam_instance_profile.name}" do
56
+ iam_instance_profile.delete
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,98 @@
1
+ require 'chef/provisioning/aws_driver/aws_provider'
2
+ require 'chef/json_compat'
3
+
4
+ class Chef::Provider::AwsIamRole < Chef::Provisioning::AWSDriver::AWSProvider
5
+ provides :aws_iam_role
6
+
7
+ def iam_client
8
+ new_resource.driver.iam_client
9
+ end
10
+
11
+ def iam_resource
12
+ new_resource.driver.iam_resource
13
+ end
14
+
15
+ def action_create
16
+ role = super
17
+
18
+ if !new_resource.inline_policies.nil?
19
+ update_inline_policy(role)
20
+ end
21
+ end
22
+
23
+ protected
24
+
25
+ def create_aws_object
26
+ converge_by "create IAM Role #{new_resource.name}" do
27
+ iam_resource.create_role({
28
+ path: new_resource.path,
29
+ role_name: new_resource.name,
30
+ assume_role_policy_document: new_resource.assume_role_policy_document
31
+ })
32
+ end
33
+ iam_resource.role(new_resource.name)
34
+ end
35
+
36
+ def update_aws_object(role)
37
+ if new_resource.path && new_resource.path != role.path
38
+ raise "Path of IAM Role #{new_resource.name} is #{role.path}, but desired path is #{new_resource.path}. IAM Role paths cannot be updated!"
39
+ end
40
+ if new_resource.assume_role_policy_document && policy_update_required?(role.assume_role_policy_document, new_resource.assume_role_policy_document)
41
+ converge_by "update IAM Role #{role.name} assume_role_policy_document" do
42
+ iam_client.update_assume_role_policy({
43
+ role_name: new_resource.name,
44
+ policy_document: new_resource.assume_role_policy_document
45
+ })
46
+ end
47
+ end
48
+ end
49
+
50
+ def destroy_aws_object(role)
51
+ converge_by "delete IAM Role #{role.name}" do
52
+ role.instance_profiles.each do |profile|
53
+ profile.remove_role(role_name: role.name)
54
+ end
55
+ role.policies.each do |policy|
56
+ converge_by "delete IAM Role inline policy #{policy.name}" do
57
+ policy.delete
58
+ end
59
+ end
60
+ role.delete
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def update_inline_policy(role)
67
+ desired_inline_policies = Hash[new_resource.inline_policies.map {|k, v| [k.to_s, v]}]
68
+ current_inline_policies = Hash[role.policies.map {|p| [p.name, p.policy_document]}]
69
+
70
+ policies_to_put = desired_inline_policies.reject {|k,v| current_inline_policies[k] && !policy_update_required?(current_inline_policies[k], v)}
71
+ policies_to_delete = current_inline_policies.keys - desired_inline_policies.keys
72
+
73
+ policies_to_put.each do |policy_name, policy|
74
+ converge_by "Adding or updating inline Role policy #{policy_name}" do
75
+ iam_client.put_role_policy({
76
+ role_name: role.name,
77
+ policy_name: policy_name,
78
+ policy_document: policy
79
+ })
80
+ end
81
+ end
82
+
83
+ policies_to_delete.each do |policy_name|
84
+ converge_by "Deleting inline Role policy #{policy_name}" do
85
+ iam_client.delete_role_policy({
86
+ role_name: role.name,
87
+ policy_name: policy_name
88
+ })
89
+ end
90
+ end
91
+ end
92
+
93
+ def policy_update_required?(current_policy, desired_policy)
94
+ # We parse the JSON into a hash to get rid of whitespace and ordering issues
95
+ Chef::JSONCompat.parse(URI.decode(current_policy)) != Chef::JSONCompat.parse(desired_policy)
96
+ end
97
+
98
+ end
@@ -29,7 +29,7 @@ class Chef::Provider::AwsImage < Chef::Provisioning::AWSDriver::AWSProvider
29
29
  # destroyed - we just need to make sure that has completed successfully
30
30
  instance = new_resource.driver.ec2.instances[instance_id]
31
31
  converge_by "waiting until instance #{instance.id} is :terminated" do
32
- wait_for_status(instance, :terminated, [AWS::EC2::Errors::InvalidInstanceID::NotFound])
32
+ wait_for_status(instance, :terminated, [AWS::EC2::Errors::InvalidInstanceID::NotFound, AWS::Core::Resource::NotFound])
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,75 @@
1
+ require 'chef/provisioning/aws_driver/aws_provider'
2
+ require 'retryable'
3
+
4
+ class Chef::Provider::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSProvider
5
+ include Chef::Provisioning::AWSDriver::TaggingStrategy::EC2ConvergeTags
6
+
7
+ provides :aws_internet_gateway
8
+
9
+ def action_detach
10
+ internet_gateway = Chef::Resource::AwsInternetGateway.get_aws_object(new_resource.name, resource: new_resource)
11
+ detach_vpc(internet_gateway)
12
+ end
13
+
14
+ protected
15
+
16
+ def create_aws_object
17
+ desired_vpc = Chef::Resource::AwsVpc.get_aws_object(new_resource.vpc, resource: new_resource) if new_resource.vpc
18
+
19
+ converge_by "create internet gateway #{new_resource.name} in region #{region}" do
20
+ internet_gateway = new_resource.driver.ec2.internet_gateways.create
21
+ retry_with_backoff(AWS::EC2::Errors::InvalidInternetGatewayID::NotFound) do
22
+ internet_gateway.tags['Name'] = new_resource.name
23
+ end
24
+
25
+ if desired_vpc
26
+ attach_vpc(desired_vpc, internet_gateway)
27
+ end
28
+
29
+ internet_gateway
30
+ end
31
+ end
32
+
33
+ def update_aws_object(internet_gateway)
34
+ current_vpc = internet_gateway.vpc
35
+
36
+ if new_resource.vpc
37
+ desired_vpc = Chef::Resource::AwsVpc.get_aws_object(new_resource.vpc, resource: new_resource)
38
+ if current_vpc != desired_vpc
39
+ attach_vpc(desired_vpc, internet_gateway)
40
+ end
41
+ end
42
+ end
43
+
44
+ def destroy_aws_object(internet_gateway)
45
+ converge_by "delete internet gateway #{new_resource.name} in region #{region}" do
46
+ detach_vpc(internet_gateway)
47
+ internet_gateway.delete
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def attach_vpc(vpc, desired_gateway)
54
+ if vpc.internet_gateway && vpc.internet_gateway != desired_gateway
55
+ Cheffish.inline_resource(self, action) do
56
+ aws_vpc vpc.id do
57
+ cidr_block vpc.cidr_block
58
+ internet_gateway false
59
+ end
60
+ end
61
+ end
62
+ converge_by "attach vpc #{vpc.id} to #{desired_gateway.id}" do
63
+ desired_gateway.vpc = vpc
64
+ end
65
+ end
66
+
67
+ def detach_vpc(internet_gateway)
68
+ if internet_gateway.vpc
69
+ converge_by "detach vpc #{internet_gateway.vpc.id} from internet gateway #{internet_gateway.id}" do
70
+ internet_gateway.detach(internet_gateway.vpc)
71
+ end
72
+ end
73
+ end
74
+
75
+ end
@@ -100,7 +100,8 @@ class Chef::Provider::AwsRouteTable < Chef::Provisioning::AWSDriver::AWSProvider
100
100
 
101
101
  # Delete anything that's left (that wasn't replaced)
102
102
  current_routes.values.each do |current_route|
103
- action_handler.perform_action "remove route sending #{current_route.destination_cidr_block} to #{current_route.target.id}" do
103
+ current_target = current_route.gateway_id || current_route.instance_id || current_route.network_interface_id || current_route.vpc_peering_connection_id
104
+ action_handler.perform_action "remove route sending #{current_route.destination_cidr_block} to #{current_target}" do
104
105
  current_route.delete
105
106
  end
106
107
  end
@@ -141,7 +142,7 @@ class Chef::Provider::AwsRouteTable < Chef::Provisioning::AWSDriver::AWSProvider
141
142
  route_target = { internet_gateway: route_target }
142
143
  when /^eni-[A-Fa-f0-9]{8}$/, Chef::Resource::AwsNetworkInterface, AWS::EC2::NetworkInterface
143
144
  route_target = { network_interface: route_target }
144
- when /^pcx-[A-Fa-f0-9]{8}$/, Chef::Resource::AwsVpcPeeringConnection, ::Aws::EC2::AwsVpcPeeringConnection
145
+ when /^pcx-[A-Fa-f0-9]{8}$/, Chef::Resource::AwsVpcPeeringConnection, ::Aws::EC2::VpcPeeringConnection
145
146
  route_target = { vpc_peering_connection: route_target }
146
147
  when String, Chef::Resource::AwsInstance
147
148
  route_target = { instance: route_target }
@@ -50,7 +50,7 @@ class Chef::Provider::AwsS3Bucket < Chef::Provisioning::AWSDriver::AWSProvider
50
50
 
51
51
  def create_aws_object
52
52
  converge_by "create S3 bucket #{new_resource.name}" do
53
- new_resource.driver.s3.buckets.create(new_resource.name)
53
+ new_resource.driver.s3.buckets.create(new_resource.name, new_resource.options)
54
54
  # S3 buckets already have a top level name property so they don't need
55
55
  # a 'Name' tag
56
56
  end
@@ -60,6 +60,9 @@ class Chef::Provider::AwsS3Bucket < Chef::Provisioning::AWSDriver::AWSProvider
60
60
  end
61
61
 
62
62
  def destroy_aws_object(bucket)
63
+ if purging
64
+ new_resource.recursive_delete(true)
65
+ end
63
66
  converge_by "delete S3 bucket #{new_resource.name}" do
64
67
  if new_resource.recursive_delete
65
68
  bucket.delete!
@@ -24,7 +24,7 @@ class Chef::Provider::AwsSecurityGroup < Chef::Provisioning::AWSDriver::AWSProvi
24
24
  Chef::Log.debug("VPC: #{options[:vpc]}")
25
25
 
26
26
  sg = new_resource.driver.ec2.security_groups.create(new_resource.name, options)
27
- retry_with_backoff(AWS::EC2::Errors::InvalidSecurityGroupsID::NotFound) do
27
+ retry_with_backoff(AWS::EC2::Errors::InvalidSecurityGroupsID::NotFound, AWS::EC2::Errors::InvalidGroup::NotFound) do
28
28
  sg.tags['Name'] = new_resource.name
29
29
  end
30
30
  sg