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,11 +1,10 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsRdsInstance 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 connection to AWS, a VPC, two subnets, a db subnet group, and a db parameter group" do
8
-
9
8
  azs = []
10
9
  driver.ec2.describe_availability_zones.availability_zones.each do |az|
11
10
  azs << az
@@ -13,18 +12,18 @@ describe Chef::Resource::AwsRdsInstance do
13
12
  az_1 = azs[0].zone_name
14
13
  az_2 = azs[1].zone_name
15
14
  aws_vpc "test_vpc" do
16
- cidr_block '10.0.5.0/24'
15
+ cidr_block "10.0.5.0/24"
17
16
  internet_gateway true
18
17
  end
19
18
 
20
19
  aws_subnet "test_subnet" do
21
- vpc 'test_vpc'
20
+ vpc "test_vpc"
22
21
  cidr_block "10.0.5.0/26"
23
22
  availability_zone az_1
24
23
  end
25
24
 
26
25
  aws_subnet "test_subnet_2" do
27
- vpc 'test_vpc'
26
+ vpc "test_vpc"
28
27
  cidr_block "10.0.5.64/26"
29
28
  availability_zone az_2
30
29
  end
@@ -37,11 +36,11 @@ describe Chef::Resource::AwsRdsInstance do
37
36
  aws_rds_parameter_group "test-db-parameter-group" do
38
37
  db_parameter_group_family "postgres9.6"
39
38
  description "testing provisioning"
40
- parameters [{:parameter_name => "max_connections", :parameter_value => "250", :apply_method => "pending-reboot"}]
39
+ parameters [{ parameter_name: "max_connections", parameter_value: "250", apply_method: "pending-reboot" }]
41
40
  end
42
41
 
43
42
  it "aws_rds_instance 'test-rds-instance' creates an rds instance that can parse the aws_rds_subnet_group and aws_rds_parameter_group" do
44
- expect_recipe {
43
+ expect_recipe do
45
44
  aws_rds_instance "test-rds-instance" do
46
45
  engine "postgres"
47
46
  publicly_accessible false
@@ -53,12 +52,11 @@ describe Chef::Resource::AwsRdsInstance do
53
52
  db_subnet_group_name "test-db-subnet-group"
54
53
  db_parameter_group_name "test-db-parameter-group"
55
54
  end
56
- }.to create_an_aws_rds_instance('test-rds-instance',
57
- engine: 'postgres',
58
- multi_az: false,
59
- db_instance_class: "db.t2.micro",
60
- master_username: "thechief",
61
- ).and be_idempotent
55
+ end.to create_an_aws_rds_instance("test-rds-instance",
56
+ engine: "postgres",
57
+ multi_az: false,
58
+ db_instance_class: "db.t2.micro",
59
+ master_username: "thechief").and be_idempotent
62
60
  r = driver.rds_resource.db_instance("test-rds-instance")
63
61
  expect(r.db_subnet_group.db_subnet_group_name).to eq("test-db-subnet-group")
64
62
  expect(r.db_parameter_groups.first.db_parameter_group_name).to eq("test-db-parameter-group")
@@ -66,7 +64,7 @@ describe Chef::Resource::AwsRdsInstance do
66
64
  end
67
65
 
68
66
  it "aws_rds_instance prefers explicit options" do
69
- expect_recipe {
67
+ expect_recipe do
70
68
  aws_rds_instance "test-rds-instance2" do
71
69
  engine "postgres"
72
70
  publicly_accessible false
@@ -77,19 +75,18 @@ describe Chef::Resource::AwsRdsInstance do
77
75
  allocated_storage 5
78
76
  additional_options(multi_az: true, backup_retention_period: 2)
79
77
  end
80
- }.to create_an_aws_rds_instance('test-rds-instance2',
81
- engine: 'postgres',
82
- multi_az: false,
83
- db_instance_class: "db.t2.micro",
84
- master_username: "thechief",
85
- backup_retention_period: 2)
86
-
78
+ end.to create_an_aws_rds_instance("test-rds-instance2",
79
+ engine: "postgres",
80
+ multi_az: false,
81
+ db_instance_class: "db.t2.micro",
82
+ master_username: "thechief",
83
+ backup_retention_period: 2)
87
84
  end
88
85
 
89
86
  tagging_id = Random.rand(1000)
90
87
 
91
88
  it "creates aws_rds_instance tags" do
92
- expect_recipe {
89
+ expect_recipe do
93
90
  aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
94
91
  aws_tags key1: "value"
95
92
  allocated_storage 5
@@ -98,12 +95,9 @@ describe Chef::Resource::AwsRdsInstance do
98
95
  master_username "thechief"
99
96
  master_user_password "securesecure"
100
97
  end
101
- }.to create_an_aws_rds_instance("test-rds-instance-tagging-#{tagging_id}")
102
- .and have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}",
103
- {
104
- 'key1' => 'value'
105
- }
106
- ).and be_idempotent
98
+ end.to create_an_aws_rds_instance("test-rds-instance-tagging-#{tagging_id}")
99
+ .and have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}",
100
+ "key1" => "value").and be_idempotent
107
101
  end
108
102
 
109
103
  # if we use let, the tagging_id method is not available in the context block
@@ -120,7 +114,7 @@ describe Chef::Resource::AwsRdsInstance do
120
114
  end
121
115
 
122
116
  it "updates aws_rds_instance tags" do
123
- expect_recipe {
117
+ expect_recipe do
124
118
  aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
125
119
  aws_tags key1: "value1", key2: "value2"
126
120
  allocated_storage 5
@@ -129,16 +123,13 @@ describe Chef::Resource::AwsRdsInstance do
129
123
  master_username "thechief"
130
124
  master_user_password "securesecure"
131
125
  end
132
- }.to have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}",
133
- {
134
- 'key1' => 'value1',
135
- 'key2' => 'value2'
136
- }
137
- ).and be_idempotent
126
+ end.to have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}",
127
+ "key1" => "value1",
128
+ "key2" => "value2").and be_idempotent
138
129
  end
