chef-provisioning-aws 3.0.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -5
  3. data/Rakefile +15 -6
  4. data/chef-provisioning-aws.gemspec +17 -17
  5. data/lib/chef/provider/aws_auto_scaling_group.rb +5 -6
  6. data/lib/chef/provider/aws_cache_cluster.rb +21 -15
  7. data/lib/chef/provider/aws_cache_replication_group.rb +12 -8
  8. data/lib/chef/provider/aws_cache_subnet_group.rb +3 -3
  9. data/lib/chef/provider/aws_cloudsearch_domain.rb +9 -13
  10. data/lib/chef/provider/aws_cloudwatch_alarm.rb +10 -12
  11. data/lib/chef/provider/aws_dhcp_options.rb +18 -21
  12. data/lib/chef/provider/aws_ebs_volume.rb +24 -26
  13. data/lib/chef/provider/aws_eip_address.rb +10 -13
  14. data/lib/chef/provider/aws_elasticsearch_domain.rb +19 -18
  15. data/lib/chef/provider/aws_iam_instance_profile.rb +5 -7
  16. data/lib/chef/provider/aws_iam_role.rb +14 -17
  17. data/lib/chef/provider/aws_image.rb +6 -6
  18. data/lib/chef/provider/aws_instance.rb +5 -5
  19. data/lib/chef/provider/aws_internet_gateway.rb +8 -11
  20. data/lib/chef/provider/aws_key_pair.rb +15 -17
  21. data/lib/chef/provider/aws_launch_configuration.rb +11 -14
  22. data/lib/chef/provider/aws_load_balancer.rb +1 -2
  23. data/lib/chef/provider/aws_nat_gateway.rb +6 -7
  24. data/lib/chef/provider/aws_network_acl.rb +28 -29
  25. data/lib/chef/provider/aws_network_interface.rb +25 -27
  26. data/lib/chef/provider/aws_rds_instance.rb +12 -13
  27. data/lib/chef/provider/aws_rds_parameter_group.rb +8 -8
  28. data/lib/chef/provider/aws_rds_subnet_group.rb +8 -9
  29. data/lib/chef/provider/aws_route_table.rb +19 -20
  30. data/lib/chef/provider/aws_s3_bucket.rb +22 -25
  31. data/lib/chef/provider/aws_security_group.rb +268 -285
  32. data/lib/chef/provider/aws_server_certificate.rb +6 -5
  33. data/lib/chef/provider/aws_sns_topic.rb +4 -6
  34. data/lib/chef/provider/aws_sqs_queue.rb +3 -4
  35. data/lib/chef/provider/aws_subnet.rb +29 -34
  36. data/lib/chef/provider/aws_vpc.rb +108 -116
  37. data/lib/chef/provider/aws_vpc_peering_connection.rb +11 -11
  38. data/lib/chef/provisioning/aws_driver.rb +4 -2
  39. data/lib/chef/provisioning/aws_driver/aws_provider.rb +234 -241
  40. data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +5 -7
  41. data/lib/chef/provisioning/aws_driver/aws_resource.rb +182 -185
  42. data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +17 -17
  43. data/lib/chef/provisioning/aws_driver/aws_taggable.rb +13 -15
  44. data/lib/chef/provisioning/aws_driver/aws_tagger.rb +47 -48
  45. data/lib/chef/provisioning/aws_driver/credentials.rb +96 -100
  46. data/lib/chef/provisioning/aws_driver/credentials2.rb +42 -45
  47. data/lib/chef/provisioning/aws_driver/driver.rb +1349 -1362
  48. data/lib/chef/provisioning/aws_driver/exceptions.rb +10 -12
  49. data/lib/chef/provisioning/aws_driver/super_lwrp.rb +60 -60
  50. data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +49 -50
  51. data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +37 -38
  52. data/lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb +14 -15
  53. data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +29 -31
  54. data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +39 -40
  55. data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -43
  56. data/lib/chef/provisioning/aws_driver/version.rb +5 -5
  57. data/lib/chef/provisioning/driver_init/aws.rb +2 -2
  58. data/lib/chef/resource/aws_auto_scaling_group.rb +1 -1
  59. data/lib/chef/resource/aws_cache_cluster.rb +9 -12
  60. data/lib/chef/resource/aws_cache_replication_group.rb +9 -11
  61. data/lib/chef/resource/aws_cache_subnet_group.rb +8 -10
  62. data/lib/chef/resource/aws_cloudsearch_domain.rb +4 -5
  63. data/lib/chef/resource/aws_cloudwatch_alarm.rb +17 -18
  64. data/lib/chef/resource/aws_dhcp_options.rb +2 -2
  65. data/lib/chef/resource/aws_ebs_volume.rb +10 -10
  66. data/lib/chef/resource/aws_eip_address.rb +5 -5
  67. data/lib/chef/resource/aws_elasticsearch_domain.rb +4 -4
  68. data/lib/chef/resource/aws_iam_instance_profile.rb +4 -5
  69. data/lib/chef/resource/aws_iam_role.rb +2 -3
  70. data/lib/chef/resource/aws_image.rb +3 -3
  71. data/lib/chef/resource/aws_instance.rb +4 -4
  72. data/lib/chef/resource/aws_internet_gateway.rb +3 -3
  73. data/lib/chef/resource/aws_key_pair.rb +7 -7
  74. data/lib/chef/resource/aws_launch_configuration.rb +4 -4
  75. data/lib/chef/resource/aws_load_balancer.rb +7 -7
  76. data/lib/chef/resource/aws_nat_gateway.rb +11 -11
  77. data/lib/chef/resource/aws_network_acl.rb +7 -8
  78. data/lib/chef/resource/aws_network_interface.rb +9 -9
  79. data/lib/chef/resource/aws_rds_instance.rb +4 -4
  80. data/lib/chef/resource/aws_rds_parameter_group.rb +3 -3
  81. data/lib/chef/resource/aws_rds_subnet_group.rb +4 -4
  82. data/lib/chef/resource/aws_route53_hosted_zone.rb +37 -40
  83. data/lib/chef/resource/aws_route53_record_set.rb +22 -24
  84. data/lib/chef/resource/aws_route_table.rb +7 -7
  85. data/lib/chef/resource/aws_s3_bucket.rb +7 -7
  86. data/lib/chef/resource/aws_security_group.rb +10 -10
  87. data/lib/chef/resource/aws_server_certificate.rb +6 -8
  88. data/lib/chef/resource/aws_sns_topic.rb +2 -2
  89. data/lib/chef/resource/aws_sqs_queue.rb +5 -7
  90. data/lib/chef/resource/aws_subnet.rb +9 -9
  91. data/lib/chef/resource/aws_vpc.rb +11 -11
  92. data/lib/chef/resource/aws_vpc_peering_connection.rb +4 -4
  93. data/spec/aws_support.rb +44 -45
  94. data/spec/aws_support/aws_resource_run_wrapper.rb +2 -2
  95. data/spec/aws_support/deep_matcher.rb +2 -3
  96. data/spec/aws_support/deep_matcher/fuzzy_match_objects.rb +6 -9
  97. data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +30 -37
  98. data/spec/aws_support/deep_matcher/matchable_array.rb +0 -1
  99. data/spec/aws_support/deep_matcher/matchable_object.rb +1 -2
  100. data/spec/aws_support/deep_matcher/rspec_monkeypatches.rb +4 -4
  101. data/spec/aws_support/delayed_stream.rb +2 -2
  102. data/spec/aws_support/matchers/create_an_aws_object.rb +6 -6
  103. data/spec/aws_support/matchers/destroy_an_aws_object.rb +6 -6
  104. data/spec/aws_support/matchers/have_aws_object_tags.rb +4 -5
  105. data/spec/aws_support/matchers/match_an_aws_object.rb +5 -6
  106. data/spec/aws_support/matchers/update_an_aws_object.rb +6 -7
  107. data/spec/integration/aws_auto_scaling_group_spec.rb +56 -64
  108. data/spec/integration/aws_cache_cluster_spec.rb +70 -71
  109. data/spec/integration/aws_cache_subnet_group_spec.rb +13 -14
  110. data/spec/integration/aws_cloudsearch_domain_spec.rb +6 -8
  111. data/spec/integration/aws_cloudwatch_alarm_spec.rb +200 -208
  112. data/spec/integration/aws_dhcp_options_spec.rb +32 -43
  113. data/spec/integration/aws_ebs_volume_spec.rb +52 -73
  114. data/spec/integration/aws_eip_address_spec.rb +24 -31
  115. data/spec/integration/aws_elasticsearch_domain_spec.rb +31 -33
  116. data/spec/integration/aws_iam_instance_profile_spec.rb +36 -45
  117. data/spec/integration/aws_iam_role_spec.rb +39 -46
  118. data/spec/integration/aws_internet_gateway_spec.rb +64 -75
  119. data/spec/integration/aws_key_pair_spec.rb +6 -6
  120. data/spec/integration/aws_launch_configuration_spec.rb +17 -18
  121. data/spec/integration/aws_nat_gateway_spec.rb +21 -24
  122. data/spec/integration/aws_network_acl_spec.rb +81 -95
  123. data/spec/integration/aws_network_interface_spec.rb +28 -43
  124. data/spec/integration/aws_rds_instance_spec.rb +29 -40
  125. data/spec/integration/aws_rds_parameter_group_spec.rb +32 -35
  126. data/spec/integration/aws_rds_subnet_group_spec.rb +30 -40
  127. data/spec/integration/aws_route53_hosted_zone_spec.rb +205 -205
  128. data/spec/integration/aws_route_table_spec.rb +118 -136
  129. data/spec/integration/aws_s3_bucket_spec.rb +19 -27
  130. data/spec/integration/aws_security_group_spec.rb +369 -388
  131. data/spec/integration/aws_server_certificate_spec.rb +16 -18
  132. data/spec/integration/aws_subnet_spec.rb +44 -58
  133. data/spec/integration/aws_vpc_peering_connection_spec.rb +43 -50
  134. data/spec/integration/aws_vpc_spec.rb +99 -115
  135. data/spec/integration/load_balancer_spec.rb +169 -183
  136. data/spec/integration/machine_batch_spec.rb +24 -31
  137. data/spec/integration/machine_image_spec.rb +54 -66
  138. data/spec/integration/machine_spec.rb +216 -237
  139. data/spec/persistence_file.txt +219 -0
  140. data/spec/spec_helper.rb +16 -17
  141. data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +67 -74
  142. data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +29 -29
  143. data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +13 -15
  144. metadata +4 -3
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsServerCertificate do
4
4
  extend AWSSupport
