chef-provisioning-aws 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/chef/provider/aws_auto_scaling_group.rb +15 -1
- data/lib/chef/provider/aws_cloudwatch_alarm.rb +84 -0
- data/lib/chef/provider/aws_ebs_volume.rb +1 -1
- data/lib/chef/provider/aws_image.rb +13 -5
- data/lib/chef/provider/aws_launch_configuration.rb +4 -4
- data/lib/chef/provider/aws_nat_gateway.rb +57 -0
- data/lib/chef/provider/aws_network_interface.rb +1 -1
- data/lib/chef/provider/aws_route_table.rb +7 -3
- data/lib/chef/provider/aws_vpc.rb +20 -0
- data/lib/chef/provisioning/aws_driver.rb +2 -0
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +1 -1
- data/lib/chef/provisioning/aws_driver/driver.rb +10 -5
- data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +76 -0
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_auto_scaling_group.rb +12 -8
- data/lib/chef/resource/aws_cloudwatch_alarm.rb +35 -0
- data/lib/chef/resource/aws_image.rb +4 -4
- data/lib/chef/resource/aws_launch_configuration.rb +1 -1
- data/lib/chef/resource/aws_nat_gateway.rb +98 -0
- data/lib/chef/resource/aws_route_table.rb +1 -0
- data/spec/aws_support.rb +1 -1
- data/spec/integration/aws_auto_scaling_group_spec.rb +118 -0
- data/spec/integration/aws_cloudwatch_alarm_spec.rb +286 -0
- data/spec/integration/aws_nat_gateway_spec.rb +52 -0
- data/spec/integration/aws_rds_instance_spec.rb +10 -10
- data/spec/integration/aws_route_table_spec.rb +22 -0
- data/spec/integration/aws_vpc_spec.rb +31 -3
- data/spec/spec_helper.rb +4 -2
- metadata +11 -3
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'chef/resource/aws_nat_gateway'
|
3
|
+
|
4
|
+
describe Chef::Resource::AwsNatGateway do
|
5
|
+
extend AWSSupport
|
6
|
+
|
7
|
+
when_the_chef_12_server 'exists', organization: 'foo', server_scope: :context do
|
8
|
+
with_aws 'with a VPC' do
|
9
|
+
purge_all
|
10
|
+
setup_public_vpc
|
11
|
+
|
12
|
+
aws_network_interface 'test_network_interface' do
|
13
|
+
subnet 'test_public_subnet'
|
14
|
+
end
|
15
|
+
|
16
|
+
aws_eip_address 'test_eip'
|
17
|
+
|
18
|
+
describe 'action :create' do #, :super_slow do
|
19
|
+
it 'creates an aws_nat_gateway in the specified subnet' do
|
20
|
+
expect_recipe {
|
21
|
+
aws_nat_gateway 'test_nat_gateway' do
|
22
|
+
subnet 'test_public_subnet'
|
23
|
+
eip_address 'test_eip'
|
24
|
+
end
|
25
|
+
}.to create_an_aws_nat_gateway('test_nat_gateway',
|
26
|
+
subnet_id: test_public_subnet.aws_object.id
|
27
|
+
).and be_idempotent
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'action :delete' do
|
32
|
+
context 'when there is a nat_gateway' do
|
33
|
+
aws_nat_gateway 'test_nat_gateway' do
|
34
|
+
subnet 'test_public_subnet'
|
35
|
+
eip_address 'test_eip'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'deletes the nat gateway and does not delete the eip address' do
|
39
|
+
r = recipe {
|
40
|
+
aws_nat_gateway 'test_nat_gateway' do
|
41
|
+
action :destroy
|
42
|
+
end
|
43
|
+
}
|
44
|
+
expect(r).to destroy_an_aws_nat_gateway('test_nat_gateway'
|
45
|
+
).and match_an_aws_eip_address('test_eip'
|
46
|
+
).and be_idempotent
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -36,17 +36,17 @@ describe Chef::Resource::AwsRdsInstance do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
aws_rds_parameter_group "test-db-parameter-group" do
|
39
|
-
db_parameter_group_family "postgres9.
|
39
|
+
db_parameter_group_family "postgres9.5"
|
40
40
|
description "testing provisioning"
|
41
41
|
parameters [{:parameter_name => "max_connections", :parameter_value => "250", :apply_method => "pending-reboot"}]
|
42
42
|
end
|
43
43
|
|
44
|
-
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
|
+
it "aws_rds_instance 'test-rds-instance' creates an rds instance that can parse the aws_rds_subnet_group and aws_rds_parameter_group", :focus do
|
45
45
|
expect_recipe {
|
46
46
|
aws_rds_instance "test-rds-instance" do
|
47
47
|
engine "postgres"
|
48
48
|
publicly_accessible false
|
49
|
-
db_instance_class "db.
|
49
|
+
db_instance_class "db.t2.micro"
|
50
50
|
master_username "thechief"
|
51
51
|
master_user_password "securesecure" # 2x security
|
52
52
|
multi_az false
|
@@ -57,7 +57,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
57
57
|
}.to create_an_aws_rds_instance('test-rds-instance',
|
58
58
|
engine: 'postgres',
|
59
59
|
multi_az: false,
|
60
|
-
db_instance_class: "db.
|
60
|
+
db_instance_class: "db.t2.micro",
|
61
61
|
master_username: "thechief",
|
62
62
|
).and be_idempotent
|
63
63
|
r = driver.rds_resource.db_instance("test-rds-instance")
|
@@ -71,7 +71,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
71
71
|
aws_rds_instance "test-rds-instance2" do
|
72
72
|
engine "postgres"
|
73
73
|
publicly_accessible false
|
74
|
-
db_instance_class "db.
|
74
|
+
db_instance_class "db.t2.micro"
|
75
75
|
master_username "thechief"
|
76
76
|
master_user_password "securesecure"
|
77
77
|
multi_az false
|
@@ -81,7 +81,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
81
81
|
}.to create_an_aws_rds_instance('test-rds-instance2',
|
82
82
|
engine: 'postgres',
|
83
83
|
multi_az: false,
|
84
|
-
db_instance_class: "db.
|
84
|
+
db_instance_class: "db.t2.micro",
|
85
85
|
master_username: "thechief",
|
86
86
|
backup_retention_period: 2)
|
87
87
|
|
@@ -94,7 +94,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
94
94
|
aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
|
95
95
|
aws_tags key1: "value"
|
96
96
|
allocated_storage 5
|
97
|
-
db_instance_class "db.
|
97
|
+
db_instance_class "db.t2.micro"
|
98
98
|
engine "postgres"
|
99
99
|
master_username "thechief"
|
100
100
|
master_user_password "securesecure"
|
@@ -114,7 +114,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
114
114
|
aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
|
115
115
|
aws_tags key1: "value"
|
116
116
|
allocated_storage 5
|
117
|
-
db_instance_class "db.
|
117
|
+
db_instance_class "db.t2.micro"
|
118
118
|
engine "postgres"
|
119
119
|
master_username "thechief"
|
120
120
|
master_user_password "securesecure"
|
@@ -125,7 +125,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
125
125
|
aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
|
126
126
|
aws_tags key1: "value2", key2: nil
|
127
127
|
allocated_storage 5
|
128
|
-
db_instance_class "db.
|
128
|
+
db_instance_class "db.t2.micro"
|
129
129
|
engine "postgres"
|
130
130
|
master_username "thechief"
|
131
131
|
master_user_password "securesecure"
|
@@ -143,7 +143,7 @@ describe Chef::Resource::AwsRdsInstance do
|
|
143
143
|
aws_rds_instance "test-rds-instance-tagging-#{tagging_id}" do
|
144
144
|
aws_tags({})
|
145
145
|
allocated_storage 5
|
146
|
-
db_instance_class "db.
|
146
|
+
db_instance_class "db.t2.micro"
|
147
147
|
engine "postgres"
|
148
148
|
master_username "thechief"
|
149
149
|
master_user_password "securesecure"
|
@@ -86,6 +86,28 @@ describe Chef::Resource::AwsRouteTable do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
context "with nat gateway" do
|
90
|
+
aws_eip_address 'test_eip'
|
91
|
+
aws_nat_gateway 'test_nat_gateway' do
|
92
|
+
subnet 'test_public_subnet'
|
93
|
+
eip_address 'test_eip'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can route to a nat gateway" do
|
97
|
+
expect_recipe {
|
98
|
+
aws_route_table 'test_route_table' do
|
99
|
+
vpc 'test_vpc'
|
100
|
+
routes '0.0.0.0/0' => test_nat_gateway
|
101
|
+
end
|
102
|
+
}.to create_an_aws_route_table('test_route_table',
|
103
|
+
routes: Set[
|
104
|
+
{ destination_cidr_block: '10.0.0.0/16', gateway_id: 'local', state: 'active' },
|
105
|
+
{ destination_cidr_block: '0.0.0.0/0', nat_gateway_id: test_nat_gateway.aws_object.nat_gateway_id, state: 'active' },
|
106
|
+
]
|
107
|
+
).and be_idempotent
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
89
111
|
context "with machines", :super_slow do
|
90
112
|
machine 'test_machine' do
|
91
113
|
machine_options bootstrap_options: {
|
@@ -6,8 +6,7 @@ describe Chef::Resource::AwsVpc do
|
|
6
6
|
when_the_chef_12_server "exists", organization: 'foo', server_scope: :context do
|
7
7
|
with_aws "When AWS has a DHCP options" do
|
8
8
|
# Empty DHCP options for the purposes of associating
|
9
|
-
aws_dhcp_options 'test_dhcp_options'
|
10
|
-
end
|
9
|
+
aws_dhcp_options 'test_dhcp_options'
|
11
10
|
|
12
11
|
context "Creating an aws_vpc" do
|
13
12
|
it "aws_vpc 'vpc' with cidr_block '10.0.0.0/24' creates a VPC" do
|
@@ -190,7 +189,36 @@ describe Chef::Resource::AwsVpc do
|
|
190
189
|
end
|
191
190
|
}.to match_an_aws_vpc_peering_connection('test_peering_connection',
|
192
191
|
:'status.code' => 'deleted'
|
193
|
-
)
|
192
|
+
).and be_idempotent
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context "and When :purge action is called for a VPC, and it contains NAT gateways" do
|
197
|
+
aws_vpc 'test_vpc' do
|
198
|
+
cidr_block '10.0.0.0/24'
|
199
|
+
internet_gateway true
|
200
|
+
end
|
201
|
+
|
202
|
+
aws_subnet 'test_subnet' do
|
203
|
+
vpc 'test_vpc'
|
204
|
+
end
|
205
|
+
|
206
|
+
aws_eip_address 'test_eip'
|
207
|
+
|
208
|
+
aws_nat_gateway 'test_nat_gateway' do
|
209
|
+
subnet 'test_subnet'
|
210
|
+
eip_address 'test_eip'
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'they should be deleted' do
|
214
|
+
r = recipe {
|
215
|
+
aws_vpc 'test_vpc' do
|
216
|
+
action :purge
|
217
|
+
end
|
218
|
+
}
|
219
|
+
expect(r).to match_an_aws_nat_gateway('test_nat_gateway',
|
220
|
+
:state => 'deleted'
|
221
|
+
).and be_idempotent
|
194
222
|
end
|
195
223
|
end
|
196
224
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
begin
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
rescue LoadError; end
|
3
5
|
|
4
6
|
# Bring in the RSpec monkeypatch before we do *anything*, so that builtin matchers
|
5
7
|
# will get the module. Not strictly necessary, but cleaner that way.
|
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.10.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: 2016-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-provisioning
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/chef/provider/aws_cache_replication_group.rb
|
229
229
|
- lib/chef/provider/aws_cache_subnet_group.rb
|
230
230
|
- lib/chef/provider/aws_cloudsearch_domain.rb
|
231
|
+
- lib/chef/provider/aws_cloudwatch_alarm.rb
|
231
232
|
- lib/chef/provider/aws_dhcp_options.rb
|
232
233
|
- lib/chef/provider/aws_ebs_volume.rb
|
233
234
|
- lib/chef/provider/aws_eip_address.rb
|
@@ -240,6 +241,7 @@ files:
|
|
240
241
|
- lib/chef/provider/aws_key_pair.rb
|
241
242
|
- lib/chef/provider/aws_launch_configuration.rb
|
242
243
|
- lib/chef/provider/aws_load_balancer.rb
|
244
|
+
- lib/chef/provider/aws_nat_gateway.rb
|
243
245
|
- lib/chef/provider/aws_network_acl.rb
|
244
246
|
- lib/chef/provider/aws_network_interface.rb
|
245
247
|
- lib/chef/provider/aws_rds_instance.rb
|
@@ -267,6 +269,7 @@ files:
|
|
267
269
|
- lib/chef/provisioning/aws_driver/exceptions.rb
|
268
270
|
- lib/chef/provisioning/aws_driver/resources.rb
|
269
271
|
- lib/chef/provisioning/aws_driver/super_lwrp.rb
|
272
|
+
- lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb
|
270
273
|
- lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb
|
271
274
|
- lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb
|
272
275
|
- lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb
|
@@ -279,6 +282,7 @@ files:
|
|
279
282
|
- lib/chef/resource/aws_cache_replication_group.rb
|
280
283
|
- lib/chef/resource/aws_cache_subnet_group.rb
|
281
284
|
- lib/chef/resource/aws_cloudsearch_domain.rb
|
285
|
+
- lib/chef/resource/aws_cloudwatch_alarm.rb
|
282
286
|
- lib/chef/resource/aws_dhcp_options.rb
|
283
287
|
- lib/chef/resource/aws_ebs_volume.rb
|
284
288
|
- lib/chef/resource/aws_eip_address.rb
|
@@ -291,6 +295,7 @@ files:
|
|
291
295
|
- lib/chef/resource/aws_key_pair.rb
|
292
296
|
- lib/chef/resource/aws_launch_configuration.rb
|
293
297
|
- lib/chef/resource/aws_load_balancer.rb
|
298
|
+
- lib/chef/resource/aws_nat_gateway.rb
|
294
299
|
- lib/chef/resource/aws_network_acl.rb
|
295
300
|
- lib/chef/resource/aws_network_interface.rb
|
296
301
|
- lib/chef/resource/aws_rds_instance.rb
|
@@ -321,8 +326,10 @@ files:
|
|
321
326
|
- spec/aws_support/matchers/have_aws_object_tags.rb
|
322
327
|
- spec/aws_support/matchers/match_an_aws_object.rb
|
323
328
|
- spec/aws_support/matchers/update_an_aws_object.rb
|
329
|
+
- spec/integration/aws_auto_scaling_group_spec.rb
|
324
330
|
- spec/integration/aws_cache_subnet_group_spec.rb
|
325
331
|
- spec/integration/aws_cloudsearch_domain_spec.rb
|
332
|
+
- spec/integration/aws_cloudwatch_alarm_spec.rb
|
326
333
|
- spec/integration/aws_dhcp_options_spec.rb
|
327
334
|
- spec/integration/aws_ebs_volume_spec.rb
|
328
335
|
- spec/integration/aws_eip_address_spec.rb
|
@@ -331,6 +338,7 @@ files:
|
|
331
338
|
- spec/integration/aws_iam_role_spec.rb
|
332
339
|
- spec/integration/aws_internet_gateway_spec.rb
|
333
340
|
- spec/integration/aws_key_pair_spec.rb
|
341
|
+
- spec/integration/aws_nat_gateway_spec.rb
|
334
342
|
- spec/integration/aws_network_acl_spec.rb
|
335
343
|
- spec/integration/aws_network_interface_spec.rb
|
336
344
|
- spec/integration/aws_rds_instance_spec.rb
|
@@ -371,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
379
|
version: '0'
|
372
380
|
requirements: []
|
373
381
|
rubyforge_project:
|
374
|
-
rubygems_version: 2.
|
382
|
+
rubygems_version: 2.5.1
|
375
383
|
signing_key:
|
376
384
|
specification_version: 4
|
377
385
|
summary: Provisioner for creating aws containers in Chef Provisioning.
|