139
130
 
140
131
  it "removes all aws_rds_instance tags" do
141
- expect_recipe {
132
+ expect_recipe do
142
133
  aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
143
134
  aws_tags({})
144
135
  allocated_storage 5
@@ -147,11 +138,9 @@ describe Chef::Resource::AwsRdsInstance do
147
138
  master_username "thechief"
148
139
  master_user_password "securesecure"
149
140
  end
150
- }.to have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}", {}
151
- ).and be_idempotent
141
+ end.to have_aws_rds_instance_tags("test-rds-instance-tagging-#{tagging_id}", {}).and be_idempotent
152
142
  end
153
143
  end
154
-
155
144
  end
156
145
  end
157
146
  end
@@ -1,51 +1,45 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsRdsParameterGroup do
4
4
  extend AWSSupport
5
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
6
-
5
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
7
6
  with_aws "no required pre-existing objects" do
8
7
  it "creates an empty parameter group" do
9
- expect_recipe {
8
+ expect_recipe do
10
9
  aws_rds_parameter_group "test-db-parameter-group" do
11
10
  db_parameter_group_family "postgres9.4"
12
11
  description "testing provisioning"
13
12
  end
14
- }.to create_an_aws_rds_parameter_group("test-db-parameter-group",
15
- :db_parameter_group_family => "postgres9.4",
16
- :description => "testing provisioning"
17
- )
13
+ end.to create_an_aws_rds_parameter_group("test-db-parameter-group",
14
+ db_parameter_group_family: "postgres9.4",
15
+ description: "testing provisioning")
18
16
  end
19
17
 
20
18
  it "creates a parameter group with tags" do
21
- expect_recipe {
19
+ expect_recipe do
22
20
  aws_rds_parameter_group "test-db-parameter-group-with-tags" do
23
21
  db_parameter_group_family "postgres9.4"
24
22
  description "testing provisioning"
25
- aws_tags key1: 'value'
23
+ aws_tags key1: "value"
26
24
  end
27
- }.to create_an_aws_rds_parameter_group("test-db-parameter-group-with-tags")
28
- .and have_aws_rds_parameter_group_tags("test-db-parameter-group-with-tags",
29
- {
30
- 'key1' => 'value'
31
- }
32
- )
25
+ end.to create_an_aws_rds_parameter_group("test-db-parameter-group-with-tags")
26
+ .and have_aws_rds_parameter_group_tags("test-db-parameter-group-with-tags",
27
+ "key1" => "value")
33
28
  end
34
29
 
35
30
  it "creates an new parameter group with parameters" do
36
31
  results = nil
37
- expect_recipe {
32
+ expect_recipe do
38
33
  results = aws_rds_parameter_group "test-db-parameter-group-with-parameters" do
39
34
  db_parameter_group_family "postgres9.4"
40
35
  description "testing provisioning"
41
- parameters [{:parameter_name => "max_connections", :parameter_value => "250", :apply_method => "pending-reboot"}]
36
+ parameters [{ parameter_name: "max_connections", parameter_value: "250", apply_method: "pending-reboot" }]
42
37
  end
43
- }.to create_an_aws_rds_parameter_group("test-db-parameter-group-with-parameters",
44
- :db_parameter_group_family => "postgres9.4",
45
- :description => "testing provisioning",
46
- )
38
+ end.to create_an_aws_rds_parameter_group("test-db-parameter-group-with-parameters",
39
+ db_parameter_group_family: "postgres9.4",
40
+ description: "testing provisioning")
47
41
 
48
- expect(results.parameters).to eq([{:parameter_name => "max_connections", :parameter_value => "250", :apply_method => "pending-reboot"}])
42
+ expect(results.parameters).to eq([{ parameter_name: "max_connections", parameter_value: "250", apply_method: "pending-reboot" }])
49
43
  results.parameters.each do |parameter|
50
44
  expect(parameter[:parameter_value]).to eq("250") if parameter[:parameter_name] == "max_connections"
51
45
  end
@@ -54,37 +48,40 @@ describe Chef::Resource::AwsRdsParameterGroup do
54
48
  context "when the object is updated" do
55
49
  let(:final_max_connection_value) { "300" }
56
50
  let(:final_application_name_value) { "second_name" }
57
- let(:initial_parameters) { [
58
- {:parameter_name => "application_name", :parameter_value => "first_name", :apply_method => "pending-reboot"}
59
- ] }
60
- let(:updated_parameters) { [
61
- {:parameter_name => "application_name", :parameter_value => final_application_name_value, :apply_method => "pending-reboot"},
62
- {:parameter_name => "max_connections", :parameter_value => final_max_connection_value, :apply_method => "pending-reboot"}
63
- ] }
51
+ let(:initial_parameters) do
52
+ [
53
+ { parameter_name: "application_name", parameter_value: "first_name", apply_method: "pending-reboot" }
54
+ ]
55
+ end
56
+ let(:updated_parameters) do
57
+ [
58
+ { parameter_name: "application_name", parameter_value: final_application_name_value, apply_method: "pending-reboot" },
59
+ { parameter_name: "max_connections", parameter_value: final_max_connection_value, apply_method: "pending-reboot" }
60
+ ]
61
+ end
64
62
  it "updates properly" do
65
63
  results = nil
66
- expect_recipe {
64
+ expect_recipe do
67
65
  results = aws_rds_parameter_group "test-db-parameter-group-updated" do
68
66
  db_parameter_group_family "postgres9.4"
69
67
  description "testing provisioning"
70
68
  parameters initial_parameters
71
69
  end
72
- }
70
+ end
73
71
  expect(results.parameters).to eq(initial_parameters)
74
72
 
75
73
  results_2 = nil
76
- expect_recipe {
74
+ expect_recipe do
77
75
  results_2 = aws_rds_parameter_group "test-db-parameter-group-updated" do
78
76
  db_parameter_group_family "postgres9.4"
79
77
  description "testing provisioning"
80
78
  parameters updated_parameters
81
79
  end
82
- }
80
+ end
83
81
  expect(results_2.parameters).to eq(updated_parameters)