@@ -7,7 +7,7 @@ describe Chef::Resource::AwsServerCertificate do
7
7
  # Follow those instructions except the chain should be `ca-int.crt` only
8
8
  # instead of concatenated intermediate and root
9
9
 
10
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
10
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
11
11
  with_aws "without a VPC" do
12
12
  cert_string = <<-CERT
13
13
  -----BEGIN CERTIFICATE-----
@@ -26,8 +26,8 @@ IUpfB2NibP9G5LhtxFY1fa+MLp9mJ+yI3hg0x+6xBPTiPDGVpFdJ+LH/mKWxsaWT
26
26
  /KKNXu+NC9z/lrNVU6J/XUCk54YdmjMvadHs1aJp6NWH7LI9df27AlBGLnRc/w04
27
27
  agCh4aCsjczD2YeBVl6idws/InYbSwhz7x9zXz2qB3BbI3psgBfJQQcJukulVGza
28
28
  RkD993U+CJpJMDbpIGRe9lXe33R3tGbbvfa4FaXZlZgoKCrE21SCb2hxlNG2+w==
29
- -----END CERTIFICATE-----
30
- CERT
29
+ -----END CERTIFICATE-----
30
+ CERT
31
31
 
32
32
  private_key_string = <<-KEY
33
33
  -----BEGIN RSA PRIVATE KEY-----
