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.
- checksums.yaml +4 -4
- data/Gemfile +16 -5
- data/Rakefile +15 -6
- data/chef-provisioning-aws.gemspec +17 -17
- data/lib/chef/provider/aws_auto_scaling_group.rb +5 -6
- data/lib/chef/provider/aws_cache_cluster.rb +21 -15
- data/lib/chef/provider/aws_cache_replication_group.rb +12 -8
- data/lib/chef/provider/aws_cache_subnet_group.rb +3 -3
- data/lib/chef/provider/aws_cloudsearch_domain.rb +9 -13
- data/lib/chef/provider/aws_cloudwatch_alarm.rb +10 -12
- data/lib/chef/provider/aws_dhcp_options.rb +18 -21
- data/lib/chef/provider/aws_ebs_volume.rb +24 -26
- data/lib/chef/provider/aws_eip_address.rb +10 -13
- data/lib/chef/provider/aws_elasticsearch_domain.rb +19 -18
- data/lib/chef/provider/aws_iam_instance_profile.rb +5 -7
- data/lib/chef/provider/aws_iam_role.rb +14 -17
- data/lib/chef/provider/aws_image.rb +6 -6
- data/lib/chef/provider/aws_instance.rb +5 -5
- data/lib/chef/provider/aws_internet_gateway.rb +8 -11
- data/lib/chef/provider/aws_key_pair.rb +15 -17
- data/lib/chef/provider/aws_launch_configuration.rb +11 -14
- data/lib/chef/provider/aws_load_balancer.rb +1 -2
- data/lib/chef/provider/aws_nat_gateway.rb +6 -7
- data/lib/chef/provider/aws_network_acl.rb +28 -29
- data/lib/chef/provider/aws_network_interface.rb +25 -27
- data/lib/chef/provider/aws_rds_instance.rb +12 -13
- data/lib/chef/provider/aws_rds_parameter_group.rb +8 -8
- data/lib/chef/provider/aws_rds_subnet_group.rb +8 -9
- data/lib/chef/provider/aws_route_table.rb +19 -20
- data/lib/chef/provider/aws_s3_bucket.rb +22 -25
- data/lib/chef/provider/aws_security_group.rb +268 -285
- data/lib/chef/provider/aws_server_certificate.rb +6 -5
- data/lib/chef/provider/aws_sns_topic.rb +4 -6
- data/lib/chef/provider/aws_sqs_queue.rb +3 -4
- data/lib/chef/provider/aws_subnet.rb +29 -34
- data/lib/chef/provider/aws_vpc.rb +108 -116
- data/lib/chef/provider/aws_vpc_peering_connection.rb +11 -11
- data/lib/chef/provisioning/aws_driver.rb +4 -2
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +234 -241
- data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +5 -7
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +182 -185
- data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +17 -17
- data/lib/chef/provisioning/aws_driver/aws_taggable.rb +13 -15
- data/lib/chef/provisioning/aws_driver/aws_tagger.rb +47 -48
- data/lib/chef/provisioning/aws_driver/credentials.rb +96 -100
- data/lib/chef/provisioning/aws_driver/credentials2.rb +42 -45
- data/lib/chef/provisioning/aws_driver/driver.rb +1349 -1362
- data/lib/chef/provisioning/aws_driver/exceptions.rb +10 -12
- data/lib/chef/provisioning/aws_driver/super_lwrp.rb +60 -60
- data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +49 -50
- data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +37 -38
- data/lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb +14 -15
- data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +29 -31
- data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +39 -40
- data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -43
- data/lib/chef/provisioning/aws_driver/version.rb +5 -5
- data/lib/chef/provisioning/driver_init/aws.rb +2 -2
- data/lib/chef/resource/aws_auto_scaling_group.rb +1 -1
- data/lib/chef/resource/aws_cache_cluster.rb +9 -12
- data/lib/chef/resource/aws_cache_replication_group.rb +9 -11
- data/lib/chef/resource/aws_cache_subnet_group.rb +8 -10
- data/lib/chef/resource/aws_cloudsearch_domain.rb +4 -5
- data/lib/chef/resource/aws_cloudwatch_alarm.rb +17 -18
- data/lib/chef/resource/aws_dhcp_options.rb +2 -2
- data/lib/chef/resource/aws_ebs_volume.rb +10 -10
- data/lib/chef/resource/aws_eip_address.rb +5 -5
- data/lib/chef/resource/aws_elasticsearch_domain.rb +4 -4
- data/lib/chef/resource/aws_iam_instance_profile.rb +4 -5
- data/lib/chef/resource/aws_iam_role.rb +2 -3
- data/lib/chef/resource/aws_image.rb +3 -3
- data/lib/chef/resource/aws_instance.rb +4 -4
- data/lib/chef/resource/aws_internet_gateway.rb +3 -3
- data/lib/chef/resource/aws_key_pair.rb +7 -7
- data/lib/chef/resource/aws_launch_configuration.rb +4 -4
- data/lib/chef/resource/aws_load_balancer.rb +7 -7
- data/lib/chef/resource/aws_nat_gateway.rb +11 -11
- data/lib/chef/resource/aws_network_acl.rb +7 -8
- data/lib/chef/resource/aws_network_interface.rb +9 -9
- data/lib/chef/resource/aws_rds_instance.rb +4 -4
- data/lib/chef/resource/aws_rds_parameter_group.rb +3 -3
- data/lib/chef/resource/aws_rds_subnet_group.rb +4 -4
- data/lib/chef/resource/aws_route53_hosted_zone.rb +37 -40
- data/lib/chef/resource/aws_route53_record_set.rb +22 -24
- data/lib/chef/resource/aws_route_table.rb +7 -7
- data/lib/chef/resource/aws_s3_bucket.rb +7 -7
- data/lib/chef/resource/aws_security_group.rb +10 -10
- data/lib/chef/resource/aws_server_certificate.rb +6 -8
- data/lib/chef/resource/aws_sns_topic.rb +2 -2
- data/lib/chef/resource/aws_sqs_queue.rb +5 -7
- data/lib/chef/resource/aws_subnet.rb +9 -9
- data/lib/chef/resource/aws_vpc.rb +11 -11
- data/lib/chef/resource/aws_vpc_peering_connection.rb +4 -4
- data/spec/aws_support.rb +44 -45
- data/spec/aws_support/aws_resource_run_wrapper.rb +2 -2
- data/spec/aws_support/deep_matcher.rb +2 -3
- data/spec/aws_support/deep_matcher/fuzzy_match_objects.rb +6 -9
- data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +30 -37
- data/spec/aws_support/deep_matcher/matchable_array.rb +0 -1
- data/spec/aws_support/deep_matcher/matchable_object.rb +1 -2
- data/spec/aws_support/deep_matcher/rspec_monkeypatches.rb +4 -4
- data/spec/aws_support/delayed_stream.rb +2 -2
- data/spec/aws_support/matchers/create_an_aws_object.rb +6 -6
- data/spec/aws_support/matchers/destroy_an_aws_object.rb +6 -6
- data/spec/aws_support/matchers/have_aws_object_tags.rb +4 -5
- data/spec/aws_support/matchers/match_an_aws_object.rb +5 -6
- data/spec/aws_support/matchers/update_an_aws_object.rb +6 -7
- data/spec/integration/aws_auto_scaling_group_spec.rb +56 -64
- data/spec/integration/aws_cache_cluster_spec.rb +70 -71
- data/spec/integration/aws_cache_subnet_group_spec.rb +13 -14
- data/spec/integration/aws_cloudsearch_domain_spec.rb +6 -8
- data/spec/integration/aws_cloudwatch_alarm_spec.rb +200 -208
- data/spec/integration/aws_dhcp_options_spec.rb +32 -43
- data/spec/integration/aws_ebs_volume_spec.rb +52 -73
- data/spec/integration/aws_eip_address_spec.rb +24 -31
- data/spec/integration/aws_elasticsearch_domain_spec.rb +31 -33
- data/spec/integration/aws_iam_instance_profile_spec.rb +36 -45
- data/spec/integration/aws_iam_role_spec.rb +39 -46
- data/spec/integration/aws_internet_gateway_spec.rb +64 -75
- data/spec/integration/aws_key_pair_spec.rb +6 -6
- data/spec/integration/aws_launch_configuration_spec.rb +17 -18
- data/spec/integration/aws_nat_gateway_spec.rb +21 -24
- data/spec/integration/aws_network_acl_spec.rb +81 -95
- data/spec/integration/aws_network_interface_spec.rb +28 -43
- data/spec/integration/aws_rds_instance_spec.rb +29 -40
- data/spec/integration/aws_rds_parameter_group_spec.rb +32 -35
- data/spec/integration/aws_rds_subnet_group_spec.rb +30 -40
- data/spec/integration/aws_route53_hosted_zone_spec.rb +205 -205
- data/spec/integration/aws_route_table_spec.rb +118 -136
- data/spec/integration/aws_s3_bucket_spec.rb +19 -27
- data/spec/integration/aws_security_group_spec.rb +369 -388
- data/spec/integration/aws_server_certificate_spec.rb +16 -18
- data/spec/integration/aws_subnet_spec.rb +44 -58
- data/spec/integration/aws_vpc_peering_connection_spec.rb +43 -50
- data/spec/integration/aws_vpc_spec.rb +99 -115
- data/spec/integration/load_balancer_spec.rb +169 -183
- data/spec/integration/machine_batch_spec.rb +24 -31
- data/spec/integration/machine_image_spec.rb +54 -66
- data/spec/integration/machine_spec.rb +216 -237
- data/spec/persistence_file.txt +219 -0
- data/spec/spec_helper.rb +16 -17
- data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +67 -74
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +29 -29
- data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +13 -15
- metadata +4 -3
@@ -1,12 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "securerandom"
|
3
3
|
|
4
4
|
describe Chef::Resource::LoadBalancer do
|
5
5
|
extend AWSSupport
|
6
6
|
|
7
|
-
when_the_chef_12_server "exists", organization:
|
7
|
+
when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
|
8
8
|
with_aws "with a VPC and a public subnet" do
|
9
|
-
|
10
9
|
purge_all
|
11
10
|
setup_public_vpc
|
12
11
|
|
@@ -30,22 +29,22 @@ describe Chef::Resource::LoadBalancer do
|
|
30
29
|
end
|
31
30
|
|
32
31
|
it "creates a load_balancer with the maximum attributes" do
|
33
|
-
expect_recipe
|
34
|
-
load_balancer
|
35
|
-
load_balancer_options(
|
32
|
+
expect_recipe do
|
33
|
+
load_balancer "test-load-balancer" do
|
34
|
+
load_balancer_options(
|
36
35
|
listeners: [
|
37
36
|
{
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
37
|
+
port: 80,
|
38
|
+
protocol: :http,
|
39
|
+
instance_port: 80,
|
40
|
+
instance_protocol: :http
|
42
41
|
},
|
43
42
|
{
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
43
|
+
port: 443,
|
44
|
+
protocol: :https,
|
45
|
+
instance_port: 81,
|
46
|
+
instance_protocol: :http,
|
47
|
+
ssl_certificate_id: load_balancer_cert.aws_object.server_certificate_metadata.arn
|
49
48
|
}
|
50
49
|
],
|
51
50
|
subnets: ["test_public_subnet"],
|
@@ -58,7 +57,7 @@ describe Chef::Resource::LoadBalancer do
|
|
58
57
|
healthy_threshold: 2
|
59
58
|
},
|
60
59
|
sticky_sessions: {
|
61
|
-
cookie_name:
|
60
|
+
cookie_name: "test-cookie-name",
|
62
61
|
ports: [80, 443]
|
63
62
|
},
|
64
63
|
scheme: "internal",
|
@@ -70,14 +69,14 @@ describe Chef::Resource::LoadBalancer do
|
|
70
69
|
enabled: true,
|
71
70
|
s3_bucket_name: bucket_name,
|
72
71
|
emit_interval: 5,
|
73
|
-
s3_bucket_prefix: "AccessLogPrefix"
|
72
|
+
s3_bucket_prefix: "AccessLogPrefix"
|
74
73
|
},
|
75
74
|
connection_draining: {
|
76
75
|
enabled: true,
|
77
|
-
timeout: 1
|
76
|
+
timeout: 1
|
78
77
|
},
|
79
78
|
connection_settings: {
|
80
|
-
idle_timeout: 1
|
79
|
+
idle_timeout: 1
|
81
80
|
},
|
82
81
|
# Don't know what can go here
|
83
82
|
# additional_attributes: [
|
@@ -89,79 +88,76 @@ describe Chef::Resource::LoadBalancer do
|
|
89
88
|
}
|
90
89
|
# 'only 1 of subnets or availability_zones may be specified'
|
91
90
|
# availability_zones: [test_public_subnet.aws_object.availability_zone_name]
|
92
|
-
|
91
|
+
)
|
93
92
|
end
|
94
|
-
|
95
|
-
|
96
|
-
).and be_idempotent
|
93
|
+
end.to create_an_aws_load_balancer("test-load-balancer",
|
94
|
+
driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0]).and be_idempotent
|
97
95
|
expect(
|
98
96
|
driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
|
99
97
|
).to eq(load_balancer_attributes: {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
stickiness_policy = driver.elb_client.describe_load_balancer_policies(load_balancer_name:
|
98
|
+
cross_zone_load_balancing: { enabled: true },
|
99
|
+
access_log: {
|
100
|
+
enabled: true,
|
101
|
+
s3_bucket_name: bucket_name,
|
102
|
+
emit_interval: 5,
|
103
|
+
s3_bucket_prefix: "AccessLogPrefix"
|
104
|
+
},
|
105
|
+
connection_draining: {
|
106
|
+
enabled: true,
|
107
|
+
timeout: 1
|
108
|
+
},
|
109
|
+
connection_settings: {
|
110
|
+
idle_timeout: 1
|
111
|
+
}
|
112
|
+
})
|
113
|
+
stickiness_policy = driver.elb_client.describe_load_balancer_policies(load_balancer_name: "test-load-balancer")[:policy_descriptions].detect { |pd| pd[:policy_type_name] == "AppCookieStickinessPolicyType" }.to_h
|
116
114
|
expect(stickiness_policy).to eq(
|
117
|
-
|
118
|
-
|
119
|
-
{attribute_value: "test-cookie-name", attribute_name: "CookieName"}
|
115
|
+
policy_attribute_descriptions: [
|
116
|
+
{ attribute_value: "test-cookie-name", attribute_name: "CookieName" }
|
120
117
|
],
|
121
|
-
|
122
|
-
|
123
|
-
}
|
118
|
+
policy_type_name: "AppCookieStickinessPolicyType",
|
119
|
+
policy_name: "test-load-balancer-sticky-session-policy"
|
124
120
|
)
|
125
121
|
|
126
|
-
listener_descriptions = driver.elb_client.describe_load_balancers(load_balancer_names: [
|
122
|
+
listener_descriptions = driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[:load_balancer_descriptions][0][:listener_descriptions]
|
127
123
|
expect(listener_descriptions.size).to eql(2)
|
128
124
|
http_listener = listener_descriptions.detect { |ld| ld[:listener][:load_balancer_port] == 80 }
|
129
125
|
https_listener = listener_descriptions.detect { |ld| ld[:listener][:load_balancer_port] == 443 }
|
130
|
-
expect(http_listener[:policy_names]).to include(
|
131
|
-
expect(https_listener[:policy_names]).to include(
|
126
|
+
expect(http_listener[:policy_names]).to include("test-load-balancer-sticky-session-policy")
|
127
|
+
expect(https_listener[:policy_names]).to include("test-load-balancer-sticky-session-policy")
|
132
128
|
end
|
133
129
|
|
134
|
-
context
|
135
|
-
aws_security_group
|
136
|
-
vpc
|
137
|
-
inbound_rules
|
138
|
-
outbound_rules [
|
130
|
+
context "with an existing load balancer" do
|
131
|
+
aws_security_group "test_security_group2" do
|
132
|
+
vpc "test_vpc"
|
133
|
+
inbound_rules "0.0.0.0/0" => [22, 80]
|
134
|
+
outbound_rules [22, 80] => "0.0.0.0/0"
|
139
135
|
end
|
140
136
|
|
141
|
-
azs = driver.ec2_client.describe_availability_zones.availability_zones.map
|
142
|
-
aws_subnet
|
143
|
-
vpc
|
137
|
+
azs = driver.ec2_client.describe_availability_zones.availability_zones.map(&:zone_name)
|
138
|
+
aws_subnet "test_public_subnet2" do
|
139
|
+
vpc "test_vpc"
|
144
140
|
map_public_ip_on_launch true
|
145
|
-
cidr_block
|
141
|
+
cidr_block "10.0.1.0/24"
|
146
142
|
# This subnet _must_ be in a different availability_zone than the existing one
|
147
143
|
availability_zone azs.last
|
148
144
|
end
|
149
145
|
|
150
|
-
load_balancer
|
151
|
-
load_balancer_options(
|
146
|
+
load_balancer "test-load-balancer" do
|
147
|
+
load_balancer_options(
|
152
148
|
listeners: [{
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
port: 80,
|
150
|
+
protocol: :http,
|
151
|
+
instance_port: 80,
|
152
|
+
instance_protocol: :http
|
157
153
|
},
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
154
|
+
{
|
155
|
+
port: 8443,
|
156
|
+
protocol: :https,
|
157
|
+
instance_port: 80,
|
158
|
+
instance_protocol: :http,
|
159
|
+
ssl_certificate_id: load_balancer_cert.aws_object.server_certificate_metadata.arn
|
160
|
+
}],
|
165
161
|
subnets: ["test_public_subnet"],
|
166
162
|
security_groups: ["test_security_group"],
|
167
163
|
health_check: {
|
@@ -172,7 +168,7 @@ describe Chef::Resource::LoadBalancer do
|
|
172
168
|
healthy_threshold: 2
|
173
169
|
},
|
174
170
|
sticky_sessions: {
|
175
|
-
cookie_name:
|
171
|
+
cookie_name: "test-cookie-name",
|
176
172
|
ports: [80]
|
177
173
|
},
|
178
174
|
scheme: "internal",
|
@@ -184,37 +180,37 @@ describe Chef::Resource::LoadBalancer do
|
|
184
180
|
enabled: true,
|
185
181
|
s3_bucket_name: bucket_name,
|
186
182
|
emit_interval: 5,
|
187
|
-
s3_bucket_prefix: "AccessLogPrefix"
|
183
|
+
s3_bucket_prefix: "AccessLogPrefix"
|
188
184
|
},
|
189
185
|
connection_draining: {
|
190
186
|
enabled: true,
|
191
|
-
timeout: 1
|
187
|
+
timeout: 1
|
192
188
|
},
|
193
189
|
connection_settings: {
|
194
|
-
idle_timeout: 1
|
190
|
+
idle_timeout: 1
|
195
191
|
}
|
196
192
|
}
|
197
|
-
|
193
|
+
)
|
198
194
|
end
|
199
195
|
|
200
|
-
it
|
201
|
-
expect_recipe
|
202
|
-
load_balancer
|
203
|
-
load_balancer_options(
|
196
|
+
it "updates all available attributes" do
|
197
|
+
expect_recipe do
|
198
|
+
load_balancer "test-load-balancer" do
|
199
|
+
load_balancer_options(
|
204
200
|
listeners: [{
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
201
|
+
port: 443,
|
202
|
+
protocol: :https,
|
203
|
+
instance_port: 8080,
|
204
|
+
instance_protocol: :http,
|
205
|
+
ssl_certificate_id: load_balancer_cert.aws_object.server_certificate_metadata.arn
|
210
206
|
},
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
207
|
+
{
|
208
|
+
port: 8443,
|
209
|
+
protocol: :https,
|
210
|
+
instance_port: 80,
|
211
|
+
instance_protocol: :http,
|
212
|
+
ssl_certificate_id: load_balancer_cert_2.aws_object.server_certificate_metadata.arn
|
213
|
+
}],
|
218
214
|
subnets: ["test_public_subnet2"],
|
219
215
|
security_groups: ["test_security_group2"],
|
220
216
|
health_check: {
|
@@ -225,11 +221,11 @@ describe Chef::Resource::LoadBalancer do
|
|
225
221
|
healthy_threshold: 3
|
226
222
|
},
|
227
223
|
sticky_sessions: {
|
228
|
-
cookie_name:
|
224
|
+
cookie_name: "test-cookie-name2",
|
229
225
|
ports: [443]
|
230
226
|
},
|
231
227
|
# scheme is immutable, we cannot update it
|
232
|
-
#scheme: "internet-facing",
|
228
|
+
# scheme: "internet-facing",
|
233
229
|
attributes: {
|
234
230
|
cross_zone_load_balancing: {
|
235
231
|
enabled: false
|
@@ -238,60 +234,58 @@ describe Chef::Resource::LoadBalancer do
|
|
238
234
|
enabled: true,
|
239
235
|
s3_bucket_name: bucket_name,
|
240
236
|
emit_interval: 60,
|
241
|
-
s3_bucket_prefix: "AccessLogPrefix2"
|
237
|
+
s3_bucket_prefix: "AccessLogPrefix2"
|
242
238
|
},
|
243
239
|
connection_draining: {
|
244
240
|
enabled: true,
|
245
|
-
timeout: 10
|
241
|
+
timeout: 10
|
246
242
|
},
|
247
243
|
connection_settings: {
|
248
|
-
idle_timeout: 10
|
244
|
+
idle_timeout: 10
|
249
245
|
}
|
250
246
|
}
|
251
|
-
|
247
|
+
)
|
252
248
|
end
|
253
|
-
|
249
|
+
end.to update_an_aws_load_balancer("test-load-balancer", driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0]).and be_idempotent
|
254
250
|
|
255
251
|
expect(
|
256
252
|
driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
|
257
253
|
).to eq(load_balancer_attributes: {
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
254
|
+
cross_zone_load_balancing: {
|
255
|
+
enabled: false
|
256
|
+
},
|
257
|
+
access_log: {
|
258
|
+
enabled: true,
|
259
|
+
s3_bucket_name: bucket_name,
|
260
|
+
emit_interval: 60,
|
261
|
+
s3_bucket_prefix: "AccessLogPrefix2"
|
262
|
+
},
|
263
|
+
connection_draining: {
|
264
|
+
enabled: true,
|
265
|
+
timeout: 10
|
266
|
+
},
|
267
|
+
connection_settings: {
|
268
|
+
idle_timeout: 10
|
269
|
+
}
|
270
|
+
})
|
275
271
|
|
276
|
-
stickiness_policy = driver.elb_client.describe_load_balancer_policies(load_balancer_name:
|
272
|
+
stickiness_policy = driver.elb_client.describe_load_balancer_policies(load_balancer_name: "test-load-balancer")[:policy_descriptions].detect { |pd| pd[:policy_type_name] == "AppCookieStickinessPolicyType" }.to_h
|
277
273
|
expect(stickiness_policy).to eq(
|
278
|
-
|
279
|
-
|
280
|
-
{attribute_value: "test-cookie-name2", attribute_name: "CookieName"}
|
274
|
+
policy_attribute_descriptions: [
|
275
|
+
{ attribute_value: "test-cookie-name2", attribute_name: "CookieName" }
|
281
276
|
],
|
282
|
-
|
283
|
-
|
284
|
-
}
|
277
|
+
policy_type_name: "AppCookieStickinessPolicyType",
|
278
|
+
policy_name: "test-load-balancer-sticky-session-policy"
|
285
279
|
)
|
286
280
|
|
287
|
-
listener_descriptions = driver.elb_client.describe_load_balancers(load_balancer_names: [
|
281
|
+
listener_descriptions = driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[:load_balancer_descriptions][0][:listener_descriptions]
|
288
282
|
expect(listener_descriptions.size).to eql(2)
|
289
283
|
https_listener = listener_descriptions.detect { |ld| ld[:listener][:load_balancer_port] == 443 }
|
290
|
-
expect(https_listener[:policy_names]).to include(
|
284
|
+
expect(https_listener[:policy_names]).to include("test-load-balancer-sticky-session-policy")
|
291
285
|
end
|
292
286
|
end
|
293
287
|
|
294
|
-
context
|
288
|
+
context "when there are machines", :super_slow do
|
295
289
|
[1, 2].each do |i|
|
296
290
|
machine "test_load_balancer_machine#{i}" do
|
297
291
|
machine_options bootstrap_options: {
|
@@ -303,121 +297,113 @@ describe Chef::Resource::LoadBalancer do
|
|
303
297
|
end
|
304
298
|
|
305
299
|
it "creates a load_balancer and assigns machine1" do
|
306
|
-
expect_recipe
|
307
|
-
load_balancer
|
308
|
-
load_balancer_options(
|
300
|
+
expect_recipe do
|
301
|
+
load_balancer "test-load-balancer" do
|
302
|
+
load_balancer_options(
|
309
303
|
subnets: ["test_public_subnet"],
|
310
304
|
security_groups: ["test_security_group"]
|
311
|
-
|
312
|
-
machines [
|
305
|
+
)
|
306
|
+
machines ["test_load_balancer_machine1"]
|
313
307
|
end
|
314
|
-
|
315
|
-
ids = aws_object.instances.map
|
308
|
+
end.to create_an_aws_load_balancer("test-load-balancer") { |aws_object|
|
309
|
+
ids = aws_object.instances.map(&:instance_id)
|
316
310
|
expect([test_load_balancer_machine1.aws_object.id]).to eq(ids)
|
317
311
|
}.and be_idempotent
|
318
312
|
end
|
319
313
|
|
320
314
|
it "can reference machines by name or id" do
|
321
|
-
expect_recipe
|
322
|
-
load_balancer
|
323
|
-
load_balancer_options(
|
315
|
+
expect_recipe do
|
316
|
+
load_balancer "test-load-balancer" do
|
317
|
+
load_balancer_options(
|
324
318
|
subnets: ["test_public_subnet"],
|
325
319
|
security_groups: ["test_security_group"]
|
326
|
-
|
327
|
-
machines [
|
320
|
+
)
|
321
|
+
machines ["test_load_balancer_machine1", test_load_balancer_machine2.aws_object.id]
|
328
322
|
end
|
329
|
-
|
330
|
-
ids = aws_object.instances.map
|
323
|
+
end.to create_an_aws_load_balancer("test-load-balancer") { |aws_object|
|
324
|
+
ids = aws_object.instances.map(&:instance_id)
|
331
325
|
expect(ids.to_set).to eq([test_load_balancer_machine1.aws_object.id, test_load_balancer_machine2.aws_object.id].to_set)
|
332
326
|
}.and be_idempotent
|
333
327
|
end
|
334
328
|
|
335
329
|
context "with an existing load_balancer with machine1 attached" do
|
336
|
-
load_balancer
|
337
|
-
load_balancer_options(
|
330
|
+
load_balancer "test-load-balancer" do
|
331
|
+
load_balancer_options(
|
338
332
|
subnets: ["test_public_subnet"],
|
339
333
|
security_groups: ["test_security_group"]
|
340
|
-
|
341
|
-
machines [
|
334
|
+
)
|
335
|
+
machines ["test_load_balancer_machine1"]
|
342
336
|
end
|
343
337
|
|
344
338
|
it "updates the attached machine to machine2" do
|
345
|
-
expect_recipe
|
346
|
-
load_balancer
|
347
|
-
load_balancer_options(
|
339
|
+
expect_recipe do
|
340
|
+
load_balancer "test-load-balancer" do
|
341
|
+
load_balancer_options(
|
348
342
|
subnets: ["test_public_subnet"],
|
349
343
|
security_groups: ["test_security_group"]
|
350
|
-
|
351
|
-
machines [
|
344
|
+
)
|
345
|
+
machines ["test_load_balancer_machine2"]
|
352
346
|
end
|
353
|
-
|
354
|
-
ids = aws_object.instances.map
|
347
|
+
end.to match_an_aws_load_balancer("test-load-balancer") { |aws_object|
|
348
|
+
ids = aws_object.instances.map(&:instance_id)
|
355
349
|
expect([test_load_balancer_machine2.aws_object.id]).to eq(ids)
|
356
350
|
}.and be_idempotent
|
357
351
|
end
|
358
352
|
end
|
359
353
|
end
|
360
354
|
|
361
|
-
context
|
362
|
-
load_balancer
|
355
|
+
context "with an existing load_balancer" do
|
356
|
+
load_balancer "test-load-balancer" do
|
363
357
|
load_balancer_options subnets: ["test_public_subnet"]
|
364
358
|
end
|
365
359
|
|
366
|
-
it
|
367
|
-
r = recipe
|
368
|
-
load_balancer
|
360
|
+
it "successfully deletes the load_balancer with the :destroy action" do
|
361
|
+
r = recipe do
|
362
|
+
load_balancer "test-load-balancer" do
|
369
363
|
action :destroy
|
370
364
|
end
|
371
|
-
|
372
|
-
expect(r).to destroy_an_aws_load_balancer(
|
365
|
+
end
|
366
|
+
expect(r).to destroy_an_aws_load_balancer("test-load-balancer").and be_idempotent
|
373
367
|
end
|
374
368
|
end
|
375
369
|
|
376
370
|
it "creates load_balancer tags" do
|
377
|
-
expect_recipe
|
378
|
-
load_balancer
|
371
|
+
expect_recipe do
|
372
|
+
load_balancer "test-load-balancer" do
|
379
373
|
aws_tags key1: "value"
|
380
374
|
load_balancer_options subnets: ["test_public_subnet"]
|
381
375
|
end
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
'key1' => 'value'
|
387
|
-
}
|
388
|
-
).and be_idempotent
|
376
|
+
end.to create_an_aws_load_balancer("test-load-balancer",
|
377
|
+
driver.elb_client.describe_load_balancers(load_balancer_names: ["test-load-balancer"])[0][0])
|
378
|
+
.and have_aws_load_balancer_tags("test-load-balancer",
|
379
|
+
"key1" => "value").and be_idempotent
|
389
380
|
end
|
390
381
|
|
391
382
|
context "with existing tags" do
|
392
|
-
load_balancer
|
383
|
+
load_balancer "test-load-balancer" do
|
393
384
|
aws_tags key1: "value"
|
394
385
|
load_balancer_options subnets: ["test_public_subnet"]
|
395
386
|
end
|
396
387
|
|
397
388
|
it "updates aws_load_balancer tags" do
|
398
|
-
expect_recipe
|
399
|
-
load_balancer
|
389
|
+
expect_recipe do
|
390
|
+
load_balancer "test-load-balancer" do
|
400
391
|
aws_tags key1: "value2", key2: nil
|
401
392
|
end
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
'key2' => ''
|
406
|
-
}
|
407
|
-
).and be_idempotent
|
393
|
+
end.to have_aws_load_balancer_tags("test-load-balancer",
|
394
|
+
"key1" => "value2",
|
395
|
+
"key2" => "").and be_idempotent
|
408
396
|
end
|
409
397
|
|
410
398
|
it "removes all aws_load_balancer tags" do
|
411
|
-
expect_recipe
|
412
|
-
load_balancer
|
413
|
-
aws_tags
|
399
|
+
expect_recipe do
|
400
|
+
load_balancer "test-load-balancer" do
|
401
|
+
aws_tags({})
|
414
402
|
end
|
415
|
-
|
416
|
-
|
417
|
-
).and be_idempotent
|
403
|
+
end.to have_aws_load_balancer_tags("test-load-balancer",
|
404
|
+
{}).and be_idempotent
|
418
405
|
end
|
419
406
|
end
|
420
|
-
|
421
407
|
end
|
422
408
|
end
|
423
409
|
end
|