84
82
  results_2.parameters.each do |parameter|
85
83
  expect(parameter[:parameter_value]).to eq(final_max_connection_value) if parameter[:parameter_name] == "max_connections"
86
84
  expect(parameter[:parameter_value]).to eq(final_application_name_value) if parameter[:parameter_name] == "application_name"
87
-
88
85
  end
89
86
  end
90
87
  end
@@ -1,14 +1,13 @@
1
- require 'spec_helper'
2
- require 'aws-sdk'
3
- require 'set'
1
+ require "spec_helper"
2
+ require "aws-sdk"
3
+ require "set"
4
4
 
5
5
  describe Chef::Resource::AwsRdsSubnetGroup do
6
6
  extend AWSSupport
7
7
 
8
- when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
8
+ when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
9
9
  with_aws "with a VPC with an internet gateway and subnet" do
10
-
11
- #region = ENV['AWS_TEST_DRIVER'][5..-1]
10
+ # region = ENV['AWS_TEST_DRIVER'][5..-1]
12
11
 
13
12
  azs = []
14
13
  driver.ec2.describe_availability_zones.availability_zones.each do |az|
@@ -18,88 +17,79 @@ describe Chef::Resource::AwsRdsSubnetGroup do
18
17
  az_2 = azs[1].zone_name
19
18
 
20
19
  aws_vpc "test_vpc" do
21
- cidr_block '10.0.0.0/24'
20
+ cidr_block "10.0.0.0/24"
22
21
  internet_gateway true
23
22
  end
24
23
 
25
24
  aws_subnet "test_subnet" do
26
- vpc 'test_vpc'
25
+ vpc "test_vpc"
27
26
  cidr_block "10.0.0.0/26"
28
27
  availability_zone az_1
29
28
  end
30
29
 
31
30
  aws_subnet "test_subnet_2" do
32
- vpc 'test_vpc'
31
+ vpc "test_vpc"
33
32
  cidr_block "10.0.0.64/26"
34
33
  availability_zone az_2
35
34
  end
36
35
 
37
36
  it "creates a database subnet group containing multiple subnets" do
38
- expect_recipe {
37
+ expect_recipe do
39
38
  aws_rds_subnet_group "test-db-subnet-group" do
40
39
  description "some_description"
41
40
  subnets ["test_subnet", test_subnet_2.aws_object.id]
42
41
  end
43
- }.to create_an_aws_rds_subnet_group("test-db-subnet-group",
44
- :db_subnet_group_description => "some_description",
45
- :subnets => Set.new([ {:subnet_status => "Active",
46
- :subnet_identifier => test_subnet_2.aws_object.id,
47
- :subnet_availability_zone => {:name => az_2}},
48
- {:subnet_status => "Active",
49
- :subnet_identifier => test_subnet.aws_object.id,
50
- :subnet_availability_zone => {:name => az_1}}])
51
- ).and be_idempotent
42
+ end.to create_an_aws_rds_subnet_group("test-db-subnet-group",
43
+ db_subnet_group_description: "some_description",
44
+ subnets: Set.new([{ subnet_status: "Active",
45
+ subnet_identifier: test_subnet_2.aws_object.id,
46
+ subnet_availability_zone: { name: az_2 } },
47
+ { subnet_status: "Active",
48
+ subnet_identifier: test_subnet.aws_object.id,
49
+ subnet_availability_zone: { name: az_1 } }])).and be_idempotent
52
50
  end
53
51
 
54
52
  it "creates aws_rds_subnet_group tags" do
55
- expect_recipe {
53
+ expect_recipe do
56
54
  aws_rds_subnet_group "test-db-subnet-group" do
57
55
  description "some_description"
58
56
  subnets ["test_subnet", test_subnet_2.aws_object.id]
59
- aws_tags key1: 'value'
57
+ aws_tags key1: "value"
60
58
  end
61
- }.to create_an_aws_rds_subnet_group("test-db-subnet-group")
62
- .and have_aws_rds_subnet_group_tags("test-db-subnet-group",
63
- {
64
- 'key1' => 'value'
65
- }
66
- ).and be_idempotent
59
+ end.to create_an_aws_rds_subnet_group("test-db-subnet-group")
60
+ .and have_aws_rds_subnet_group_tags("test-db-subnet-group",
61
+ "key1" => "value").and be_idempotent
67
62
  end
68
63
 
69
64
  context "with existing tags" do
70
65
  aws_rds_subnet_group "test-db-subnet-group" do
71
66
  description "some_description"
72
67
  subnets ["test_subnet", test_subnet_2.aws_object.id]
73
- aws_tags key1: 'value'
68
+ aws_tags key1: "value"
74
69
  end
75
70
 
76
71
  it "updates aws_rds_subnet_group tags" do
77
- expect_recipe {
72
+ expect_recipe do
78
73
  aws_rds_subnet_group "test-db-subnet-group" do
79
74
  description "some_description"
80
75
  subnets ["test_subnet", test_subnet_2.aws_object.id]
81
- aws_tags key1: "value2", key2: ''
76
+ aws_tags key1: "value2", key2: ""
82
77
  end
83
- }.to have_aws_rds_subnet_group_tags("test-db-subnet-group",
84
- {
85
- 'key1' => 'value2',
86
- 'key2' => ''
87
- }
88
- ).and be_idempotent
78
+ end.to have_aws_rds_subnet_group_tags("test-db-subnet-group",
79
+ "key1" => "value2",
80
+ "key2" => "").and be_idempotent
89
81
  end
90
82
 
91
83
  it "removes all aws_rds_subnet_group tags" do
92
- expect_recipe {
84
+ expect_recipe do
93
85
  aws_rds_subnet_group "test-db-subnet-group" do
94
86
  description "some_description"
95
87
  subnets ["test_subnet", test_subnet_2.aws_object.id]
96
88
  aws_tags({})
97
89
  end
98
- }.to have_aws_rds_subnet_group_tags("test-db-subnet-group", {}
99
- ).and be_idempotent
90
+ end.to have_aws_rds_subnet_group_tags("test-db-subnet-group", {}).and be_idempotent
100
91
  end