@@ -56,8 +56,8 @@ k7JouTKFS7IMwTW3AFpyHz+KG4QcBoQj94ofZvapIOv8E5+8MkSVyuONRbHuoOeE
56
56
  DNbJssECgYBIAFB3J66cZH3zBfyanHwYMPlTupxUBTsN19UCAK7MZqA5kbqG7b7Q
57
57
  cKPrgR7gibLvaxj22lvD8uEICMGy6g8s3+PyDwcw5PNrKOdIkRrYQxTFtfs1JRCa
58
58
  6kM8q32f1I3qd31zbpoDBHq+Se2RSaLbmoIAFqDSCWyeUHydALo2kw==
59
- -----END RSA PRIVATE KEY-----
60
- KEY
59
+ -----END RSA PRIVATE KEY-----
60
+ KEY
61
61
 
62
62
  certificate_chain_string = <<-CHAIN
63
63
  -----BEGIN CERTIFICATE-----
@@ -76,32 +76,30 @@ gtw2MXUV3eA9ByAD4XKIWSvaROdHj+5wiCKWKMGvrSEPay5xEJm54VcALXHGk+Vf
76
76
  jFNHTa/YFrlDXXupmI8HCYKwXrcooNcLuIkEmZIPX99s1vjFVT8oRdYLwFGt7AVC
77
77
  ufkpMTlf/J9WjsabI5O+fzJYgdVm7QUq8Dg3tiM0RcZtO2cWus4DZl/KQkZx84f1
78
78
  WGXzC2zbuS6DI9QPgkLeQ11O2kaeMqkNy6Tzr88XfA==
79
- -----END CERTIFICATE-----
80
- CHAIN
79
+ -----END CERTIFICATE-----
80
+ CHAIN
81
81
 
82
82
  it "creates a cert" do
83
- expect_recipe {
83
+ expect_recipe do
84
84
  aws_server_certificate "test-cert" do
85
85
  certificate_body cert_string
86
86
  private_key private_key_string
87
87
  certificate_chain certificate_chain_string
88
88
  end
89
- }.to create_an_aws_server_certificate("test-cert",
90
- :certificate_body => cert_string.strip,
91
- :certificate_chain => certificate_chain_string.strip
92
- ).and be_idempotent
89
+ end.to create_an_aws_server_certificate("test-cert",
90
+ certificate_body: cert_string.strip,
91
+ certificate_chain: certificate_chain_string.strip).and be_idempotent
93
92
  end
94
93
 
95
94
  it "creates a cert without a certificate_chain" do
96
- expect_recipe {
95
+ expect_recipe do
97
96
  aws_server_certificate "test-cert" do
98
97
  certificate_body cert_string
99
98
  private_key private_key_string
100
99
  end
101
- }.to create_an_aws_server_certificate("test-cert",
102
- :certificate_body => cert_string.strip,
103
- :certificate_chain => nil
104
- ).and be_idempotent
100
+ end.to create_an_aws_server_certificate("test-cert",
101
+ certificate_body: cert_string.strip,
102
+ certificate_chain: nil).and be_idempotent
105
103
  end
106
104
  end
107
105
  end
@@ -1,106 +1,92 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsSubnet do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
7
  with_aws "with a VPC with an internet gateway, route table and network acl" do
8
8
  aws_vpc "test_vpc" do
9
- cidr_block '10.0.0.0/24'
9
+ cidr_block "10.0.0.0/24"
10
10
  internet_gateway true
11
11
  end
12
12
 
13
- aws_route_table 'test_route_table' do
14
- vpc 'test_vpc'
13
+ aws_route_table "test_route_table" do
14
+ vpc "test_vpc"
15
15
  end
