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,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "securerandom"
|
3
3
|
|
4
4
|
def mk_role_name
|
5
5
|
name_postfix = SecureRandom.hex(8)
|
@@ -7,7 +7,7 @@ def mk_role_name
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def ec2_principal
|
10
|
-
<<EOF
|
10
|
+
<<EOF
|
11
11
|
{
|
12
12
|
"Version": "2012-10-17",
|
13
13
|
"Statement": [
|
@@ -29,131 +29,122 @@ describe Chef::Resource::AwsIamRole do
|
|
29
29
|
|
30
30
|
when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
|
31
31
|
with_aws "when connected to AWS" do
|
32
|
-
|
33
|
-
let(:instance_name) {
|
32
|
+
let(:instance_name) do
|
34
33
|
name_postfix = SecureRandom.hex(8)
|
35
34
|
"cp_test_iam_instance_profile_#{name_postfix}"
|
36
|
-
|
35
|
+
end
|
37
36
|
|
38
37
|
it "creates an aws_iam_instance_profile with minimum attributes" do
|
39
|
-
expect_recipe
|
38
|
+
expect_recipe do
|
40
39
|
aws_iam_instance_profile instance_name do
|
41
40
|
path "/"
|
42
41
|
end
|
43
|
-
|
44
|
-
|
45
|
-
).and be_idempotent
|
42
|
+
end.to create_an_aws_iam_instance_profile(instance_name,
|
43
|
+
path: "/").and be_idempotent
|
46
44
|
end
|
47
45
|
|
48
46
|
context "with an existing aws_iam_role" do
|
49
|
-
let(:role_name)
|
47
|
+
let(:role_name) do
|
50
48
|
name_postfix = SecureRandom.hex(8)
|
51
49
|
"cp_test_iam_role_#{name_postfix}"
|
52
|
-
|
50
|
+
end
|
53
51
|
|
54
52
|
# See aws_iam_role_spec.rb for explanation
|
55
53
|
before(:each) do
|
56
|
-
converge
|
54
|
+
converge do
|
57
55
|
aws_iam_role role_name do
|
58
56
|
path "/"
|
59
57
|
assume_role_policy_document ec2_principal
|
60
58
|
end
|
61
|
-
|
59
|
+
end
|
62
60
|
end
|
63
61
|
|
64
62
|
after(:each) do
|
65
|
-
converge
|
63
|
+
converge do
|
66
64
|
aws_iam_role role_name do
|
67
65
|
action :destroy
|
68
66
|
end
|
69
|
-
|
67
|
+
end
|
70
68
|
end
|
71
69
|
|
72
70
|
it "creates an aws_iam_instance_profile with maximum attributes" do
|
73
|
-
expect_recipe
|
71
|
+
expect_recipe do
|
74
72
|
aws_iam_instance_profile instance_name do
|
75
73
|
path "/"
|
76
74
|
role role_name
|
77
75
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
).and be_idempotent
|
76
|
+
end.to create_an_aws_iam_instance_profile(instance_name,
|
77
|
+
path: "/",
|
78
|
+
roles: [{ name: role_name }]).and be_idempotent
|
82
79
|
end
|
83
80
|
|
84
81
|
context "with an existing aws_iam_instance_profile with an attached role" do
|
85
82
|
before(:each) do
|
86
|
-
converge
|
83
|
+
converge do
|
87
84
|
aws_iam_instance_profile instance_name do
|
88
85
|
path "/"
|
89
86
|
role role_name
|
90
87
|
end
|
91
|
-
|
88
|
+
end
|
92
89
|
end
|
93
90
|
|
94
91
|
after(:each) do
|
95
|
-
converge
|
92
|
+
converge do
|
96
93
|
aws_iam_instance_profile instance_name do
|
97
94
|
action :destroy
|
98
95
|
end
|
99
|
-
|
96
|
+
end
|
100
97
|
end
|
101
98
|
|
102
99
|
it "removes the relationship when the role is deleted" do
|
103
|
-
expect_recipe
|
100
|
+
expect_recipe do
|
104
101
|
aws_iam_role role_name do
|
105
102
|
action :destroy
|
106
103
|
end
|
107
|
-
|
108
|
-
|
109
|
-
).and be_idempotent
|
104
|
+
end.to match_an_aws_iam_instance_profile(instance_name,
|
105
|
+
roles: []).and be_idempotent
|
110
106
|
end
|
111
107
|
|
112
108
|
it "removes the relationship when the instance_profile is deleted" do
|
113
|
-
expect_recipe
|
109
|
+
expect_recipe do
|
114
110
|
aws_iam_instance_profile instance_name do
|
115
111
|
action :destroy
|
116
112
|
end
|
117
|
-
|
118
|
-
|
119
|
-
).and be_idempotent
|
113
|
+
end.to match_an_aws_iam_role(role_name,
|
114
|
+
instance_profiles: []).and be_idempotent
|
120
115
|
end
|
121
116
|
|
122
117
|
context "with a second aws_iam_role" do
|
123
118
|
before(:each) do
|
124
|
-
converge
|
119
|
+
converge do
|
125
120
|
aws_iam_role "#{role_name}2" do
|
126
121
|
path "/"
|
127
122
|
assume_role_policy_document ec2_principal
|
128
123
|
end
|
129
|
-
|
124
|
+
end
|
130
125
|
end
|
131
126
|
|
132
127
|
after(:each) do
|
133
|
-
converge
|
128
|
+
converge do
|
134
129
|
aws_iam_instance_profile instance_name do
|
135
130
|
action :destroy
|
136
131
|
end
|
137
|
-
|
132
|
+
end
|
138
133
|
end
|
139
134
|
|
140
135
|
it "updates the attached role" do
|
141
|
-
expect_recipe
|
136
|
+
expect_recipe do
|
142
137
|
aws_iam_instance_profile instance_name do
|
143
138
|
path "/"
|
144
139
|
role "#{role_name}2"
|
145
140
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
).and be_idempotent
|
141
|
+
end.to update_an_aws_iam_instance_profile(instance_name,
|
142
|
+
path: "/",
|
143
|
+
roles: [{ name: "#{role_name}2" }]).and be_idempotent
|
150
144
|
end
|
151
145
|
end
|
152
|
-
|
153
146
|
end
|
154
147
|
end
|
155
|
-
|
156
148
|
end
|
157
|
-
|
158
149
|
end
|
159
150
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "securerandom"
|
3
3
|
|
4
4
|
def ec2_principal
|
5
|
-
<<-EOF
|
5
|
+
<<-EOF
|
6
6
|
{
|
7
7
|
"Version": "2012-10-17",
|
8
8
|
"Statement": [
|
@@ -16,11 +16,11 @@ def ec2_principal
|
|
16
16
|
}
|
17
17
|
]
|
18
18
|
}
|
19
|
-
EOF
|
19
|
+
EOF
|
20
20
|
end
|
21
21
|
|
22
22
|
def rds_principal
|
23
|
-
<<-EOF
|
23
|
+
<<-EOF
|
24
24
|
{
|
25
25
|
"Version": "2012-10-17",
|
26
26
|
"Statement": [
|
@@ -34,11 +34,11 @@ def rds_principal
|
|
34
34
|
}
|
35
35
|
]
|
36
36
|
}
|
37
|
-
EOF
|
37
|
+
EOF
|
38
38
|
end
|
39
39
|
|
40
40
|
def rds_role_policy
|
41
|
-
<<-EOF
|
41
|
+
<<-EOF
|
42
42
|
{
|
43
43
|
"Version": "2012-10-17",
|
44
44
|
"Statement": [
|
@@ -54,11 +54,11 @@ def rds_role_policy
|
|
54
54
|
}
|
55
55
|
]
|
56
56
|
}
|
57
|
-
EOF
|
57
|
+
EOF
|
58
58
|
end
|
59
59
|
|
60
60
|
def iam_role_policy
|
61
|
-
<<-EOF
|
61
|
+
<<-EOF
|
62
62
|
{
|
63
63
|
"Version": "2012-10-17",
|
64
64
|
"Statement": [
|
@@ -69,7 +69,7 @@ def iam_role_policy
|
|
69
69
|
}
|
70
70
|
]
|
71
71
|
}
|
72
|
-
EOF
|
72
|
+
EOF
|
73
73
|
end
|
74
74
|
|
75
75
|
describe Chef::Resource::AwsIamRole do
|
@@ -77,36 +77,34 @@ describe Chef::Resource::AwsIamRole do
|
|
77
77
|
|
78
78
|
when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
|
79
79
|
with_aws "when connected to AWS" do
|
80
|
-
|
81
|
-
let(:role_name) {
|
80
|
+
let(:role_name) do
|
82
81
|
name_postfix = SecureRandom.hex(8)
|
83
82
|
"cp_test_iam_role_#{name_postfix}"
|
84
|
-
|
83
|
+
end
|
85
84
|
|
86
85
|
it "creates an aws_iam_role with minimum attributes" do
|
87
|
-
expect_recipe
|
86
|
+
expect_recipe do
|
88
87
|
aws_iam_role role_name do
|
89
88
|
assume_role_policy_document ec2_principal
|
90
89
|
end
|
91
|
-
|
90
|
+
end.to create_an_aws_iam_role(role_name) { |aws_object|
|
92
91
|
expect(Chef::JSONCompat.parse(URI.decode(aws_object.assume_role_policy_document))).to eq(Chef::JSONCompat.parse(ec2_principal))
|
93
92
|
}.and be_idempotent
|
94
93
|
end
|
95
94
|
|
96
95
|
it "creates an aws_iam_role with maximum attributes" do
|
97
|
-
expect_recipe
|
96
|
+
expect_recipe do
|
98
97
|
aws_iam_role role_name do
|
99
98
|
path "/"
|
100
99
|
assume_role_policy_document ec2_principal
|
101
100
|
inline_policies a: iam_role_policy
|
102
101
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}.and be_idempotent
|
102
|
+
end.to create_an_aws_iam_role(role_name,
|
103
|
+
path: "/",
|
104
|
+
policies: [{ name: "a" }]) { |aws_object|
|
105
|
+
expect(Chef::JSONCompat.parse(URI.decode(aws_object.assume_role_policy_document))).to eq(Chef::JSONCompat.parse(ec2_principal))
|
106
|
+
expect(Chef::JSONCompat.parse(URI.decode(aws_object.policies.first.policy_document))).to eq(Chef::JSONCompat.parse(iam_role_policy))
|
107
|
+
}.and be_idempotent
|
110
108
|
end
|
111
109
|
|
112
110
|
context "with an existing aws_iam_role" do
|
@@ -116,62 +114,57 @@ describe Chef::Resource::AwsIamRole do
|
|
116
114
|
# 2) the let(:role_name) cannot be used at the context level, only at
|
117
115
|
# the example/before/after level
|
118
116
|
before(:each) do
|
119
|
-
converge
|
117
|
+
converge do
|
120
118
|
aws_iam_role role_name do
|
121
119
|
path "/"
|
122
120
|
assume_role_policy_document ec2_principal
|
123
121
|
inline_policies a: iam_role_policy
|
124
122
|
end
|
125
|
-
|
123
|
+
end
|
126
124
|
end
|
127
125
|
|
128
126
|
after(:each) do
|
129
|
-
converge
|
127
|
+
converge do
|
130
128
|
aws_iam_role role_name do
|
131
129
|
action :destroy
|
132
130
|
end
|
133
|
-
|
131
|
+
end
|
134
132
|
end
|
135
133
|
|
136
|
-
|
137
134
|
it "updates all available fields" do
|
138
|
-
expect_recipe
|
135
|
+
expect_recipe do
|
139
136
|
aws_iam_role role_name do
|
140
137
|
assume_role_policy_document rds_principal
|
141
138
|
inline_policies b: rds_role_policy
|
142
139
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}.and be_idempotent
|
140
|
+
end.to create_an_aws_iam_role(role_name,
|
141
|
+
path: "/",
|
142
|
+
policies: [{ name: "b" }]) { |aws_object|
|
143
|
+
expect(Chef::JSONCompat.parse(URI.decode(aws_object.assume_role_policy_document))).to eq(Chef::JSONCompat.parse(rds_principal))
|
144
|
+
expect(Chef::JSONCompat.parse(URI.decode(aws_object.policies.first.policy_document))).to eq(Chef::JSONCompat.parse(rds_role_policy))
|
145
|
+
}.and be_idempotent
|
150
146
|
end
|
151
147
|
|
152
148
|
it "clears inline_policies with an empty hash" do
|
153
|
-
expect_recipe
|
149
|
+
expect_recipe do
|
154
150
|
aws_iam_role role_name do
|
155
|
-
inline_policies
|
151
|
+
inline_policies({})
|
156
152
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
).and be_idempotent
|
153
|
+
end.to create_an_aws_iam_role(role_name,
|
154
|
+
path: "/",
|
155
|
+
policies: []).and be_idempotent
|
161
156
|
end
|
162
157
|
|
163
158
|
it "deletes the aws_iam_role" do
|
164
|
-
r = recipe
|
159
|
+
r = recipe do
|
165
160
|
aws_iam_role role_name do
|
166
161
|
action :destroy
|
167
162
|
end
|
168
|
-
|
163
|
+
end
|
169
164
|
expect(r).to destroy_an_aws_iam_role(role_name)
|
170
165
|
expect { driver.iam_client.list_role_policies(role_name: role_name).policy_names }.to raise_error(::Aws::IAM::Errors::NoSuchEntity)
|
171
166
|
end
|
172
167
|
end
|
173
|
-
|
174
168
|
end
|
175
|
-
|
176
169
|
end
|
177
170
|
end
|
@@ -1,162 +1,151 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Chef::Resource::AwsInternetGateway do
|
4
4
|
extend AWSSupport
|
5
5
|
|
6
|
-
when_the_chef_12_server
|
7
|
-
with_aws
|
8
|
-
|
6
|
+
when_the_chef_12_server "exists", organization: "foo", server_scope: :context do
|
7
|
+
with_aws "with a VPC" do
|
9
8
|
purge_all
|
10
|
-
aws_vpc
|
11
|
-
cidr_block
|
9
|
+
aws_vpc "test_vpc_igw_a" do
|
10
|
+
cidr_block "10.0.0.0/24"
|
12
11
|
end
|
13
12
|
|
14
|
-
aws_vpc
|
15
|
-
cidr_block
|
13
|
+
aws_vpc "test_vpc_igw_b" do
|
14
|
+
cidr_block "10.0.1.0/24"
|
16
15
|
end
|
17
16
|
|
18
17
|
it "creates an aws_internet_gateway with no parameters" do
|
19
|
-
expect_recipe
|
20
|
-
aws_internet_gateway
|
21
|
-
|
18
|
+
expect_recipe do
|
19
|
+
aws_internet_gateway "test_internet_gateway"
|
20
|
+
end.to create_an_aws_internet_gateway("test_internet_gateway").and be_idempotent
|
22
21
|
end
|
23
22
|
|
24
23
|
it "creates an aws_internet_gateway and attaches it to the specified VPC" do
|
25
|
-
expect_recipe
|
26
|
-
aws_internet_gateway
|
24
|
+
expect_recipe do
|
25
|
+
aws_internet_gateway "test_internet_gateway" do
|
27
26
|
vpc test_vpc_igw_a.aws_object.id
|
28
27
|
end
|
29
|
-
|
30
|
-
|
31
|
-
).and be_idempotent
|
28
|
+
end.to create_an_aws_internet_gateway("test_internet_gateway",
|
29
|
+
id: test_vpc_igw_a.aws_object.internet_gateways.first.id).and be_idempotent
|
32
30
|
end
|
33
31
|
|
34
|
-
context
|
35
|
-
aws_internet_gateway
|
32
|
+
context "with the IGW attached to an existing VPC" do
|
33
|
+
aws_internet_gateway "test_internet_gateway" do
|
36
34
|
vpc test_vpc_igw_a.aws_object.id
|
37
35
|
end
|
38
36
|
|
39
37
|
it "updates it to the new VPC" do
|
40
|
-
expect_recipe
|
41
|
-
aws_internet_gateway
|
38
|
+
expect_recipe do
|
39
|
+
aws_internet_gateway "test_internet_gateway" do
|
42
40
|
vpc test_vpc_igw_b
|
43
41
|
end
|
44
|
-
|
45
|
-
|
46
|
-
).and be_idempotent
|
42
|
+
end.to update_an_aws_internet_gateway("test_internet_gateway",
|
43
|
+
id: test_vpc_igw_b.aws_object.internet_gateways.first.id).and be_idempotent
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
50
|
-
context
|
51
|
-
aws_internet_gateway
|
47
|
+
context "with the IGW attached to an existing VPC" do
|
48
|
+
aws_internet_gateway "test_internet_gateway" do
|
52
49
|
vpc test_vpc_igw_a.aws_object.id
|
53
50
|
end
|
54
51
|
|
55
52
|
it "detaches it from the VPC" do
|
56
|
-
expect_recipe
|
57
|
-
aws_internet_gateway
|
53
|
+
expect_recipe do
|
54
|
+
aws_internet_gateway "test_internet_gateway" do
|
58
55
|
action :detach
|
59
56
|
end
|
60
|
-
|
61
|
-
|
62
|
-
).and be_idempotent
|
57
|
+
end.to update_an_aws_internet_gateway("test_internet_gateway",
|
58
|
+
attachments: []).and be_idempotent
|
63
59
|
end
|
64
60
|
end
|
65
61
|
|
66
|
-
context
|
67
|
-
aws_internet_gateway
|
62
|
+
context "with the IGW attached to an existing VPC" do
|
63
|
+
aws_internet_gateway "test_internet_gateway" do
|
68
64
|
vpc test_vpc_igw_a.aws_object.id
|
69
65
|
end
|
70
66
|
|
71
67
|
it "detaches the VPC and destroys the IGW" do
|
72
|
-
r = recipe
|
73
|
-
aws_internet_gateway
|
68
|
+
r = recipe do
|
69
|
+
aws_internet_gateway "test_internet_gateway" do
|
74
70
|
action :destroy
|
75
71
|
end
|
76
|
-
|
77
|
-
expect(r).to destroy_an_aws_internet_gateway(
|
72
|
+
end
|
73
|
+
expect(r).to destroy_an_aws_internet_gateway("test_internet_gateway").and be_idempotent
|
78
74
|
|
79
75
|
expect(test_vpc_igw_a.aws_object.internet_gateways.first).to eq(nil)
|
80
76
|
end
|
81
77
|
|
82
|
-
context
|
83
|
-
aws_vpc
|
84
|
-
cidr_block
|
78
|
+
context "with a VPC with its own managed internet gateway" do
|
79
|
+
aws_vpc "test_vpc_preexisting_igw" do
|
80
|
+
cidr_block "10.0.1.0/24"
|
85
81
|
internet_gateway true
|
86
82
|
end
|
87
83
|
|
88
84
|
it "deletes the old managed IGW and attaches the new one" do
|
89
85
|
old_attached_igw = test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id
|
90
86
|
|
91
|
-
expect_recipe
|
92
|
-
aws_internet_gateway
|
87
|
+
expect_recipe do
|
88
|
+
aws_internet_gateway "test_internet_gateway" do
|
93
89
|
vpc test_vpc_preexisting_igw.aws_object.id
|
94
90
|
end
|
95
|
-
|
96
|
-
|
97
|
-
).and be_idempotent
|
91
|
+
end.to create_an_aws_internet_gateway("test_internet_gateway",
|
92
|
+
id: test_vpc_preexisting_igw.aws_object.internet_gateways.first.id).and be_idempotent
|
98
93
|
|
99
94
|
current_attached_igw = test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id
|
100
95
|
expect(current_attached_igw).not_to eq(old_attached_igw)
|
101
96
|
end
|
102
97
|
end
|
103
98
|
|
104
|
-
context
|
105
|
-
aws_internet_gateway
|
106
|
-
aws_vpc
|
107
|
-
cidr_block
|
99
|
+
context "with a VPC and an attached aws_internet_gateway resource" do
|
100
|
+
aws_internet_gateway "test_internet_gateway"
|
101
|
+
aws_vpc "test_vpc_preexisting_igw" do
|
102
|
+
cidr_block "10.0.1.0/24"
|
108
103
|
internet_gateway test_internet_gateway
|
109
104
|
end
|
110
105
|
|
111
106
|
it "leaves the attachment alone if internet_gateway is set to true" do
|
112
107
|
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id).to eq(test_internet_gateway.aws_object.id)
|
113
|
-
expect_recipe
|
114
|
-
aws_vpc
|
115
|
-
cidr_block
|
108
|
+
expect_recipe do
|
109
|
+
aws_vpc "test_vpc_preexisting_igw" do
|
110
|
+
cidr_block "10.0.1.0/24"
|
116
111
|
internet_gateway true
|
117
112
|
end
|
118
|
-
|
119
|
-
|
120
|
-
).and be_idempotent
|
113
|
+
end.to match_an_aws_vpc("test_vpc_preexisting_igw",
|
114
|
+
vpc_id: test_internet_gateway.aws_object.attachments.first.vpc_id).and be_idempotent
|
121
115
|
end
|
122
116
|
|
123
117
|
it "deletes the attachment if internet_gateway is set to false" do
|
124
|
-
expect_recipe
|
125
|
-
aws_vpc
|
126
|
-
cidr_block
|
118
|
+
expect_recipe do
|
119
|
+
aws_vpc "test_vpc_preexisting_igw" do
|
120
|
+
cidr_block "10.0.1.0/24"
|
127
121
|
internet_gateway false
|
128
122
|
end
|
129
|
-
|
130
|
-
|
131
|
-
).and be_idempotent
|
123
|
+
end.to match_an_aws_internet_gateway("test_internet_gateway",
|
124
|
+
attachments: []).and be_idempotent
|
132
125
|
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.entries).to eq([])
|
133
126
|
end
|
134
127
|
end
|
135
128
|
|
136
|
-
context
|
137
|
-
aws_internet_gateway
|
138
|
-
aws_internet_gateway
|
139
|
-
aws_vpc
|
140
|
-
cidr_block
|
129
|
+
context "with a VPC and an attached aws_internet_gateway resource" do
|
130
|
+
aws_internet_gateway "test_internet_gateway1"
|
131
|
+
aws_internet_gateway "test_internet_gateway2"
|
132
|
+
aws_vpc "test_vpc_preexisting_igw" do
|
133
|
+
cidr_block "10.0.1.0/24"
|
141
134
|
internet_gateway test_internet_gateway1
|
142
135
|
end
|
143
136
|
|
144
137
|
it "switches the attachment to a newly specified aws_internet_gateway" do
|
145
138
|
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id).to eq(test_internet_gateway1.aws_object.id)
|
146
|
-
expect_recipe
|
147
|
-
aws_internet_gateway
|
148
|
-
vpc
|
139
|
+
expect_recipe do
|
140
|
+
aws_internet_gateway "test_internet_gateway2" do
|
141
|
+
vpc "test_vpc_preexisting_igw"
|
149
142
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
id: test_vpc_preexisting_igw.aws_object.internet_gateways.first.id
|
154
|
-
).and be_idempotent
|
143
|
+
end.to match_an_aws_internet_gateway("test_internet_gateway1",
|
144
|
+
attachments: []).and match_an_aws_internet_gateway("test_internet_gateway2",
|
145
|
+
id: test_vpc_preexisting_igw.aws_object.internet_gateways.first.id).and be_idempotent
|
155
146
|
end
|
156
|
-
|
157
147
|
end
|
158
148
|
end
|
159
149
|
end
|
160
|
-
|
161
150
|
end
|
162
151
|
end
|