101
92
  end
102
-
103
93
  end
104
94
  end
105
95
  end
@@ -1,96 +1,94 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Chef::Resource::AwsRoute53HostedZone 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 connected to AWS" do
8
-
9
8
  context "aws_route53_hosted_zone" do
10
-
11
9
  # for the occasional spec where the test zone won't be automatically deleted, the spec can set
12
10
  # @zone_to_delete to communicate the zone name to the 'after' block. (this can't be done just with
13
11
  # let-vars because attribute values in dependent RecordSet resources have to be hard-coded.)
14
12
  let(:zone_to_delete) { @zone_to_delete }
15
13
 
16
- after(:example) {
14
+ after(:example) do
17
15
  if zone_to_delete
18
- converge {
16
+ converge do
19
17
  aws_route53_hosted_zone zone_to_delete do
20
18
  action :destroy
21
19
  end
22
- }
20
+ end
23
21
  end
24
- }
22
+ end
25
23
 
26
24
  let(:zone_name) { "aws-spec-#{Time.now.to_i}.com" }
27
25
 
28
26
  context ":create" do
29
27
  it "creates a hosted zone without attributes" do
30
- expect(recipe {
28
+ expect(recipe do
31
29
  aws_route53_hosted_zone zone_name
32
- }).to create_an_aws_route53_hosted_zone(zone_name).and be_idempotent
30
+ end).to create_an_aws_route53_hosted_zone(zone_name).and be_idempotent
33
31
  end
34
32
 
35
33
  it "creates a hosted zone with attributes" do
36
34
  test_comment = "Test comment for spec."
37
35
 
38
- expect_recipe {
36
+ expect_recipe do
39
37
  aws_route53_hosted_zone zone_name do
40
38
  comment test_comment
41
39
  end
42
- }.to create_an_aws_route53_hosted_zone(zone_name,
43
- config: { comment: test_comment }).and be_idempotent
40
+ end.to create_an_aws_route53_hosted_zone(zone_name,
41
+ config: { comment: test_comment }).and be_idempotent
44
42
  end
45
43
 
46
44
  # we don't want to go overboard testing all our validations, but this is the one that can cause the
47
45
  # most difficult user confusion, and AWS won't catch it.
48
46
  it "crashes if the zone name has a trailing dot" do
49
- expect_converge {
47
+ expect_converge do
50
48
  aws_route53_hosted_zone "#{zone_name}."
51
- }.to raise_error(Chef::Exceptions::ValidationFailed, /domain name cannot end with a dot/)
49
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /domain name cannot end with a dot/)
52
50
  end
53
51
 
54
52
  it "updates the zone comment" do
55
53
  expected_comment = "Updated comment."
56
54
 
57
- expect_recipe {
55
+ expect_recipe do
58
56
  aws_route53_hosted_zone zone_name do
59
57
  comment "Initial comment."
60
58
  end
61
59
  aws_route53_hosted_zone zone_name do
62
60
  comment expected_comment
63
61
  end
64
- }.to create_an_aws_route53_hosted_zone(zone_name,
65
- config: { comment: expected_comment }).and be_idempotent
62
+ end.to create_an_aws_route53_hosted_zone(zone_name,
63
+ config: { comment: expected_comment }).and be_idempotent
66
64
  end
67
65
 
68
66
  it "updates the zone comment when none is given" do
69
- expect_recipe {
67
+ expect_recipe do
70
68
  aws_route53_hosted_zone zone_name do
71
69
  comment "Initial comment."
72
70
  end
73
71
  aws_route53_hosted_zone zone_name do
74
72
  end
75
- }.to create_an_aws_route53_hosted_zone(zone_name,
76
- config: { comment: nil }).and be_idempotent
73
+ end.to create_an_aws_route53_hosted_zone(zone_name,
74
+ config: { comment: nil }).and be_idempotent
77
75
  end
78
76
  end
79
77
 
80
78
  context "RecordSets" do
81
- let(:sdk_cname_rr) {
79
+ let(:sdk_cname_rr) do
82
80
  {
83
- name: "some-host.feegle.com.", # AWS adds the trailing dot.
81
+ name: "some-host.feegle.com.", # AWS adds the trailing dot.
84
82
  type: "CNAME",
85
83
  ttl: 3600,
86
- resource_records: [{ value: "some-other-host" }],
84
+ resource_records: [{ value: "some-other-host" }]
87
85
  }
88
- }
86
+ end
89
87
 
90
88
  it "crashes on duplicate RecordSets" do
91
- expect_converge {
89
+ expect_converge do
92
90
  aws_route53_hosted_zone "chasm.com" do
93
- record_sets {
91
+ record_sets do
94
92
  aws_route53_record_set "wooster1" do
95
93
  rr_name "wooster.chasm.com"
96
94
  type "CNAME"
@@ -103,163 +101,163 @@ describe Chef::Resource::AwsRoute53HostedZone do
103
101
  ttl 3600
104
102
  resource_records ["141.222.1.1"]
105
103
  end
106
- }
104
+ end
107
105
  end
108
- }.to raise_error(Chef::Exceptions::ValidationFailed, /Duplicate RecordSet found in resource/)
106
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /Duplicate RecordSet found in resource/)
109
107
  end
110
108
 
111
109
  # normally wouldn't bother with this, but it's best to be safe with the inlined resources.
112
110
  it "crashes on a RecordSet with an invalid action" do
113
- expect_converge {
111
+ expect_converge do
114
112
  aws_route53_hosted_zone zone_name do
115
- record_sets {
113
+ record_sets do
116
114
  aws_route53_record_set "wooster1" do
117
115
  action :invoke
118
116
  rr_name "wooster.example.com"
119
117
  type "CNAME"
120
118
  ttl 300
121
119
  end
122
- }
120
+ end
123
121
  end
124
- }.to raise_error(Chef::Exceptions::ValidationFailed, /Option action must be equal to one of/)
122
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /Option action must be equal to one of/)
125
123
  end