16
16
 
17
- aws_network_acl 'test_network_acl' do
18
- vpc 'test_vpc'
17
+ aws_network_acl "test_network_acl" do
18
+ vpc "test_vpc"
19
19
  end
20
20
 
21
21
  it "aws_subnet 'test_subnet' with no parameters except VPC creates a subnet" do
22
- expect_recipe {
23
- aws_subnet 'test_subnet' do
24
- vpc 'test_vpc'
22
+ expect_recipe do
23
+ aws_subnet "test_subnet" do
24
+ vpc "test_vpc"
25
25
  end
26
- }.to create_an_aws_subnet('test_subnet',
27
- vpc_id: test_vpc.aws_object.id,
28
- cidr_block: test_vpc.aws_object.cidr_block
29
- ).and be_idempotent
26
+ end.to create_an_aws_subnet("test_subnet",
27
+ vpc_id: test_vpc.aws_object.id,
28
+ cidr_block: test_vpc.aws_object.cidr_block).and be_idempotent
30
29
  end
31
30
 
32
31
  it "aws_subnet 'test_subnet' with all parameters creates a subnet" do
33
32
  az = driver.ec2_client.describe_availability_zones.availability_zones.first.zone_name
34
33
  na = test_network_acl.aws_object.id
35
34
  rt = test_route_table.aws_object.id
36
- expect_recipe {
37
- aws_subnet 'test_subnet' do
38
- vpc 'test_vpc'
39
- cidr_block '10.0.0.0/24'
35
+ expect_recipe do
36
+ aws_subnet "test_subnet" do
37
+ vpc "test_vpc"
38
+ cidr_block "10.0.0.0/24"
40
39
  availability_zone az
41
40
  map_public_ip_on_launch true
42
- route_table 'test_route_table'
43
- network_acl 'test_network_acl'
41
+ route_table "test_route_table"
42
+ network_acl "test_network_acl"
44
43
  end
45
- }.to create_an_aws_subnet('test_subnet',
46
- vpc_id: test_vpc.aws_object.id,
47
- cidr_block: '10.0.0.0/24',
48
- availability_zone: az
49
- ).and match_an_aws_subnet('test_subnet',
50
- subnet_id: driver.ec2_client.describe_route_tables(filters: [{name: "route-table-id", values: [rt]}]).route_tables[0].associations[0].subnet_id
51
- ).and match_an_aws_subnet('test_subnet',
52
- subnet_id: driver.ec2_client.describe_network_acls(filters: [{name: "network-acl-id", values: [na]}]).network_acls[0].associations[0].subnet_id
53
- ).and be_idempotent
44
+ end.to create_an_aws_subnet("test_subnet",
45
+ vpc_id: test_vpc.aws_object.id,
46
+ cidr_block: "10.0.0.0/24",
47
+ availability_zone: az).and match_an_aws_subnet("test_subnet",
48
+ subnet_id: driver.ec2_client.describe_route_tables(filters: [{ name: "route-table-id", values: [rt] }]).route_tables[0].associations[0].subnet_id).and match_an_aws_subnet("test_subnet",
49
+ subnet_id: driver.ec2_client.describe_network_acls(filters: [{ name: "network-acl-id", values: [na] }]).network_acls[0].associations[0].subnet_id).and be_idempotent
54
50
  end
55
51
 
56
52
  it "creates aws_subnet tags" do
57
- expect_recipe {
58
- aws_subnet 'test_subnet' do
59
- vpc 'test_vpc'
53
+ expect_recipe do
54
+ aws_subnet "test_subnet" do
55
+ vpc "test_vpc"
60
56
  aws_tags key1: "value"
61
57
  end
62
- }.to create_an_aws_subnet('test_subnet')
63
- .and have_aws_subnet_tags('test_subnet',
64
- {
65
- 'Name' => 'test_subnet',
66
- 'key1' => 'value'
67
- }
68
- ).and be_idempotent
58
+ end.to create_an_aws_subnet("test_subnet")
59
+ .and have_aws_subnet_tags("test_subnet",
60
+ "Name" => "test_subnet",
61
+ "key1" => "value").and be_idempotent
69
62
  end
70
63
 
71
64
  context "with existing tags" do
72
- aws_subnet 'test_subnet' do
73
- vpc 'test_vpc'
65
+ aws_subnet "test_subnet" do
66
+ vpc "test_vpc"
74
67
  aws_tags key1: "value"
75
68
  end
76
69
 
77
70
  it "updates aws_subnet tags" do
78
- expect_recipe {
79
- aws_subnet 'test_subnet' do
71
+ expect_recipe do
72
+ aws_subnet "test_subnet" do
80
73
  aws_tags key1: "value2", key2: nil
81
74
  end
82
- }.to have_aws_subnet_tags('test_subnet',
83
- {
84
- 'Name' => 'test_subnet',
85
- 'key1' => 'value2',
86
- 'key2' => ''
87
- }
88
- ).and be_idempotent
75
+ end.to have_aws_subnet_tags("test_subnet",
76
+ "Name" => "test_subnet",
77
+ "key1" => "value2",
78
+ "key2" => "").and be_idempotent
89
79
  end
90
80
 
