chef-provisioning-aws 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -7,6 +7,8 @@ describe Chef::Resource::MachineImage do
|
|
7
7
|
with_aws "with a VPC and a public subnet" do
|
8
8
|
before :all do
|
9
9
|
chef_config[:log_level] = :warn
|
10
|
+
Chef::Config.chef_provisioning[:machine_max_wait_time] = 240
|
11
|
+
Chef::Config.chef_provisioning[:image_max_wait_time] = 600
|
10
12
|
end
|
11
13
|
|
12
14
|
purge_all
|
@@ -25,28 +27,41 @@ describe Chef::Resource::MachineImage do
|
|
25
27
|
name: 'test_machine_image'
|
26
28
|
).and be_idempotent
|
27
29
|
end
|
28
|
-
end
|
29
|
-
|
30
|
-
with_aws "Without a VPC" do
|
31
|
-
before :all do
|
32
|
-
chef_config[:log_level] = :warn
|
33
|
-
end
|
34
|
-
|
35
|
-
aws_key_pair 'test_key_pair' do
|
36
|
-
allow_overwrite true
|
37
|
-
end
|
38
30
|
|
39
|
-
|
40
|
-
|
31
|
+
describe 'action :destroy', :super_slow do
|
32
|
+
# with_converge does a before(:each)
|
33
|
+
with_converge {
|
41
34
|
machine_image 'test_machine_image' do
|
42
35
|
machine_options bootstrap_options: {
|
36
|
+
subnet_id: 'test_public_subnet',
|
43
37
|
key_name: 'test_key_pair',
|
44
38
|
instance_type: 'm3.medium'
|
45
39
|
}
|
46
40
|
end
|
47
|
-
}
|
48
|
-
|
49
|
-
|
41
|
+
}
|
42
|
+
|
43
|
+
it "destroys the image" do
|
44
|
+
r = recipe {
|
45
|
+
machine_image "test_machine_image" do
|
46
|
+
action :destroy
|
47
|
+
end
|
48
|
+
}
|
49
|
+
expect(r).to destroy_an_aws_image('test_machine_image'
|
50
|
+
).and be_idempotent
|
51
|
+
end
|
52
|
+
|
53
|
+
it "destroys the image if instance is gone long time ago" do
|
54
|
+
image = driver.ec2_resource.images({filters: [ { name: "name", values: ["test_machine_image"] }]}).first
|
55
|
+
image.create_tags(tags: [{key: "from-instance", value: "i-12345678"}])
|
56
|
+
|
57
|
+
r = recipe {
|
58
|
+
machine_image "test_machine_image" do
|
59
|
+
action :destroy
|
60
|
+
end
|
61
|
+
}
|
62
|
+
expect(r).to destroy_an_aws_image('test_machine_image'
|
63
|
+
).and be_idempotent
|
64
|
+
end
|
50
65
|
end
|
51
66
|
|
52
67
|
it "creates aws_image tags", :super_slow do
|
@@ -58,8 +73,8 @@ describe Chef::Resource::MachineImage do
|
|
58
73
|
}
|
59
74
|
aws_tags key1: "value"
|
60
75
|
end
|
61
|
-
}.to create_an_aws_image('test_machine_image'
|
62
|
-
.and have_aws_image_tags('test_machine_image',
|
76
|
+
}.to create_an_aws_image('test_machine_image'
|
77
|
+
).and have_aws_image_tags('test_machine_image',
|
63
78
|
{
|
64
79
|
'key1' => 'value'
|
65
80
|
}
|
@@ -223,37 +223,18 @@ describe Chef::Resource::Machine do
|
|
223
223
|
subnet_id: test_public_subnet.aws_object.id
|
224
224
|
).and be_idempotent
|
225
225
|
end
|
226
|
-
|
226
|
+
end
|
227
227
|
|
228
228
|
context "with a custom iam role" do
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
role_name: "machine_test_custom_role",
|
234
|
-
assume_role_policy_document: assume_role_policy_document
|
235
|
-
}).role
|
236
|
-
driver.iam_client.create_instance_profile({
|
237
|
-
instance_profile_name: "machine_test_custom_role"
|
238
|
-
})
|
239
|
-
driver.iam_client.add_role_to_instance_profile({
|
240
|
-
instance_profile_name: "machine_test_custom_role",
|
241
|
-
role_name: "machine_test_custom_role"
|
242
|
-
})
|
243
|
-
sleep 5 # grrrrrr, the resource should take care of the polling for us
|
229
|
+
assume_role_policy_document = '{"Version":"2008-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":["ec2.amazonaws.com"]},"Action":["sts:AssumeRole"]}]}'
|
230
|
+
aws_iam_role "machine_test_custom_role" do
|
231
|
+
path "/"
|
232
|
+
assume_role_policy_document assume_role_policy_document
|
244
233
|
end
|
245
234
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
role_name: "machine_test_custom_role"
|
250
|
-
})
|
251
|
-
driver.iam_client.delete_instance_profile({
|
252
|
-
instance_profile_name: "machine_test_custom_role"
|
253
|
-
})
|
254
|
-
driver.iam_client.delete_role({
|
255
|
-
role_name: "machine_test_custom_role"
|
256
|
-
})
|
235
|
+
aws_iam_instance_profile "machine_test_instance_profile" do
|
236
|
+
path "/"
|
237
|
+
role "machine_test_custom_role"
|
257
238
|
end
|
258
239
|
|
259
240
|
it "converts iam_instance_profile from a string to a hash", :super_slow do
|
@@ -262,12 +243,12 @@ describe Chef::Resource::Machine do
|
|
262
243
|
machine_options bootstrap_options: {
|
263
244
|
subnet_id: 'test_public_subnet',
|
264
245
|
key_name: 'test_key_pair',
|
265
|
-
iam_instance_profile: "
|
246
|
+
iam_instance_profile: "machine_test_instance_profile"
|
266
247
|
}
|
267
248
|
action :allocate
|
268
249
|
end
|
269
250
|
}.to create_an_aws_instance('test_machine',
|
270
|
-
iam_instance_profile: {arn: /
|
251
|
+
iam_instance_profile: {arn: /machine_test_instance_profile/}
|
271
252
|
).and be_idempotent
|
272
253
|
end
|
273
254
|
end
|
@@ -368,6 +349,7 @@ describe Chef::Resource::Machine do
|
|
368
349
|
key_name: key_pair_name,
|
369
350
|
key_path: private_key_path
|
370
351
|
}
|
352
|
+
action :allocate
|
371
353
|
end
|
372
354
|
}.to create_an_aws_instance('test_machine'
|
373
355
|
).and be_idempotent
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/driver'
|
2
|
+
|
3
|
+
describe Aws::Route53::Types::ResourceRecordSet do
|
4
|
+
it "returns the correct RecordSet unique key"
|
5
|
+
it "returns the correct AWS change struct"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Chef::Resource::AwsRoute53RecordSet do
|
9
|
+
|
10
|
+
let(:resource_name) { "test_resource" }
|
11
|
+
let(:zone_name) { "blerf.net" }
|
12
|
+
let(:resource) {
|
13
|
+
r = Chef::Resource::AwsRoute53RecordSet.new(resource_name)
|
14
|
+
r.aws_route53_zone_name(zone_name)
|
15
|
+
r
|
16
|
+
}
|
17
|
+
|
18
|
+
it "returns the correct RecordSet unique key" do
|
19
|
+
expect(resource.aws_key).to eq("#{resource_name}.#{zone_name}")
|
20
|
+
resource.rr_name("new-name")
|
21
|
+
expect(resource.aws_key).to eq("new-name.#{zone_name}")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the correct AWS change struct" do
|
25
|
+
resource.rr_name("foo")
|
26
|
+
resource.ttl(900)
|
27
|
+
resource.type("A")
|
28
|
+
resource.resource_records(["141.222.1.1", "8.8.8.8"])
|
29
|
+
|
30
|
+
expect(resource.to_aws_struct).to eq({ :name=>"foo.blerf.net",
|
31
|
+
:type=>"A",
|
32
|
+
:ttl=>900,
|
33
|
+
:resource_records=>[{:value=>"141.222.1.1"}, {:value=>"8.8.8.8"}]
|
34
|
+
})
|
35
|
+
end
|
36
|
+
|
37
|
+
context "#validate_rr_type" do
|
38
|
+
it "validates MX values" do
|
39
|
+
correct = 2.times.map { [rand(10000), rand(36**40).to_s(36)].join(" ") }
|
40
|
+
expect(resource.validate_rr_type!("MX", correct)).to be_truthy
|
41
|
+
|
42
|
+
incorrect = ["string content doesn't matter without a number"]
|
43
|
+
expect { resource.validate_rr_type!("MX", incorrect) }.to raise_error(Chef::Exceptions::ValidationFailed,
|
44
|
+
/MX.*priority and mail server/)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "validates SRV values" do
|
48
|
+
correct = 2.times.map { [rand(10000), rand(10000), rand(10000), rand(36**40).to_s(36)].join(" ") }
|
49
|
+
expect(resource.validate_rr_type!("MX", correct)).to be_truthy
|
50
|
+
|
51
|
+
incorrect = ["string content doesn't matter without a number"]
|
52
|
+
expect { resource.validate_rr_type!("SRV", incorrect) }.to raise_error(Chef::Exceptions::ValidationFailed,
|
53
|
+
/SRV.*priority, weight, port, and hostname/)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "validates CNAME values" do
|
57
|
+
correct = ["foo"]
|
58
|
+
expect(resource.validate_rr_type!("CNAME", correct)).to be_truthy
|
59
|
+
|
60
|
+
incorrect = ["foo1", "foo2"]
|
61
|
+
expect { resource.validate_rr_type!("CNAME", incorrect) }.to raise_error(Chef::Exceptions::ValidationFailed,
|
62
|
+
/CNAME records may only have a single value/)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "validates A values" do
|
66
|
+
correct = ["141.222.1.1", "8.8.8.8"]
|
67
|
+
expect(resource.validate_rr_type!("A", correct)).to be_truthy
|
68
|
+
|
69
|
+
incorrect = ["141.222.1.500", "8.8.8.8x"]
|
70
|
+
expect { resource.validate_rr_type!("A", incorrect) }.to raise_error(Chef::Exceptions::ValidationFailed,
|
71
|
+
/A records are of the form/)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "quietly accepts the remaining RR types" do
|
75
|
+
%w(TXT PTR AAAA SPF).each do |type|
|
76
|
+
expect(resource.validate_rr_type!(type, "We're not validating anything on type '#{type}'.")).to be_truthy
|
77
|
+
end
|
78
|
+
|
79
|
+
["SOA", "NS", nil].each do |invalid_type|
|
80
|
+
expect { resource.validate_rr_type!("not a valid RR type", invalid_type) }.to raise_error(ArgumentError)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "#fqdn" do
|
86
|
+
it "generates correct FQDNs" do
|
87
|
+
zone_name = "23skidoo.com"
|
88
|
+
hostname = "fnord"
|
89
|
+
|
90
|
+
resource.aws_route53_zone_name(zone_name)
|
91
|
+
expect(resource.fqdn).to eq("#{resource_name}.#{zone_name}")
|
92
|
+
|
93
|
+
fq_resource = Chef::Resource::AwsRoute53RecordSet.new("#{hostname}.#{zone_name}")
|
94
|
+
fq_resource.aws_route53_zone_name(zone_name)
|
95
|
+
expect(fq_resource.fqdn).to eq("#{hostname}.#{zone_name}")
|
96
|
+
|
97
|
+
fq_resource = Chef::Resource::AwsRoute53RecordSet.new("#{hostname}.#{zone_name}.")
|
98
|
+
fq_resource.aws_route53_zone_name(zone_name)
|
99
|
+
expect(fq_resource.fqdn).to eq("#{hostname}.#{zone_name}.")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe Chef::Provider::AwsRoute53HostedZone do
|
105
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Ewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-provisioning
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: chef
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '12.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '12.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,34 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-byebug
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: pry-stack_explorer
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
153
181
|
description: Provisioner for creating aws containers in Chef Provisioning.
|
154
182
|
email: jewart@getchef.com
|
155
183
|
executables: []
|
@@ -158,6 +186,7 @@ extra_rdoc_files:
|
|
158
186
|
- README.md
|
159
187
|
- LICENSE
|
160
188
|
files:
|
189
|
+
- Gemfile
|
161
190
|
- LICENSE
|
162
191
|
- README.md
|
163
192
|
- Rakefile
|
@@ -169,8 +198,11 @@ files:
|
|
169
198
|
- lib/chef/provider/aws_dhcp_options.rb
|
170
199
|
- lib/chef/provider/aws_ebs_volume.rb
|
171
200
|
- lib/chef/provider/aws_eip_address.rb
|
201
|
+
- lib/chef/provider/aws_iam_instance_profile.rb
|
202
|
+
- lib/chef/provider/aws_iam_role.rb
|
172
203
|
- lib/chef/provider/aws_image.rb
|
173
204
|
- lib/chef/provider/aws_instance.rb
|
205
|
+
- lib/chef/provider/aws_internet_gateway.rb
|
174
206
|
- lib/chef/provider/aws_key_pair.rb
|
175
207
|
- lib/chef/provider/aws_launch_configuration.rb
|
176
208
|
- lib/chef/provider/aws_load_balancer.rb
|
@@ -214,6 +246,8 @@ files:
|
|
214
246
|
- lib/chef/resource/aws_dhcp_options.rb
|
215
247
|
- lib/chef/resource/aws_ebs_volume.rb
|
216
248
|
- lib/chef/resource/aws_eip_address.rb
|
249
|
+
- lib/chef/resource/aws_iam_instance_profile.rb
|
250
|
+
- lib/chef/resource/aws_iam_role.rb
|
217
251
|
- lib/chef/resource/aws_image.rb
|
218
252
|
- lib/chef/resource/aws_instance.rb
|
219
253
|
- lib/chef/resource/aws_internet_gateway.rb
|
@@ -224,6 +258,8 @@ files:
|
|
224
258
|
- lib/chef/resource/aws_network_interface.rb
|
225
259
|
- lib/chef/resource/aws_rds_instance.rb
|
226
260
|
- lib/chef/resource/aws_rds_subnet_group.rb
|
261
|
+
- lib/chef/resource/aws_route53_hosted_zone.rb
|
262
|
+
- lib/chef/resource/aws_route53_record_set.rb
|
227
263
|
- lib/chef/resource/aws_route_table.rb
|
228
264
|
- lib/chef/resource/aws_s3_bucket.rb
|
229
265
|
- lib/chef/resource/aws_security_group.rb
|
@@ -251,11 +287,16 @@ files:
|
|
251
287
|
- spec/integration/aws_cloudsearch_domain_spec.rb
|
252
288
|
- spec/integration/aws_dhcp_options_spec.rb
|
253
289
|
- spec/integration/aws_ebs_volume_spec.rb
|
290
|
+
- spec/integration/aws_eip_address_spec.rb
|
291
|
+
- spec/integration/aws_iam_instance_profile_spec.rb
|
292
|
+
- spec/integration/aws_iam_role_spec.rb
|
293
|
+
- spec/integration/aws_internet_gateway_spec.rb
|
254
294
|
- spec/integration/aws_key_pair_spec.rb
|
255
295
|
- spec/integration/aws_network_acl_spec.rb
|
256
296
|
- spec/integration/aws_network_interface_spec.rb
|
257
297
|
- spec/integration/aws_rds_instance_spec.rb
|
258
298
|
- spec/integration/aws_rds_subnet_group_spec.rb
|
299
|
+
- spec/integration/aws_route53_hosted_zone_spec.rb
|
259
300
|
- spec/integration/aws_route_table_spec.rb
|
260
301
|
- spec/integration/aws_s3_bucket_spec.rb
|
261
302
|
- spec/integration/aws_security_group_spec.rb
|
@@ -270,6 +311,7 @@ files:
|
|
270
311
|
- spec/spec_helper.rb
|
271
312
|
- spec/unit/chef/provisioning/aws_driver/credentials_spec.rb
|
272
313
|
- spec/unit/chef/provisioning/aws_driver/driver_spec.rb
|
314
|
+
- spec/unit/chef/provisioning/aws_driver/route53_spec.rb
|
273
315
|
homepage: https://github.com/opscode/chef-provisioning-aws
|
274
316
|
licenses: []
|
275
317
|
metadata: {}
|