126
124
 
127
125
  it "creates a hosted zone with a RecordSet" do
128
- expect_recipe {
126
+ expect_recipe do
129
127
  aws_route53_hosted_zone "feegle.com" do
130
- record_sets {
128
+ record_sets do
131
129
  aws_route53_record_set "some-hostname CNAME" do
132
130
  rr_name "some-host.feegle.com"
133
131
  type "CNAME"
134
132
  ttl 3600
135
133
  resource_records ["some-other-host"]
136
134
  end
137
- }
135
+ end
138
136
  end
139
- }.to create_an_aws_route53_hosted_zone("feegle.com",
140
- resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
137
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
138
+ resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
141
139
  # the empty {} acts as a wildcard, and all zones have SOA and NS records we want to skip.
142
140
  end
143
141
 
144
142
  it "creates a hosted zone with a RecordSet with an RR name with a trailing dot" do
145
- expect_recipe {
143
+ expect_recipe do
146
144
  aws_route53_hosted_zone "feegle.com" do
147
- record_sets {
145
+ record_sets do
148
146
  aws_route53_record_set "some-host.feegle.com." do
149
147
  type "CNAME"
150
148
  ttl 3600
151
149
  resource_records ["some-other-host"]
152
150
  end
153
- }
151
+ end
154
152
  end
155
- }.to create_an_aws_route53_hosted_zone("feegle.com",
156
- resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
153
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
154
+ resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
157
155
  end
158
156
 
159
157
  # AWS's error for this is "FATAL problem: DomainLabelEmpty encountered", so we help the user out.
160
158
  it "crashes with a RecordSet with a mismatched zone name with a trailing dot" do
161
- expect_converge {
159
+ expect_converge do
162
160
  aws_route53_hosted_zone "feegle.com" do
163
- record_sets {
161
+ record_sets do
164
162
  aws_route53_record_set "some-host.wrong-zone.com." do
165
163
  type "CNAME"
166
164
  ttl 3600
167
165
  resource_records ["some-other-host"]
168
166
  end
169
- }
167
+ end
170
168
  end
171
- }.to raise_error(Chef::Exceptions::ValidationFailed, /RecordSet name.*does not match parent/)
169
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /RecordSet name.*does not match parent/)
172
170
  end
173
171
 
174
172
  it "creates and updates a RecordSet" do
175
- expected_rr = sdk_cname_rr.merge({ ttl: 1800 })
173
+ expected_rr = sdk_cname_rr.merge(ttl: 1800)
176
174
 
177
- expect_recipe {
175
+ expect_recipe do
178
176
  aws_route53_hosted_zone "feegle.com" do
179
- record_sets {
177
+ record_sets do
180
178
  aws_route53_record_set "some-hostname CNAME" do
181
179
  rr_name "some-host"
182
180
  type "CNAME"
183
181
  ttl 3600
184
182
  resource_records ["some-other-host"]
185
183
  end
186
- }
184
+ end
187
185
  end
188
186
 
189
187
  aws_route53_hosted_zone "feegle.com" do
190
- record_sets {
188
+ record_sets do
191
189
  aws_route53_record_set "some-hostname CNAME" do
192
190
  rr_name "some-host"
193
191
  type "CNAME"
194
192
  ttl 1800
195
193
  resource_records ["some-other-host"]
196
194
  end
197
- }
195
+ end
198
196
  end
199
- }.to create_an_aws_route53_hosted_zone("feegle.com",
200
- resource_record_sets: [{}, {}, expected_rr]).and be_idempotent
197
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
198
+ resource_record_sets: [{}, {}, expected_rr]).and be_idempotent
201
199
  end
202
200
 
203
201
  it "creates and deletes a RecordSet" do
204
- expect_recipe {
202
+ expect_recipe do
205
203
  aws_route53_hosted_zone "feegle.com" do
206
- record_sets {
204
+ record_sets do
207
205
  aws_route53_record_set "some-api-host" do
208
206
  type "CNAME"
209
207
  ttl 3600
210
208
  resource_records ["some-other-host"]
211
209
  end
212
- }
210
+ end
213
211
  end
214
212
 
215
213
  aws_route53_hosted_zone "feegle.com" do
216
- record_sets {
214
+ record_sets do
217
215
  aws_route53_record_set "some-api-host" do
218
216
  action :destroy
219
217
  type "CNAME"
220
218
  ttl 3600
221
219
  resource_records ["some-other-host"]
222
220
  end
223
- }
221
+ end
224
222
  end
225
- }.to create_an_aws_route53_hosted_zone("feegle.com",
226
- resource_record_sets: [{}, {}]).and be_idempotent
223
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
224
+ resource_record_sets: [{}, {}]).and be_idempotent
227
225
  end
228
226
 
229
227
  it "automatically uses the parent zone name in the RecordSet name" do