91
81
  it "removes all aws_subnet tags except Name" do
92
- expect_recipe {
93
- aws_subnet 'test_subnet' do
82
+ expect_recipe do
83
+ aws_subnet "test_subnet" do
94
84
  aws_tags({})
95
85
  end
96
- }.to have_aws_subnet_tags('test_subnet',
97
- {
98
- 'Name' => 'test_subnet'
99
- }
100
- ).and be_idempotent
86
+ end.to have_aws_subnet_tags("test_subnet",
87
+ "Name" => "test_subnet").and be_idempotent
101
88
  end
102
89
  end
103
-
104
90
  end
105
91
  end
106
92
  end
@@ -1,99 +1,92 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsVpcPeeringConnection do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
7
  with_aws "with 2 VPCs" do
8
-
9
8
  aws_vpc "test_vpc" do
10
- cidr_block '10.0.0.0/24'
9
+ cidr_block "10.0.0.0/24"
11
10
  internet_gateway false
12
11
  end
13
12
 
14
13
  aws_vpc "test_vpc_2" do
15
- cidr_block '11.0.0.0/24'
14
+ cidr_block "11.0.0.0/24"
16
15
  internet_gateway false
17
16
  end
18
17
 
19
18
  it "aws_peering_connection 'test_vpc' with no attributes fails to create a VPC peering connection (must specify vpc and peer_vpc)" do
20
- expect_converge {
21
- aws_vpc_peering_connection 'test_peering_connection' do
19
+ expect_converge do
20
+ aws_vpc_peering_connection "test_peering_connection" do
22
21
  end
23
- }.to raise_error(RuntimeError, /VCP peering connection create action for 'test_peering_connection' requires the 'vpc' attribute./)
22
+ end.to raise_error(RuntimeError, /VCP peering connection create action for 'test_peering_connection' requires the 'vpc' attribute./)
24
23
 
25
- expect_converge {
26
- aws_vpc_peering_connection 'test_peering_connection' do
27
- vpc 'test_vpc'
24
+ expect_converge do
25
+ aws_vpc_peering_connection "test_peering_connection" do
26
+ vpc "test_vpc"
28
27
  end
29
- }.to raise_error(RuntimeError, /VCP peering connection create action for 'test_peering_connection' requires the 'peer_vpc' attribute./)
28
+ end.to raise_error(RuntimeError, /VCP peering connection create action for 'test_peering_connection' requires the 'peer_vpc' attribute./)
30
29
  end
31
30
 
32
31
  it "aws_peering_connection 'test_peering_connection' with minimal parameters creates a active connection" do
33
- expect_recipe {
34
- aws_vpc_peering_connection 'test_peering_connection' do
35
- vpc 'test_vpc'
36
- peer_vpc 'test_vpc_2'
32
+ expect_recipe do
33
+ aws_vpc_peering_connection "test_peering_connection" do
34
+ vpc "test_vpc"
35
+ peer_vpc "test_vpc_2"
37
36
  end
38
- }.to create_an_aws_vpc_peering_connection('test_peering_connection',
39
- :'requester_vpc_info.vpc_id' => test_vpc.aws_object.id,
40
- :'accepter_vpc_info.vpc_id' => test_vpc_2.aws_object.id,
41
- :'status.code' => 'active'
42
- ).and be_idempotent
37
+ end.to create_an_aws_vpc_peering_connection("test_peering_connection",
38
+ 'requester_vpc_info.vpc_id': test_vpc.aws_object.id,
39
+ 'accepter_vpc_info.vpc_id': test_vpc_2.aws_object.id,
40
+ 'status.code': "active").and be_idempotent
43
41
  end
44
42
 
45
43
  it "aws_peering_connection 'test_peering_connection' with peer_owner_id set to be the actual account id, creates an active peering" do
46
- expect_recipe {
47
- aws_vpc_peering_connection 'test_peering_connection' do
48
- vpc 'test_vpc'
49
- peer_vpc 'test_vpc_2'
44
+ expect_recipe do
45
+ aws_vpc_peering_connection "test_peering_connection" do
46
+ vpc "test_vpc"
47
+ peer_vpc "test_vpc_2"
50
48
  peer_owner_id driver.account_id
51
49
  end
52
- }.to create_an_aws_vpc_peering_connection('test_peering_connection',
53
- :'requester_vpc_info.vpc_id' => test_vpc.aws_object.id,
54
- :'accepter_vpc_info.vpc_id' => test_vpc_2.aws_object.id,
55
- :'status.code' => 'active'
56
- ).and be_idempotent
50
+ end.to create_an_aws_vpc_peering_connection("test_peering_connection",
51
+ 'requester_vpc_info.vpc_id': test_vpc.aws_object.id,
52
+ 'accepter_vpc_info.vpc_id': test_vpc_2.aws_object.id,
53
+ 'status.code': "active").and be_idempotent
57
54
  end
58
55
 
59
56
  it "aws_peering_connection 'test_peering_connection' with a false peer_owner_id, creates a failed peering connection" do
