chef-provisioning-aws 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -0
- data/README.md +26 -39
- data/Rakefile +13 -5
- data/lib/chef/provider/aws_iam_instance_profile.rb +60 -0
- data/lib/chef/provider/aws_iam_role.rb +98 -0
- data/lib/chef/provider/aws_image.rb +1 -1
- data/lib/chef/provider/aws_internet_gateway.rb +75 -0
- data/lib/chef/provider/aws_route_table.rb +3 -2
- data/lib/chef/provider/aws_s3_bucket.rb +4 -1
- data/lib/chef/provider/aws_security_group.rb +1 -1
- data/lib/chef/provider/aws_vpc.rb +50 -45
- data/lib/chef/provisioning/aws_driver.rb +22 -1
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +13 -5
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +173 -165
- data/lib/chef/provisioning/aws_driver/credentials.rb +12 -0
- data/lib/chef/provisioning/aws_driver/driver.rb +82 -37
- data/lib/chef/provisioning/aws_driver/super_lwrp.rb +56 -43
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_dhcp_options.rb +1 -1
- data/lib/chef/resource/aws_ebs_volume.rb +1 -1
- data/lib/chef/resource/aws_eip_address.rb +1 -1
- data/lib/chef/resource/aws_iam_instance_profile.rb +33 -0
- data/lib/chef/resource/aws_iam_role.rb +55 -0
- data/lib/chef/resource/aws_image.rb +1 -1
- data/lib/chef/resource/aws_instance.rb +1 -1
- data/lib/chef/resource/aws_internet_gateway.rb +36 -6
- data/lib/chef/resource/aws_load_balancer.rb +1 -1
- data/lib/chef/resource/aws_network_acl.rb +1 -1
- data/lib/chef/resource/aws_network_interface.rb +1 -1
- data/lib/chef/resource/aws_route53_hosted_zone.rb +261 -0
- data/lib/chef/resource/aws_route53_record_set.rb +162 -0
- data/lib/chef/resource/aws_route_table.rb +1 -1
- data/lib/chef/resource/aws_security_group.rb +1 -1
- data/lib/chef/resource/aws_sns_topic.rb +1 -1
- data/lib/chef/resource/aws_subnet.rb +1 -1
- data/lib/chef/resource/aws_vpc.rb +1 -1
- data/lib/chef/resource/aws_vpc_peering_connection.rb +1 -1
- data/spec/aws_support.rb +11 -13
- data/spec/aws_support/matchers/create_an_aws_object.rb +7 -1
- data/spec/aws_support/matchers/have_aws_object_tags.rb +1 -1
- data/spec/aws_support/matchers/match_an_aws_object.rb +7 -1
- data/spec/aws_support/matchers/update_an_aws_object.rb +8 -2
- data/spec/integration/aws_eip_address_spec.rb +74 -0
- data/spec/integration/aws_iam_instance_profile_spec.rb +159 -0
- data/spec/integration/aws_iam_role_spec.rb +177 -0
- data/spec/integration/aws_internet_gateway_spec.rb +161 -0
- data/spec/integration/aws_network_interface_spec.rb +3 -4
- data/spec/integration/aws_route53_hosted_zone_spec.rb +522 -0
- data/spec/integration/aws_route_table_spec.rb +52 -4
- data/spec/integration/aws_s3_bucket_spec.rb +1 -1
- data/spec/integration/load_balancer_spec.rb +303 -8
- data/spec/integration/machine_batch_spec.rb +1 -0
- data/spec/integration/machine_image_spec.rb +32 -17
- data/spec/integration/machine_spec.rb +11 -29
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +0 -1
- data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +105 -0
- metadata +48 -6
@@ -5,10 +5,8 @@ describe Chef::Resource::AwsRouteTable do
|
|
5
5
|
|
6
6
|
when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
|
7
7
|
with_aws "with a VPC with an internet gateway" do
|
8
|
-
|
9
|
-
|
10
|
-
internet_gateway true
|
11
|
-
end
|
8
|
+
purge_all
|
9
|
+
setup_public_vpc
|
12
10
|
|
13
11
|
it "aws_route_table 'test_route_table' with no parameters except VPC creates a route table" do
|
14
12
|
expect_recipe {
|
@@ -84,6 +82,56 @@ describe Chef::Resource::AwsRouteTable do
|
|
84
82
|
).and be_idempotent
|
85
83
|
end
|
86
84
|
|
85
|
+
context "with an existing routing table" do
|
86
|
+
aws_route_table 'test_route_table' do
|
87
|
+
vpc 'test_vpc'
|
88
|
+
routes '0.0.0.0/0' => :internet_gateway
|
89
|
+
end
|
90
|
+
|
91
|
+
it "updates an existing routing table" do
|
92
|
+
expect_recipe {
|
93
|
+
aws_route_table 'test_route_table' do
|
94
|
+
vpc 'test_vpc'
|
95
|
+
routes '0.0.0.0/0' => :internet_gateway,
|
96
|
+
'10.1.0.0/24' => :internet_gateway
|
97
|
+
end
|
98
|
+
}.to update_an_aws_route_table('test_route_table',
|
99
|
+
routes: [
|
100
|
+
{ destination_cidr_block: '10.1.0.0/24', gateway_id: test_vpc.aws_object.internet_gateway.id, state: "active" },
|
101
|
+
{ destination_cidr_block: '10.0.0.0/24', gateway_id: 'local', state: "active" },
|
102
|
+
{ destination_cidr_block: '0.0.0.0/0', gateway_id: test_vpc.aws_object.internet_gateway.id, state: "active" },
|
103
|
+
]
|
104
|
+
).and be_idempotent
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "with machines", :super_slow do
|
109
|
+
machine 'test_machine' do
|
110
|
+
machine_options bootstrap_options: {
|
111
|
+
subnet_id: 'test_public_subnet',
|
112
|
+
key_name: 'test_key_pair'
|
113
|
+
}
|
114
|
+
action :ready # The box has to be online for AWS to accept it as routable
|
115
|
+
end
|
116
|
+
|
117
|
+
it "can route to a machine", :super_slow do
|
118
|
+
expect_recipe {
|
119
|
+
aws_route_table 'test_route_table' do
|
120
|
+
vpc 'test_vpc'
|
121
|
+
routes '0.0.0.0/0' => :internet_gateway,
|
122
|
+
'10.1.0.0/16' => 'test_machine'
|
123
|
+
end
|
124
|
+
|
125
|
+
}.to create_an_aws_route_table('test_route_table',
|
126
|
+
routes: [
|
127
|
+
{ destination_cidr_block: '10.0.0.0/16', gateway_id: 'local', state: "active" },
|
128
|
+
{ destination_cidr_block: '10.1.0.0/16', instance_id: test_machine.aws_object.id, state: "active" },
|
129
|
+
{ destination_cidr_block: '0.0.0.0/0', gateway_id: test_vpc.aws_object.internet_gateway.id, state: "active" },
|
130
|
+
]
|
131
|
+
).and be_idempotent
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
87
135
|
context "with existing tags" do
|
88
136
|
aws_route_table 'test_route_table' do
|
89
137
|
vpc 'test_vpc'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
describe Chef::Resource::LoadBalancer do
|
4
5
|
extend AWSSupport
|
@@ -9,16 +10,39 @@ describe Chef::Resource::LoadBalancer do
|
|
9
10
|
purge_all
|
10
11
|
setup_public_vpc
|
11
12
|
|
13
|
+
bucket_name = "chef.provisioning.test.#{SecureRandom.hex(8)}"
|
14
|
+
aws_s3_bucket bucket_name do
|
15
|
+
options acl: "public-read-write"
|
16
|
+
recursive_delete true
|
17
|
+
end
|
18
|
+
|
19
|
+
cert_string = "-----BEGIN CERTIFICATE-----\nMIIDejCCAmICCQCpupMy/LKfLTANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJV\nUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHU2VhdHRsZTENMAsGA1UE\nChMEQ2hlZjEMMAoGA1UECxMDRGV2MQ4wDAYDVQQDEwVUeWxlcjEcMBoGCSqGSIb3\nDQEJARYNdHlsZXJAY2hlZi5pbzAeFw0xNTA4MDQwMDI1NDFaFw0xNjA4MDMwMDI1\nNDFaMH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQH\nEwdTZWF0dGxlMQ0wCwYDVQQKEwRDaGVmMQwwCgYDVQQLEwNEZXYxDjAMBgNVBAMT\nBVR5bGVyMRwwGgYJKoZIhvcNAQkBFg10eWxlckBjaGVmLmlvMIIBIjANBgkqhkiG\n9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz4gFxNSzwwwYrYTTOCNVQL/agpIXmQKKtkE7\n+Up+waOdSR2iZvgc4fowAqQQ5dtVtur6LEA2LDlLILE+7MhlBxPc3V99lhi5p/Pv\neGCPI7k9sYT0iPJwiqvW+/nCo93QoNpUUDgb6WpT/RENFESn99nTE5NjxNx560aq\nSxAPHTogJEz3wC8c6mQQoANOuXzNb41wvOCUI7Tku76AQ9uECFUjtYpXpx8komaY\nAPtwzr87LGdSysE75roagews2MzAJgGG16oUBsJzT45MlIyQorN3AjoZ3fze6kop\nOhAWeYUM61rwTq7JtLXtBG/9yJzTd/eWU8c4cSK8zePx48X9TQIDAQABMA0GCSqG\nSIb3DQEBBQUAA4IBAQBXJQSpDkjxyljnSWjBur4XikLlFuEpdAdu0MILM3GnS3rT\ntoCVPG2U1d+KkhYG0Y9TBxHpK+3lDGYNyFYJN0STzL4cFzMgQlmZKFhVi/YJWKYO\nj9baIB3dy2k8b2XdDe3WxyycQpHjHhFPqpOTMGNV/1PwJNZGQEjc/svr8EalxvZB\neMb3Kk94K7yohvhT+Ze//rr4ArlM1zvEv3QMwSuyJBA2gtH7FgFKWohZnubW+3uc\n9W/Ux/3O1+BKDWp6zyqn/b2SSF51Jt3tSCF+hIMKYeJnJojY/AF9tQ+DtE8EKYRD\n/qzXX2MQLbhm1AzLt4PN63r96ADYlHhOJGNa9ocS\n-----END CERTIFICATE-----"
|
20
|
+
private_key_string = "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAz4gFxNSzwwwYrYTTOCNVQL/agpIXmQKKtkE7+Up+waOdSR2i\nZvgc4fowAqQQ5dtVtur6LEA2LDlLILE+7MhlBxPc3V99lhi5p/PveGCPI7k9sYT0\niPJwiqvW+/nCo93QoNpUUDgb6WpT/RENFESn99nTE5NjxNx560aqSxAPHTogJEz3\nwC8c6mQQoANOuXzNb41wvOCUI7Tku76AQ9uECFUjtYpXpx8komaYAPtwzr87LGdS\nysE75roagews2MzAJgGG16oUBsJzT45MlIyQorN3AjoZ3fze6kopOhAWeYUM61rw\nTq7JtLXtBG/9yJzTd/eWU8c4cSK8zePx48X9TQIDAQABAoIBAA8teoaHq9Hy+4cN\nNMlhRCXlIhz0hEdLeUuU/8benOCaj7E+OpdfQ/V+763xw86buOwUyVEdLRkU45qz\ne8+jZEgdOsTx6+RjUIio/XWHUlChhpKKD7xIRtTNdn6dKJAFc/GfphTr1Za/kP7s\nFVHLJ6Gny5kd6WkHWt9LHr84oHJZoSjR6YDYdSTL+NtVTwqsKj4EfNY8JAPJI/xI\n9A9t57pvXzwdiya/vXPGytgwkHC/HHWp2sgFvKtJUzuGH0ETDlys9mvXoVQeZ0d9\njhzwIwWAoyvTY9FsUBTCD0aO8r2ylsDVIo2b2cEAZ0Z77OGMUt4sock88sDIICnO\nZVjhV50CgYEA8hKTHpI5ENFvYrTckrc+PnPw7B7xHCCB84ut/CiwzawYRjUx/mtm\nCYYR1xAXdEFrBC21i4Ri8LAIrAQiFGydg2oh4ZQcnEMGKZ0F2VXlsidVNN2tW/50\n8kEaPHPVeP6Trt2kPtpQnhDcuQXbPmOgPBIY2j6nu/Go25e8eICkfhsCgYEA23iy\n8Og1SWZlV5b3ZFyolZiZ9kp0cwyXUGWxUZyw33gBmK6BFkscflI1vfNutxnTDjNl\nALLRoAeIApvXTMFOMUPJsDk90pO7rdlfLznU27lKPyCDkvDGmjCvGGDXrnvi+cc3\ngB3ERfrLJCMoMk9lyg7/KEzzsIjvtTRO79atCLcCgYAGT/+wI2YDj0KVU1wRI2An\nJsTYk3H8Jsjcvf66faEmq98yLX7xQIG3q9xZPF0wNeiBgmOikMA3wI9pVO5ClBaD\nb8gUZtVcKc9GVIbrhPbpb2ckasdzh64rBxGVE/w0HIdjXvpCfVTu2ke3N3ThKp3q\nExq8zjd3ijS6DTnn9orTkwKBgQCxVwpgl4HXWaIx8I7ezfB7UN+3n9oQzO/HyyRI\n6fAR4oqHsRolxXO0rwE2B+pCkd907hqDQfsY8Hz6fqquHtTsAfaLKvXFnhJdG/RJ\n2NUi5soT0FYA+gXAue4CKN6e4wQ5CLzUDTl3wns7LB1i6b06VHvhOK0AzOXE6guO\nyUzwaQKBgDCrGz6IrxEUWl6C14xNNRZBvYTY9oCQpUnup1gMxATJZm4KelKvtKz2\nU1MXpc1i395e+E+tjNAQg0JcBmwkHOMl8c/oAESWPxi11ezalGtUXjIgjBkqqNUE\n/uFqRpNFGwI09JolIqhBTgPWFq6MuuPDJ9IIGJZDQoGEBKmu0k2r\n-----END RSA PRIVATE KEY-----"
|
21
|
+
|
22
|
+
aws_server_certificate "load_balancer_cert" do
|
23
|
+
certificate_body cert_string
|
24
|
+
private_key private_key_string
|
25
|
+
end
|
26
|
+
|
12
27
|
it "creates a load_balancer with the maximum attributes" do
|
13
28
|
expect_recipe {
|
14
29
|
load_balancer 'test-load-balancer' do
|
15
30
|
load_balancer_options({
|
16
|
-
listeners: [
|
31
|
+
listeners: [
|
32
|
+
{
|
17
33
|
:port => 80,
|
18
34
|
:protocol => :http,
|
19
35
|
:instance_port => 80,
|
36
|
+
:instance_protocol => :http
|
37
|
+
},
|
38
|
+
{
|
39
|
+
:port => 443,
|
40
|
+
:protocol => :https,
|
41
|
+
:instance_port => 81,
|
20
42
|
:instance_protocol => :http,
|
21
|
-
|
43
|
+
:ssl_certificate_id => load_balancer_cert.aws_object.arn
|
44
|
+
}
|
45
|
+
],
|
22
46
|
subnets: ["test_public_subnet"],
|
23
47
|
security_groups: ["test_security_group"],
|
24
48
|
health_check: {
|
@@ -27,18 +51,53 @@ describe Chef::Resource::LoadBalancer do
|
|
27
51
|
timeout: 5,
|
28
52
|
unhealthy_threshold: 2,
|
29
53
|
healthy_threshold: 2
|
54
|
+
},
|
55
|
+
scheme: "internal",
|
56
|
+
attributes: {
|
57
|
+
cross_zone_load_balancing: {
|
58
|
+
enabled: true
|
59
|
+
},
|
60
|
+
access_log: {
|
61
|
+
enabled: true,
|
62
|
+
s3_bucket_name: bucket_name,
|
63
|
+
emit_interval: 5,
|
64
|
+
s3_bucket_prefix: "AccessLogPrefix",
|
65
|
+
},
|
66
|
+
connection_draining: {
|
67
|
+
enabled: true,
|
68
|
+
timeout: 1,
|
69
|
+
},
|
70
|
+
connection_settings: {
|
71
|
+
idle_timeout: 1,
|
72
|
+
},
|
73
|
+
# Don't know what can go here
|
74
|
+
# additional_attributes: [
|
75
|
+
# {
|
76
|
+
# key: "StringVal",
|
77
|
+
# value: "StringVal",
|
78
|
+
# },
|
79
|
+
# ]
|
30
80
|
}
|
31
81
|
# 'only 1 of subnets or availability_zones may be specified'
|
32
82
|
# availability_zones: [test_public_subnet.aws_object.availability_zone_name]
|
33
83
|
})
|
34
84
|
end
|
35
85
|
}.to create_an_aws_load_balancer('test-load-balancer', {
|
36
|
-
listeners: [
|
86
|
+
listeners: [
|
87
|
+
{
|
37
88
|
:port => 80,
|
38
89
|
:protocol => :http,
|
39
90
|
:instance_port => 80,
|
40
91
|
:instance_protocol => :http,
|
41
|
-
|
92
|
+
},
|
93
|
+
{
|
94
|
+
:port => 443,
|
95
|
+
:protocol => :https,
|
96
|
+
:instance_port => 81,
|
97
|
+
:instance_protocol => :http,
|
98
|
+
:server_certificate => {arn: load_balancer_cert.aws_object.arn}
|
99
|
+
}
|
100
|
+
],
|
42
101
|
subnets: [test_public_subnet.aws_object],
|
43
102
|
security_groups: [test_security_group.aws_object],
|
44
103
|
health_check: {
|
@@ -47,16 +106,252 @@ describe Chef::Resource::LoadBalancer do
|
|
47
106
|
timeout: 5,
|
48
107
|
unhealthy_threshold: 2,
|
49
108
|
healthy_threshold: 2
|
109
|
+
},
|
110
|
+
scheme: "internal"
|
111
|
+
}).and be_idempotent
|
112
|
+
expect(
|
113
|
+
driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
|
114
|
+
).to eq(load_balancer_attributes: {
|
115
|
+
cross_zone_load_balancing: {enabled: true},
|
116
|
+
access_log: {
|
117
|
+
enabled: true,
|
118
|
+
s3_bucket_name: bucket_name,
|
119
|
+
emit_interval: 5,
|
120
|
+
s3_bucket_prefix: "AccessLogPrefix",
|
121
|
+
},
|
122
|
+
connection_draining: {
|
123
|
+
enabled: true,
|
124
|
+
timeout: 1,
|
125
|
+
},
|
126
|
+
connection_settings: {
|
127
|
+
idle_timeout: 1,
|
50
128
|
}
|
51
|
-
}
|
52
|
-
|
129
|
+
})
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'with an existing load balancer' do
|
133
|
+
aws_security_group 'test_security_group2' do
|
134
|
+
vpc 'test_vpc'
|
135
|
+
inbound_rules '0.0.0.0/0' => [ 22, 80 ]
|
136
|
+
outbound_rules [ 22, 80 ] => '0.0.0.0/0'
|
137
|
+
end
|
138
|
+
|
139
|
+
azs = driver.ec2_client.describe_availability_zones.availability_zones.map {|r| r.zone_name}
|
140
|
+
aws_subnet 'test_public_subnet2' do
|
141
|
+
vpc 'test_vpc'
|
142
|
+
map_public_ip_on_launch true
|
143
|
+
cidr_block '10.0.1.0/24'
|
144
|
+
# This subnet _must_ be in a different availability_zone than the existing one
|
145
|
+
availability_zone azs.last
|
146
|
+
end
|
147
|
+
|
148
|
+
load_balancer 'test-load-balancer' do
|
149
|
+
load_balancer_options({
|
150
|
+
listeners: [{
|
151
|
+
:port => 80,
|
152
|
+
:protocol => :http,
|
153
|
+
:instance_port => 80,
|
154
|
+
:instance_protocol => :http,
|
155
|
+
}],
|
156
|
+
subnets: ["test_public_subnet"],
|
157
|
+
security_groups: ["test_security_group"],
|
158
|
+
health_check: {
|
159
|
+
target: "HTTP:80/",
|
160
|
+
interval: 10,
|
161
|
+
timeout: 5,
|
162
|
+
unhealthy_threshold: 2,
|
163
|
+
healthy_threshold: 2
|
164
|
+
},
|
165
|
+
scheme: "internal",
|
166
|
+
attributes: {
|
167
|
+
cross_zone_load_balancing: {
|
168
|
+
enabled: true
|
169
|
+
},
|
170
|
+
access_log: {
|
171
|
+
enabled: true,
|
172
|
+
s3_bucket_name: bucket_name,
|
173
|
+
emit_interval: 5,
|
174
|
+
s3_bucket_prefix: "AccessLogPrefix",
|
175
|
+
},
|
176
|
+
connection_draining: {
|
177
|
+
enabled: true,
|
178
|
+
timeout: 1,
|
179
|
+
},
|
180
|
+
connection_settings: {
|
181
|
+
idle_timeout: 1,
|
182
|
+
}
|
183
|
+
}
|
184
|
+
})
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'updates all available attributes' do
|
188
|
+
expect_recipe {
|
189
|
+
load_balancer 'test-load-balancer' do
|
190
|
+
load_balancer_options({
|
191
|
+
listeners: [{
|
192
|
+
:port => 443,
|
193
|
+
:protocol => :https,
|
194
|
+
:instance_port => 8080,
|
195
|
+
:instance_protocol => :http,
|
196
|
+
:ssl_certificate_id => load_balancer_cert.aws_object.arn
|
197
|
+
}],
|
198
|
+
subnets: ["test_public_subnet2"],
|
199
|
+
security_groups: ["test_security_group2"],
|
200
|
+
health_check: {
|
201
|
+
target: "HTTP:8080/",
|
202
|
+
interval: 15,
|
203
|
+
timeout: 4,
|
204
|
+
unhealthy_threshold: 3,
|
205
|
+
healthy_threshold: 3
|
206
|
+
},
|
207
|
+
# scheme is immutable, we cannot update it
|
208
|
+
#scheme: "internet-facing",
|
209
|
+
attributes: {
|
210
|
+
cross_zone_load_balancing: {
|
211
|
+
enabled: false
|
212
|
+
},
|
213
|
+
access_log: {
|
214
|
+
enabled: true,
|
215
|
+
s3_bucket_name: bucket_name,
|
216
|
+
emit_interval: 60,
|
217
|
+
s3_bucket_prefix: "AccessLogPrefix2",
|
218
|
+
},
|
219
|
+
connection_draining: {
|
220
|
+
enabled: true,
|
221
|
+
timeout: 10,
|
222
|
+
},
|
223
|
+
connection_settings: {
|
224
|
+
idle_timeout: 10,
|
225
|
+
}
|
226
|
+
}
|
227
|
+
})
|
228
|
+
end
|
229
|
+
}.to update_an_aws_load_balancer('test-load-balancer', {
|
230
|
+
listeners: [{
|
231
|
+
:port => 443,
|
232
|
+
:protocol => :https,
|
233
|
+
:instance_port => 8080,
|
234
|
+
:instance_protocol => :http,
|
235
|
+
:server_certificate => {arn: load_balancer_cert.aws_object.arn}
|
236
|
+
}],
|
237
|
+
subnets: [test_public_subnet2.aws_object],
|
238
|
+
security_groups: [test_security_group2.aws_object],
|
239
|
+
health_check: {
|
240
|
+
target: "HTTP:8080/",
|
241
|
+
interval: 15,
|
242
|
+
timeout: 4,
|
243
|
+
unhealthy_threshold: 3,
|
244
|
+
healthy_threshold: 3
|
245
|
+
},
|
246
|
+
scheme: "internal"
|
247
|
+
}).and be_idempotent
|
248
|
+
expect(
|
249
|
+
driver.elb_client.describe_load_balancer_attributes(load_balancer_name: "test-load-balancer").to_h
|
250
|
+
).to eq(load_balancer_attributes: {
|
251
|
+
cross_zone_load_balancing: {
|
252
|
+
enabled: false
|
253
|
+
},
|
254
|
+
access_log: {
|
255
|
+
enabled: true,
|
256
|
+
s3_bucket_name: bucket_name,
|
257
|
+
emit_interval: 60,
|
258
|
+
s3_bucket_prefix: "AccessLogPrefix2",
|
259
|
+
},
|
260
|
+
connection_draining: {
|
261
|
+
enabled: true,
|
262
|
+
timeout: 10,
|
263
|
+
},
|
264
|
+
connection_settings: {
|
265
|
+
idle_timeout: 10,
|
266
|
+
}
|
267
|
+
})
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'when there are machines', :super_slow do
|
272
|
+
[1, 2].each do |i|
|
273
|
+
machine "test_load_balancer_machine#{i}" do
|
274
|
+
machine_options bootstrap_options: {
|
275
|
+
subnet_id: "test_public_subnet",
|
276
|
+
security_group_ids: ["test_security_group"]
|
277
|
+
}
|
278
|
+
action :allocate
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
it "creates a load_balancer and assigns machine1" do
|
283
|
+
expect_recipe {
|
284
|
+
load_balancer 'test-load-balancer' do
|
285
|
+
load_balancer_options({
|
286
|
+
subnets: ["test_public_subnet"],
|
287
|
+
security_groups: ["test_security_group"]
|
288
|
+
})
|
289
|
+
machines ['test_load_balancer_machine1']
|
290
|
+
end
|
291
|
+
}.to create_an_aws_load_balancer('test-load-balancer',
|
292
|
+
:instances => [{id: test_load_balancer_machine1.aws_object.id}]
|
293
|
+
).and be_idempotent
|
294
|
+
end
|
295
|
+
|
296
|
+
it "can reference machines by name or id" do
|
297
|
+
expect_recipe {
|
298
|
+
load_balancer 'test-load-balancer' do
|
299
|
+
load_balancer_options({
|
300
|
+
subnets: ["test_public_subnet"],
|
301
|
+
security_groups: ["test_security_group"]
|
302
|
+
})
|
303
|
+
machines ['test_load_balancer_machine1', test_load_balancer_machine2.aws_object.id]
|
304
|
+
end
|
305
|
+
}.to create_an_aws_load_balancer('test-load-balancer',
|
306
|
+
:instances => [{id: test_load_balancer_machine1.aws_object.id}, {id: test_load_balancer_machine2.aws_object.id}]
|
307
|
+
).and be_idempotent
|
308
|
+
end
|
309
|
+
|
310
|
+
context "with an existing load_balancer with machine1 attached" do
|
311
|
+
load_balancer 'test-load-balancer' do
|
312
|
+
load_balancer_options({
|
313
|
+
subnets: ["test_public_subnet"],
|
314
|
+
security_groups: ["test_security_group"]
|
315
|
+
})
|
316
|
+
machines ['test_load_balancer_machine1']
|
317
|
+
end
|
318
|
+
|
319
|
+
it "updates the attached machine to machine2" do
|
320
|
+
expect_recipe {
|
321
|
+
load_balancer 'test-load-balancer' do
|
322
|
+
load_balancer_options({
|
323
|
+
subnets: ["test_public_subnet"],
|
324
|
+
security_groups: ["test_security_group"]
|
325
|
+
})
|
326
|
+
machines ['test_load_balancer_machine2']
|
327
|
+
end
|
328
|
+
}.to match_an_aws_load_balancer('test-load-balancer',
|
329
|
+
:instances => [{id: test_load_balancer_machine2.aws_object.id}]
|
330
|
+
).and be_idempotent
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context 'with an existing load_balancer' do
|
336
|
+
load_balancer 'test-load-balancer' do
|
337
|
+
load_balancer_options subnets: ["test_public_subnet"]
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'successfully deletes the load_balancer with the :destroy action' do
|
341
|
+
r = recipe {
|
342
|
+
load_balancer 'test-load-balancer' do
|
343
|
+
action :destroy
|
344
|
+
end
|
345
|
+
}
|
346
|
+
expect(r).to destroy_an_aws_load_balancer('test-load-balancer').and be_idempotent
|
347
|
+
end
|
53
348
|
end
|
54
349
|
|
55
350
|
it "creates load_balancer tags" do
|
56
351
|
expect_recipe {
|
57
352
|
load_balancer 'test-load-balancer' do
|
58
353
|
aws_tags key1: "value"
|
59
|
-
load_balancer_options :
|
354
|
+
load_balancer_options subnets: ["test_public_subnet"]
|
60
355
|
end
|
61
356
|
}.to create_an_aws_load_balancer('test-load-balancer')
|
62
357
|
.and have_aws_load_balancer_tags('test-load-balancer',
|
@@ -69,7 +364,7 @@ describe Chef::Resource::LoadBalancer do
|
|
69
364
|
context "with existing tags" do
|
70
365
|
load_balancer 'test-load-balancer' do
|
71
366
|
aws_tags key1: "value"
|
72
|
-
load_balancer_options :
|
367
|
+
load_balancer_options subnets: ["test_public_subnet"]
|
73
368
|
end
|
74
369
|
|
75
370
|
it "updates aws_load_balancer tags" do
|