230
- expect_recipe {
228
+ expect_recipe do
231
229
  aws_route53_hosted_zone "feegle.com" do
232
- record_sets {
230
+ record_sets do
233
231
  aws_route53_record_set "some-host" do
234
232
  type "CNAME"
235
233
  ttl 3600
236
234
  resource_records ["some-other-host"]
237
235
  end
238
- }
236
+ end
239
237
  end
240
- }.to create_an_aws_route53_hosted_zone("feegle.com",
241
- resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
238
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
239
+ resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
242
240
  end
243
241
 
244
242
  it "raises the AWS exception when trying to delete a record using mismatched values" do
245
243
  @zone_to_delete = zone_name = "raise-aws-exception.com"
246
244
 
247
- expect_converge {
245
+ expect_converge do
248
246
  aws_route53_hosted_zone zone_name do
249
- record_sets {
247
+ record_sets do
250
248
  aws_route53_record_set "some-hostname CNAME" do
251
249
  rr_name "some-api-host.raise-aws-exception.com"
252
250
  type "CNAME"
253
251
  ttl 3600
254
252
  resource_records ["some-other-host"]
255
253
  end
256
- }
254
+ end
257
255
  end
258
- }.not_to raise_error
256
+ end.not_to raise_error
259
257
 
260
- expect_converge {
258
+ expect_converge do
261
259
  aws_route53_hosted_zone zone_name do
262
- record_sets {
260
+ record_sets do
263
261
  aws_route53_record_set "some-hostname CNAME" do
264
262
  action :destroy
265
263
  rr_name "some-api-host.raise-aws-exception.com"
@@ -267,24 +265,24 @@ describe Chef::Resource::AwsRoute53HostedZone do
267
265
  ttl 100
268
266
  resource_records ["some-other-host"]
269
267
  end
270
- }
268
+ end
271
269
  end
272
- }.to raise_error(::Aws::Route53::Errors::InvalidChangeBatch, /Tried to delete.*the values provided do not match the current values/)
270
+ end.to raise_error(::Aws::Route53::Errors::InvalidChangeBatch, /Tried to delete.*the values provided do not match the current values/)
273
271
  end
274
272
 
275
273
  it "uses the resource name as the :rr_name" do
276
- expect_recipe {
274
+ expect_recipe do
277
275
  aws_route53_hosted_zone "feegle.com" do
278
- record_sets {
276
+ record_sets do
279
277
  aws_route53_record_set "some-host" do
280
278
  type "CNAME"
281
279
  ttl 3600
282
280
  resource_records ["some-other-host"]
283
281
  end
284
- }
282
+ end
285
283
  end
286
- }.to create_an_aws_route53_hosted_zone("feegle.com",
287
- resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
284
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
285
+ resource_record_sets: [{}, {}, sdk_cname_rr]).and be_idempotent
288
286
  end
289
287
 
290
288
  context "inheriting default property values" do
@@ -293,12 +291,12 @@ describe Chef::Resource::AwsRoute53HostedZone do
293
291
  name: "another-host.feegle.com.",
294
292
  type: "A",
295
293
  ttl: 3600,
296
- resource_records: [{value: "8.8.8.8"}]
294
+ resource_records: [{ value: "8.8.8.8" }]
297
295
  }
298
- expect_recipe {
296
+ expect_recipe do
299
297
  aws_route53_hosted_zone "feegle.com" do
300
298
  defaults ttl: 3600, type: "CNAME"
301
- record_sets {
299
+ record_sets do
302
300
  aws_route53_record_set "some-host" do
303
301
  resource_records ["some-other-host"]
304
302
  end
@@ -306,18 +304,18 @@ describe Chef::Resource::AwsRoute53HostedZone do
306
304
  type "A"
307
305
  resource_records ["8.8.8.8"]
308
306
  end
309
- }
307
+ end
310
308
  end
311
- }.to create_an_aws_route53_hosted_zone("feegle.com",
312
- resource_record_sets: [{}, {},
313
- expected_a, sdk_cname_rr]).and be_idempotent
309
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
310
+ resource_record_sets: [{}, {},
311
+ expected_a, sdk_cname_rr]).and be_idempotent
314
312
  end
315
313
 
316
314
  it "only provides defaults for certain properties" do
317
- expect_converge {
315
+ expect_converge do
318
316
  aws_route53_hosted_zone "feegle.com" do
319
317
  defaults invalid_default: 42
320
- record_sets {
318
+ record_sets do
321
319
  aws_route53_record_set "some-host" do
322
320
  resource_records ["some-other-host"]
323
321
  end
@@ -325,250 +323,252 @@ describe Chef::Resource::AwsRoute53HostedZone do
325
323
  type "A"
326
324
  resource_records ["8.8.8.8"]
327
325
  end
328
- }
326
+ end
329
327
  end
330
- }.to raise_error(Chef::Exceptions::ValidationFailed, /'defaults' keys may be any of/)
328
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /'defaults' keys may be any of/)
331
329
  end
332
330
 
333
331
  it "checks for requiredness" do
334
- expect_converge {
332
+ expect_converge do
335
333
  aws_route53_hosted_zone "feegle.com" do
336
334
  defaults ttl: 3600
337
- record_sets {
335
+ record_sets do
338
336
  aws_route53_record_set "some-host" do
339
337
  resource_records ["some-other-host"]
340
338
  end
341
- }
339
+ end
342
340
  end
343
- }.to raise_error(Chef::Exceptions::ValidationFailed, /required/i)
341
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /required/i)
344
342
  end
345
343
  end
346
344
 
347
345
  context "individual RR types" do