60
- expect_recipe {
61
- aws_vpc_peering_connection 'test_peering_connection' do
62
- vpc 'test_vpc'
63
- peer_vpc 'test_vpc_2'
64
- peer_owner_id '000000000000'
57
+ expect_recipe do
58
+ aws_vpc_peering_connection "test_peering_connection" do
59
+ vpc "test_vpc"
60
+ peer_vpc "test_vpc_2"
61
+ peer_owner_id "000000000000"
65
62
  end
66
- }.to create_an_aws_vpc_peering_connection('test_peering_connection',
67
- :'requester_vpc_info.vpc_id' => test_vpc.aws_object.id,
68
- :'accepter_vpc_info.vpc_id' => test_vpc_2.aws_object.id,
69
- :'status.code' => 'failed'
70
- ).and be_idempotent
63
+ end.to create_an_aws_vpc_peering_connection("test_peering_connection",
64
+ 'requester_vpc_info.vpc_id': test_vpc.aws_object.id,
65
+ 'accepter_vpc_info.vpc_id': test_vpc_2.aws_object.id,
66
+ 'status.code': "failed").and be_idempotent
71
67
  end
72
68
 
73
69
  it "aws_peering_connection 'test_peering_connection' with accept action, accepts a pending peering connection" do
74
70
  pcx = nil
75
71
  ec2_resource = driver.ec2_resource
76
- expect_recipe {
72
+ expect_recipe do
77
73
  ruby_block "fetch VPC objects" do
78
74
  block do
79
75
  test_vpc = Chef::Resource::AwsVpc.get_aws_object("test_vpc", run_context: run_context)
80
76
  test_vpc_2 = Chef::Resource::AwsVpc.get_aws_object("test_vpc_2", run_context: run_context)
81
- pcx = ec2_resource.vpc(test_vpc.id).request_vpc_peering_connection({ :peer_vpc_id => test_vpc_2.id })
77
+ pcx = ec2_resource.vpc(test_vpc.id).request_vpc_peering_connection(peer_vpc_id: test_vpc_2.id)
82
78
  end
83
79
  end
84
- }.to match_an_aws_vpc_peering_connection(pcx.id,
85
- :'status.code' => 'pending-acceptance'
86
- )
80
+ end.to match_an_aws_vpc_peering_connection(pcx.id,
81
+ 'status.code': "pending-acceptance")
87
82
 
88
- expect_recipe {
83
+ expect_recipe do
89
84
  aws_vpc_peering_connection pcx.id do
90
85
  action :accept
91
86
  end
92
- }.to match_an_aws_vpc_peering_connection(pcx.id,
93
- :'status.code' => 'active'
94
- )
87
+ end.to match_an_aws_vpc_peering_connection(pcx.id,
88
+ 'status.code': "active")
95
89
  end
96
90
  end
97
91
  end
98
92
  end
99
-
@@ -1,101 +1,96 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsVpc do
4
4
  extend AWSSupport
5
5
 
6
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
6
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
7
  with_aws "When AWS has a DHCP options" do
8
8
  # Empty DHCP options for the purposes of associating
9
- aws_dhcp_options 'test_dhcp_options'
9
+ aws_dhcp_options "test_dhcp_options"
10
10
 
11
11
  context "Creating an aws_vpc" do
12
12
  it "aws_vpc 'vpc' with cidr_block '10.0.0.0/24' creates a VPC" do
13
- expect_recipe {
14
- aws_vpc 'test_vpc' do
15
- cidr_block '10.0.0.0/24'
13
+ expect_recipe do
14
+ aws_vpc "test_vpc" do
15
+ cidr_block "10.0.0.0/24"
16
16
  end
17
- }.to create_an_aws_vpc('test_vpc',
18
- cidr_block: '10.0.0.0/24',
19
- instance_tenancy: "default",
20
- state: "available",
21
- internet_gateways_entries: nil
22
- ).and be_idempotent
17
+ end.to create_an_aws_vpc("test_vpc",
18
+ cidr_block: "10.0.0.0/24",
19
+ instance_tenancy: "default",
20
+ state: "available",
21
+ internet_gateways_entries: nil).and be_idempotent
23
22
  end
24
23
 
25
24
  it "aws_vpc 'vpc' with cidr_block '10.0.0.0/24' creates a VPC with tags" do
26
- expect_recipe {
27
- aws_vpc 'test_vpc_2' do
28
- cidr_block '10.0.0.0/24'
29
- aws_tags :foo => :bar
25
+ expect_recipe do
26
+ aws_vpc "test_vpc_2" do
27
+ cidr_block "10.0.0.0/24"
28
+ aws_tags foo: :bar
30
29
  end
31
- }.to create_an_aws_vpc('test_vpc_2',
32
- cidr_block: '10.0.0.0/24',
33
- instance_tenancy: "default",
34
- state: "available",
35
- internet_gateways_entries: nil
36
- ).and have_aws_vpc_tags('test_vpc_2',
37
- {"foo" => "bar"}
38
- ).and be_idempotent
30
+ end.to create_an_aws_vpc("test_vpc_2",
31
+ cidr_block: "10.0.0.0/24",
32
+ instance_tenancy: "default",
33
+ state: "available",
34
+ internet_gateways_entries: nil).and have_aws_vpc_tags("test_vpc_2",
35
+ "foo" => "bar").and be_idempotent
39
36
  end
40
37
 
41
38
  it "aws_vpc 'vpc' with all attributes creates a VPC" do
42
- expect_recipe {
43
- aws_vpc 'test_vpc' do
44
- cidr_block '10.0.0.0/24'
39
+ expect_recipe do
40
+ aws_vpc "test_vpc" do
41
+ cidr_block "10.0.0.0/24"
45
42
  internet_gateway true
46
43
  instance_tenancy :dedicated
47
- main_routes '0.0.0.0/0' => :internet_gateway
48
- dhcp_options 'test_dhcp_options'
44
+ main_routes "0.0.0.0/0" => :internet_gateway
45
+ dhcp_options "test_dhcp_options"
49
46
  enable_dns_support true
50
47
  enable_dns_hostnames true
51
48
  end
52
- }.to create_an_aws_vpc('test_vpc',
53
- cidr_block: '10.0.0.0/24',
54
- instance_tenancy: "dedicated",
55
- dhcp_options_id: test_dhcp_options.aws_object.id,
56
- state: "available",
57
- routetables_entries_routes: [
58
- {
59
- destination_cidr_block: '10.0.0.0/24',
60
- gateway_id: 'local',
61
- origin: 'CreateRouteTable',
62
- state: 'active'
63
- },
64
- {
65
- destination_cidr_block: '0.0.0.0/0',
66
- gateway_id: (/igw-\w+/),
67
- origin: 'CreateRoute',
68
- state: 'active'
69
- }
70
- ],
71
- internet_gateways_entries: an_instance_of(::Aws::EC2::InternetGateway)
72
- ).and be_idempotent
49
+ end.to create_an_aws_vpc("test_vpc",
50
+ cidr_block: "10.0.0.0/24",
51
+ instance_tenancy: "dedicated",
52
+ dhcp_options_id: test_dhcp_options.aws_object.id,
53
+ state: "available",
54
+ routetables_entries_routes: [
55
+ {
56
+ destination_cidr_block: "10.0.0.0/24",
57
+ gateway_id: "local",
58
+ origin: "CreateRouteTable",
59
+ state: "active"
60
+ },
61
+ {
62
+ destination_cidr_block: "0.0.0.0/0",
63
+ gateway_id: /igw-\w+/,
64
+ origin: "CreateRoute",
65
+ state: "active"
66
+ }
67
+ ],
68
+ internet_gateways_entries: an_instance_of(::Aws::EC2::InternetGateway)).and be_idempotent
73
69
  end
74
70
  end
75
71
 
76
72
  context "and an existing VPC with values filled in" do
77
- aws_vpc 'test_vpc' do
78
- cidr_block '10.0.0.0/24'
73
+ aws_vpc "test_vpc" do
74
+ cidr_block "10.0.0.0/24"
79
75
  internet_gateway true
80
76
  instance_tenancy :dedicated
81
- main_routes '0.0.0.0/0' => :internet_gateway
82
- dhcp_options 'test_dhcp_options'
77
+ main_routes "0.0.0.0/0" => :internet_gateway
78
+ dhcp_options "test_dhcp_options"
83
79
  enable_dns_support true
84
80
  enable_dns_hostnames true
85
81
  end
86
82
 
87
83
  context "and a route table inside that VPC" do
88
- aws_route_table 'test_route_table' do
89
- vpc 'test_vpc'
84
+ aws_route_table "test_route_table" do
85
+ vpc "test_vpc"
90
86
  end
91
87
  it "aws_vpc can update the main_route_table to it" do
92
- expect_recipe {
93
- aws_vpc 'test_vpc' do
94
- main_route_table 'test_route_table'
88
+ expect_recipe do
89
+ aws_vpc "test_vpc" do
90
+ main_route_table "test_route_table"
95
91
  end
96
- }.to update_an_aws_vpc('test_vpc',
97
- vpc_id: test_route_table.aws_object.vpc_id
98
- ).and be_idempotent
92
+ end.to update_an_aws_vpc("test_vpc",
93
+ vpc_id: test_route_table.aws_object.vpc_id).and be_idempotent
99
94
  end
100
95
 
101
96
  # Clean up the main route table association so we can cleanly delete
@@ -113,74 +108,65 @@ describe Chef::Resource::AwsVpc do
113
108
  end
114
109
  @old_main = test_vpc.aws_object.route_tables.entries[1].id if @old_main.nil?
115
110
  if new_main != @old_main
116
- test_vpc.aws_object.client.replace_route_table_association(association_id: new_main_route_table.id,route_table_id: @old_main)
111
+ test_vpc.aws_object.client.replace_route_table_association(association_id: new_main_route_table.id, route_table_id: @old_main)
117
112
  end
118
113
  end
119
114
  end
120
115
  end
121
116
 
122
117
  it "creates aws_vpc tags" do
123
- expect_recipe {
124
- aws_vpc 'test_vpc' do
125
- cidr_block '10.0.0.0/24'
118
+ expect_recipe do
119
+ aws_vpc "test_vpc" do
120
+ cidr_block "10.0.0.0/24"
126
121
  aws_tags key1: "value"
127
122
  end
128
- }.to create_an_aws_vpc('test_vpc')
129
- .and have_aws_vpc_tags('test_vpc',
130
- {
131
- 'Name' => 'test_vpc',
132
- 'key1' => 'value'
133
- }
134
- ).and be_idempotent
123
+ end.to create_an_aws_vpc("test_vpc")
124
+ .and have_aws_vpc_tags("test_vpc",
125
+ "Name" => "test_vpc",
126
+ "key1" => "value").and be_idempotent
135
127
  end