348
- let(:expected) {{
349
- cname: {
350
- name: "cname-host.feegle.com.",
351
- type: "CNAME",
352
- ttl: 1800,
353
- resource_records: [{ value: "8.8.8.8" }],
354
- },
355
- a: {
356
- name: "a-host.feegle.com.",
357
- type: "A",
358
- ttl: 1800,
359
- resource_records: [{ value: "141.222.1.1"}, { value: "8.8.8.8" }],
360
- },
361
- aaaa: {
362
- name: "aaaa-host.feegle.com.",
363
- type: "AAAA",
364
- ttl: 1800,
365
- resource_records: [{ value: "2607:f8b0:4010:801::1001"},
366
- { value: "2607:f8b9:4010:801::1001" }],
367
- },
368
- mx: {
369
- name: "mx-host.feegle.com.",
370
- type: "MX",
371
- ttl: 1800,
372
- # AWS does *not* append a dot to these.
373
- resource_records: [{ value: "10 mail1.example.com"}, { value: "15 mail2.example.com."}],
374
- },
375
- txt: {
376
- name: "txt-host.feegle.com.",
377
- type: "TXT",
378
- resource_records: [{ value: '"Very Important Data"' },
379
- { value: '"Even More Important Data"' }],
380
- },
381
- srv: {
382
- name: "srv-host.feegle.com.",
383
- type: "SRV",
384
- resource_records: [{ value: "10 50 8889 chef-server.example.com" },
385
- { value: "20 70 80 narf.net" }],
386
- },
387
- soa: {
388
- name: "feegle.com.",
389
- type: "SOA",
390
- resource_records: [{ value: "ns-1641.awsdns-13.co.uk. awsdns-hostmaster.amazon.com. 2 7200 900 1209600 86400"}],
391
- },
392
- ns: {
393
- name: "feegle.com.",
394
- type: "NS",
395
- resource_records: [{ value: "ns1.amazon.com." },
396
- { value: "ns2.amazon.org." }],
397
- },
398
- }}
346
+ let(:expected) do
347
+ {
348
+ cname: {
349
+ name: "cname-host.feegle.com.",
350
+ type: "CNAME",
351
+ ttl: 1800,
352
+ resource_records: [{ value: "8.8.8.8" }]
353
+ },
354
+ a: {
355
+ name: "a-host.feegle.com.",
356
+ type: "A",
357
+ ttl: 1800,
358
+ resource_records: [{ value: "141.222.1.1" }, { value: "8.8.8.8" }]
359
+ },
360
+ aaaa: {
361
+ name: "aaaa-host.feegle.com.",
362
+ type: "AAAA",
363
+ ttl: 1800,
364
+ resource_records: [{ value: "2607:f8b0:4010:801::1001" },
365
+ { value: "2607:f8b9:4010:801::1001" }]
366
+ },
367
+ mx: {
368
+ name: "mx-host.feegle.com.",
369
+ type: "MX",
370
+ ttl: 1800,
371
+ # AWS does *not* append a dot to these.
372
+ resource_records: [{ value: "10 mail1.example.com" }, { value: "15 mail2.example.com." }]
373
+ },
374
+ txt: {
375
+ name: "txt-host.feegle.com.",
376
+ type: "TXT",
377
+ resource_records: [{ value: '"Very Important Data"' },
378
+ { value: '"Even More Important Data"' }]
379
+ },
380
+ srv: {
381
+ name: "srv-host.feegle.com.",
382
+ type: "SRV",
383
+ resource_records: [{ value: "10 50 8889 chef-server.example.com" },
384
+ { value: "20 70 80 narf.net" }]
385
+ },
386
+ soa: {
387
+ name: "feegle.com.",
388
+ type: "SOA",
389
+ resource_records: [{ value: "ns-1641.awsdns-13.co.uk. awsdns-hostmaster.amazon.com. 2 7200 900 1209600 86400" }]
390
+ },
391
+ ns: {
392
+ name: "feegle.com.",
393
+ type: "NS",
394
+ resource_records: [{ value: "ns1.amazon.com." },
395
+ { value: "ns2.amazon.org." }]
396
+ }
397
+ }
398
+ end
399
399
 
400
400
  it "handles CNAME records" do
401
- expect_recipe {
401
+ expect_recipe do
402
402
  aws_route53_hosted_zone "feegle.com" do
403
- record_sets {
403
+ record_sets do
404
404
  aws_route53_record_set "CNAME-host" do
405
405
  type "CNAME"
406
406
  ttl 1800
407
407
  resource_records ["8.8.8.8"]
408
408
  end
409
- }
409
+ end
410
410
  end
411
- }.to create_an_aws_route53_hosted_zone("feegle.com",
412
- resource_record_sets: [ {}, {}, expected[:cname] ]).and be_idempotent
411
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
412
+ resource_record_sets: [{}, {}, expected[:cname]]).and be_idempotent
413
413
 
414
- expect_converge {
414
+ expect_converge do
415
415
  aws_route53_hosted_zone "feegle.com" do
416
- record_sets {
416
+ record_sets do
417
417
  aws_route53_record_set "CNAME-host" do
418
418
  type "CNAME"
419
419
  ttl 1800
420
420
  resource_records ["141.222.1.1", "8.8.8.8"]
421
421
  end
422
- }
422
+ end
423
423
  end
424
- }.to raise_error(Chef::Exceptions::ValidationFailed, /CNAME records.*have a single value/)
424
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /CNAME records.*have a single value/)
425
425
  end
426
426
 
427
427
  it "handles A records" do
428
- expect_recipe {
428
+ expect_recipe do
429
429
  aws_route53_hosted_zone "feegle.com" do
430
- record_sets {
430
+ record_sets do
431
431
  aws_route53_record_set "A-host" do
432
432
  type "A"
433
433
  ttl 1800
434
434
  resource_records ["141.222.1.1", "8.8.8.8"]
435
435
  end
436
- }
436
+ end
437
437
  end
438
- }.to create_an_aws_route53_hosted_zone("feegle.com",
439
- resource_record_sets: [ {}, {}, expected[:a] ]).and be_idempotent
438
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
439
+ resource_record_sets: [{}, {}, expected[:a]]).and be_idempotent
440
440
 
441
- expect_converge {
441
+ expect_converge do
442
442
  aws_route53_hosted_zone "feegle.com" do
443
- record_sets {
443
+ record_sets do
444
444
  aws_route53_record_set "A-host" do
445
445
  type "A"
446
446
  ttl 1800
447
447
  resource_records ["hostnames-dont-go-here.com", "8.8.8.8"]
448
448
  end
449
- }
449
+ end
450
450
  end
451
- }.to raise_error(Chef::Exceptions::ValidationFailed, /A records are of the form/)
451
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /A records are of the form/)
452
452
  end
453
453
 
454
454
  # we don't validate IPv6 addresses, because they are complex.
455
455
  it "handles AAAA records" do
456
- expect_recipe {
456
+ expect_recipe do
457
457
  aws_route53_hosted_zone "feegle.com" do
458
- record_sets {
458
+ record_sets do
459
459
  aws_route53_record_set "AAAA-host" do
460
460
  type "AAAA"
461
461
  ttl 1800
462
462
  resource_records ["2607:f8b0:4010:801::1001", "2607:f8b9:4010:801::1001"]
463
463
  end
464
- }
464
+ end
465
465
  end
466
- }.to create_an_aws_route53_hosted_zone("feegle.com",
467
- resource_record_sets: [ {}, {}, expected[:aaaa] ]).and be_idempotent
466
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
467
+ resource_record_sets: [{}, {}, expected[:aaaa]]).and be_idempotent
468
468
  end