136
128
 
137
129
  context "with existing tags" do
138
- aws_vpc 'test_vpc' do
139
- cidr_block '10.0.0.0/24'
130
+ aws_vpc "test_vpc" do
131
+ cidr_block "10.0.0.0/24"
140
132
  aws_tags key1: "value"
141
133
  end
142
134
 
143
135
  it "updates aws_vpc tags" do
144
- expect_recipe {
145
- aws_vpc 'test_vpc' do
136
+ expect_recipe do
137
+ aws_vpc "test_vpc" do
146
138
  aws_tags key1: "value2", key2: nil
147
139
  end
148
- }.to have_aws_vpc_tags('test_vpc',
149
- {
150
- 'Name' => 'test_vpc',
151
- 'key1' => 'value2',
152
- 'key2' => ''
153
- }
154
- ).and be_idempotent
140
+ end.to have_aws_vpc_tags("test_vpc",
141
+ "Name" => "test_vpc",
142
+ "key1" => "value2",
143
+ "key2" => "").and be_idempotent
155
144
  end
156
145
 
157
146
  it "removes all aws_vpc tags except Name" do
158
- expect_recipe {
159
- aws_vpc 'test_vpc' do
147
+ expect_recipe do
148
+ aws_vpc "test_vpc" do
160
149
  aws_tags({})
161
150
  end
162
- }.to have_aws_vpc_tags('test_vpc',
163
- {
164
- 'Name' => 'test_vpc'
165
- }
166
- ).and be_idempotent
151
+ end.to have_aws_vpc_tags("test_vpc",
152
+ "Name" => "test_vpc").and be_idempotent
167
153
  end
168
154
  end
169
155
 
170
156
  it "aws_vpc 'vpc' with no attributes fails to create a VPC (must specify cidr_block)" do
171
- expect_converge {
172
- aws_vpc 'test_vpc' do
157
+ expect_converge do
158
+ aws_vpc "test_vpc" do
173
159
  end
174
- }.to raise_error(::ArgumentError, /missing required parameter params\[:cidr_block\]/)
160
+ end.to raise_error(::ArgumentError, /missing required parameter params\[:cidr_block\]/)
175
161
  end
176
162
 
177
163
  context "When having two VPC's and a peering connection between them" do
178
164
  aws_vpc "test_vpc_1" do
179
- cidr_block '20.0.0.0/24'
165
+ cidr_block "20.0.0.0/24"
180
166
  end
181
167
 
182
168
  aws_vpc "test_vpc_2" do
183
- cidr_block '21.0.0.0/24'
169
+ cidr_block "21.0.0.0/24"
184
170
  end
185
171
 
186
172
  aws_vpc_peering_connection "test_peering_connection" do
@@ -189,42 +175,40 @@ describe Chef::Resource::AwsVpc do
189
175
  end
190
176
 
191
177
  it "deletes the peer connection when one of the vpc's is deleted." do
192
- expect_recipe {
178
+ expect_recipe do
193
179
  aws_vpc "test_vpc_1" do
194
180
  action :purge
195
181
  end
196
- }.to match_an_aws_vpc_peering_connection('test_peering_connection',
197
- :'status.code' => 'deleted'
198
- ).and be_idempotent
182
+ end.to match_an_aws_vpc_peering_connection("test_peering_connection",
183
+ 'status.code': "deleted").and be_idempotent
199
184
  end
200
185
  end
201
186
 
202
187
  context "and When :purge action is called for a VPC, and it contains NAT gateways" do
203
- aws_vpc 'test_vpc' do
204
- cidr_block '10.0.0.0/24'
188
+ aws_vpc "test_vpc" do
189
+ cidr_block "10.0.0.0/24"
205
190
  internet_gateway true
206
191
  end
207
192
 
208
- aws_subnet 'test_subnet' do
209
- vpc 'test_vpc'
193
+ aws_subnet "test_subnet" do
194
+ vpc "test_vpc"
210
195
  end
211
196
 
212
- aws_eip_address 'test_eip'
197
+ aws_eip_address "test_eip"
213
198
 
214
- aws_nat_gateway 'test_nat_gateway' do
215
- subnet 'test_subnet'
216
- eip_address 'test_eip'
199
+ aws_nat_gateway "test_nat_gateway" do
200
+ subnet "test_subnet"
201
+ eip_address "test_eip"
217
202
  end
218
203
 
219
- it 'they should be deleted' do
220
- r = recipe {
221
- aws_vpc 'test_vpc' do
204
+ it "they should be deleted" do
205
+ r = recipe do
206
+ aws_vpc "test_vpc" do
222
207
  action :purge
223
208
  end
224
- }
225
- expect(r).to match_an_aws_nat_gateway('test_nat_gateway',
226
- :state => 'deleted'
227
- ).and be_idempotent
209
+ end
210
+ expect(r).to match_an_aws_nat_gateway("test_nat_gateway",
211
+ state: "deleted").and be_idempotent
228
212
  end
229
213
  end
230
214
  end