469
469
 
470
470
  it "handles MX records" do
471
- expect_recipe {
471
+ expect_recipe do
472
472
  aws_route53_hosted_zone "feegle.com" do
473
- record_sets {
473
+ record_sets do
474
474
  aws_route53_record_set "MX-host" do
475
475
  type "MX"
476
476
  ttl 1800
477
477
  resource_records ["10 mail1.example.com", "15 mail2.example.com."]
478
478
  end
479
- }
479
+ end
480
480
  end
481
- }.to create_an_aws_route53_hosted_zone("feegle.com",
482
- resource_record_sets: [ {}, {}, expected[:mx] ]).and be_idempotent
483
- expect_converge {
481
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
482
+ resource_record_sets: [{}, {}, expected[:mx]]).and be_idempotent
483
+ expect_converge do
484
484
  aws_route53_hosted_zone "feegle.com" do
485
- record_sets {
485
+ record_sets do
486
486
  aws_route53_record_set "MX-host" do
487
487
  type "MX"
488
488
  ttl 1800
489
489
  resource_records ["10mail1.example.com", "mail2.example.com."]
490
490
  end
491
- }
491
+ end
492
492
  end
493
- }.to raise_error(Chef::Exceptions::ValidationFailed, /MX records must have a priority and mail server/)
493
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /MX records must have a priority and mail server/)
494
494
  end
495
495
 
496
496
  it "handles SOA records" do
497
- expect_recipe {
497
+ expect_recipe do
498
498
  aws_route53_hosted_zone "feegle.com" do
499
- record_sets {
499
+ record_sets do
500
500
  aws_route53_record_set "SOA-host" do
501
501
  rr_name "feegle.com."
502
502
  type "SOA"
503
503
  ttl 300
504
504
  resource_records ["ns-1641.awsdns-13.co.uk. awsdns-hostmaster.amazon.com. 2 7200 900 1209600 86400"]
505
505
  end
506
- }
506
+ end
507
507
  end
508
- }.to create_an_aws_route53_hosted_zone("feegle.com",
509
- resource_record_sets: [ {}, expected[:soa] ]).and be_idempotent
508
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
509
+ resource_record_sets: [{}, expected[:soa]]).and be_idempotent
510
510
  end
511
511
 
512
512
  it "handles NS records" do
513
- expect_recipe {
513
+ expect_recipe do
514
514
  aws_route53_hosted_zone "feegle.com" do
515
- record_sets {
515
+ record_sets do
516
516
  aws_route53_record_set "NS-host" do
517
517
  rr_name "feegle.com."
518
518
  type "NS"
519
519
  ttl 300
520
- resource_records %w[ns1.amazon.com. ns2.amazon.org.]
520
+ resource_records %w{ns1.amazon.com. ns2.amazon.org.}
521
521
  end
522
- }
522
+ end
523
523
  end
524
- }.to create_an_aws_route53_hosted_zone("feegle.com",
525
- resource_record_sets: [ expected[:ns], {} ]).and be_idempotent
524
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
525
+ resource_record_sets: [expected[:ns], {}]).and be_idempotent
526
526
  end
527
527
 
528
528
  # we don't validate TXT values:
529
529
  # http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html#TXTFormat
530
530
  it "handles TXT records" do
531
- expect_recipe {
531
+ expect_recipe do
532
532
  aws_route53_hosted_zone "feegle.com" do
533
- record_sets {
533
+ record_sets do
534
534
  aws_route53_record_set "TXT-host" do
535
535
  type "TXT"
536
536
  ttl 300
537
- resource_records %w["Very\ Important\ Data" "Even\ More\ Important\ Data"]
537
+ resource_records %w{Very\ Important\ Data Even\ More\ Important\ Data}
538
538
  end
539
- }
539
+ end
540
540
  end
541
- }.to create_an_aws_route53_hosted_zone("feegle.com",
542
- resource_record_sets: [ {}, {}, expected[:txt] ]).and be_idempotent
541
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
542
+ resource_record_sets: [{}, {}, expected[:txt]]).and be_idempotent
543
543
  end
544
544
 
545
545
  it "handles SRV records" do
546
- expect_recipe {
546
+ expect_recipe do
547
547
  aws_route53_hosted_zone "feegle.com" do
548
- record_sets {
548
+ record_sets do
549
549
  aws_route53_record_set "SRV-host" do
550
550
  type "SRV"
551
551
  ttl 300
552
552
  resource_records ["10 50 8889 chef-server.example.com", "20 70 80 narf.net"]
553
553
  end
554
- }
554
+ end
555
555
  end
556
- }.to create_an_aws_route53_hosted_zone("feegle.com",
557
- resource_record_sets: [ {}, {}, expected[:srv] ]).and be_idempotent
556
+ end.to create_an_aws_route53_hosted_zone("feegle.com",
557
+ resource_record_sets: [{}, {}, expected[:srv]]).and be_idempotent
558
558
 
559
- expect_converge {
559
+ expect_converge do
560
560
  aws_route53_hosted_zone "feegle.com" do
561
- record_sets {
561
+ record_sets do
562
562
  aws_route53_record_set "SRV-host" do
563
563
  type "SRV"
564
564
  ttl 300
565
565
  resource_records ["1050 8889 chef-server.example.com", "narf.net"]
566
566
  end
567
- }
567
+ end
568
568
  end
569
- }.to raise_error(Chef::Exceptions::ValidationFailed, /SRV.*priority, weight, port, and hostname/)
569
+ end.to raise_error(Chef::Exceptions::ValidationFailed, /SRV.*priority, weight, port, and hostname/)
570
570
  end
571
- end # end RR types
571
+ end # end RR types
572
572
  end
573
573
  end
574
574
  end