chef-provisioning-aws 2.2.2 → 3.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/chef-provisioning-aws.gemspec +0 -1
- data/lib/chef/provider/aws_auto_scaling_group.rb +9 -6
- data/lib/chef/provider/aws_dhcp_options.rb +21 -11
- data/lib/chef/provider/aws_ebs_volume.rb +26 -24
- data/lib/chef/provider/aws_eip_address.rb +11 -12
- data/lib/chef/provider/aws_image.rb +1 -1
- data/lib/chef/provider/aws_internet_gateway.rb +18 -10
- data/lib/chef/provider/aws_key_pair.rb +6 -6
- data/lib/chef/provider/aws_launch_configuration.rb +7 -9
- data/lib/chef/provider/aws_nat_gateway.rb +2 -2
- data/lib/chef/provider/aws_network_acl.rb +11 -8
- data/lib/chef/provider/aws_network_interface.rb +34 -29
- data/lib/chef/provider/aws_rds_parameter_group.rb +1 -1
- data/lib/chef/provider/aws_rds_subnet_group.rb +1 -1
- data/lib/chef/provider/aws_route_table.rb +7 -7
- data/lib/chef/provider/aws_s3_bucket.rb +24 -12
- data/lib/chef/provider/aws_security_group.rb +202 -25
- data/lib/chef/provider/aws_server_certificate.rb +3 -4
- data/lib/chef/provider/aws_sns_topic.rb +4 -3
- data/lib/chef/provider/aws_sqs_queue.rb +7 -3
- data/lib/chef/provider/aws_subnet.rb +45 -21
- data/lib/chef/provider/aws_vpc.rb +59 -30
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +12 -3
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +2 -2
- data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +1 -1
- data/lib/chef/provisioning/aws_driver/aws_tagger.rb +2 -2
- data/lib/chef/provisioning/aws_driver/credentials.rb +1 -1
- data/lib/chef/provisioning/aws_driver/credentials2.rb +5 -1
- data/lib/chef/provisioning/aws_driver/driver.rb +124 -34
- data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +4 -4
- data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +1 -1
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_auto_scaling_group.rb +2 -2
- data/lib/chef/resource/aws_cache_cluster.rb +4 -4
- data/lib/chef/resource/aws_cache_replication_group.rb +3 -3
- data/lib/chef/resource/aws_cache_subnet_group.rb +4 -4
- data/lib/chef/resource/aws_cloudsearch_domain.rb +1 -1
- data/lib/chef/resource/aws_cloudwatch_alarm.rb +1 -1
- data/lib/chef/resource/aws_dhcp_options.rb +10 -3
- data/lib/chef/resource/aws_ebs_volume.rb +10 -4
- data/lib/chef/resource/aws_eip_address.rb +4 -4
- data/lib/chef/resource/aws_elasticsearch_domain.rb +1 -1
- data/lib/chef/resource/aws_iam_role.rb +1 -1
- data/lib/chef/resource/aws_internet_gateway.rb +11 -4
- data/lib/chef/resource/aws_key_pair.rb +4 -3
- data/lib/chef/resource/aws_launch_configuration.rb +5 -4
- data/lib/chef/resource/aws_load_balancer.rb +14 -3
- data/lib/chef/resource/aws_nat_gateway.rb +2 -2
- data/lib/chef/resource/aws_network_acl.rb +10 -10
- data/lib/chef/resource/aws_network_interface.rb +12 -6
- data/lib/chef/resource/aws_rds_parameter_group.rb +6 -6
- data/lib/chef/resource/aws_rds_subnet_group.rb +4 -5
- data/lib/chef/resource/aws_route53_record_set.rb +1 -1
- data/lib/chef/resource/aws_route_table.rb +1 -1
- data/lib/chef/resource/aws_s3_bucket.rb +3 -2
- data/lib/chef/resource/aws_security_group.rb +6 -6
- data/lib/chef/resource/aws_server_certificate.rb +4 -5
- data/lib/chef/resource/aws_sns_topic.rb +4 -4
- data/lib/chef/resource/aws_sqs_queue.rb +3 -3
- data/lib/chef/resource/aws_subnet.rb +5 -5
- data/lib/chef/resource/aws_vpc.rb +12 -6
- data/lib/chef/resource/aws_vpc_peering_connection.rb +2 -2
- data/spec/aws_support.rb +12 -9
- data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +15 -5
- data/spec/integration/aws_dhcp_options_spec.rb +7 -7
- data/spec/integration/aws_ebs_volume_spec.rb +1 -1
- data/spec/integration/aws_internet_gateway_spec.rb +19 -18
- data/spec/integration/aws_key_pair_spec.rb +1 -1
- data/spec/integration/aws_nat_gateway_spec.rb +3 -6
- data/spec/integration/aws_network_acl_spec.rb +19 -11
- data/spec/integration/aws_network_interface_spec.rb +26 -20
- data/spec/integration/aws_rds_instance_spec.rb +6 -7
- data/spec/integration/aws_rds_subnet_group_spec.rb +6 -6
- data/spec/integration/aws_route53_hosted_zone_spec.rb +1 -1
- data/spec/integration/aws_s3_bucket_spec.rb +1 -2
- data/spec/integration/aws_security_group_spec.rb +272 -198
- data/spec/integration/aws_server_certificate_spec.rb +60 -78
- data/spec/integration/aws_subnet_spec.rb +8 -4
- data/spec/integration/aws_vpc_spec.rb +29 -23
- data/spec/integration/machine_spec.rb +1 -1
- data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +13 -0
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +1 -1
- data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +1 -1
- metadata +5 -20
- data/spec/persistence_file.txt +0 -220
@@ -5,12 +5,12 @@ require 'chef/provisioning/aws_driver/exceptions'
|
|
5
5
|
class Chef::Resource::AwsSecurityGroup < Chef::Provisioning::AWSDriver::AWSResource
|
6
6
|
include Chef::Provisioning::AWSDriver::AWSTaggable
|
7
7
|
|
8
|
-
aws_sdk_type
|
8
|
+
aws_sdk_type ::Aws::EC2::SecurityGroup,
|
9
9
|
id: :id,
|
10
10
|
option_names: [:security_group, :security_group_id, :security_group_name]
|
11
11
|
|
12
12
|
attribute :name, kind_of: String, name_attribute: true
|
13
|
-
attribute :vpc, kind_of: [ String, AwsVpc,
|
13
|
+
attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
|
14
14
|
attribute :description, kind_of: String
|
15
15
|
|
16
16
|
#
|
@@ -55,21 +55,21 @@ class Chef::Resource::AwsSecurityGroup < Chef::Provisioning::AWSDriver::AWSResou
|
|
55
55
|
|
56
56
|
def aws_object
|
57
57
|
if security_group_id
|
58
|
-
result = driver.
|
58
|
+
result = driver.ec2_resource.security_group(security_group_id)
|
59
59
|
else
|
60
60
|
# Names are unique within a VPC. Try to search by name and narroy by VPC, if
|
61
61
|
# provided
|
62
62
|
if vpc
|
63
63
|
vpc_object = Chef::Resource::AwsVpc.get_aws_object(vpc, resource: self)
|
64
|
-
results
|
64
|
+
results=vpc_object.security_groups.to_a.select { |s| s.group_name == name or s.id == name }
|
65
65
|
else
|
66
|
-
results
|
66
|
+
results=driver.ec2_resource.security_groups.to_a.select { |s| s.group_name == name or s.id == name }
|
67
67
|
end
|
68
68
|
if results.size >= 2
|
69
69
|
raise ::Chef::Provisioning::AWSDriver::Exceptions::MultipleSecurityGroupError.new(name, results)
|
70
70
|
end
|
71
71
|
result = results.first
|
72
72
|
end
|
73
|
-
result
|
73
|
+
result ? result : nil
|
74
74
|
end
|
75
75
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
|
3
3
|
class Chef::Resource::AwsServerCertificate < Chef::Provisioning::AWSDriver::AWSResource
|
4
|
-
aws_sdk_type
|
4
|
+
aws_sdk_type ::Aws::IAM::ServerCertificate
|
5
5
|
|
6
6
|
attribute :name, kind_of: String, name_attribute: true
|
7
7
|
|
@@ -11,11 +11,10 @@ class Chef::Resource::AwsServerCertificate < Chef::Provisioning::AWSDriver::AWSR
|
|
11
11
|
|
12
12
|
def aws_object
|
13
13
|
begin
|
14
|
-
cert = driver.iam
|
15
|
-
|
16
|
-
cert.arn
|
14
|
+
cert = ::Aws::IAM::ServerCertificate.new(name,{client: driver.iam} )
|
15
|
+
cert.data
|
17
16
|
cert
|
18
|
-
rescue
|
17
|
+
rescue ::Aws::IAM::Errors::NoSuchEntity
|
19
18
|
nil
|
20
19
|
end
|
21
20
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
|
3
3
|
class Chef::Resource::AwsSnsTopic < Chef::Provisioning::AWSDriver::AWSResource
|
4
|
-
aws_sdk_type
|
4
|
+
aws_sdk_type ::Aws::SNS::Topic
|
5
5
|
|
6
6
|
attribute :name, kind_of: String, name_attribute: true
|
7
7
|
attribute :arn, kind_of: String, default: lazy { driver.build_arn(service: 'sns', resource: name) }
|
8
8
|
|
9
9
|
def aws_object
|
10
|
-
result = driver.sns.topics[arn]
|
11
10
|
begin
|
12
11
|
# Test whether it exists or not by asking for a property
|
13
|
-
result.
|
14
|
-
|
12
|
+
result = driver.sns.get_topic_attributes(topic_arn: arn)
|
13
|
+
result = result.data
|
14
|
+
rescue ::Aws::SNS::Errors::NotFound
|
15
15
|
result = nil
|
16
16
|
end
|
17
17
|
result
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
|
3
3
|
class Chef::Resource::AwsSqsQueue < Chef::Provisioning::AWSDriver::AWSResource
|
4
|
-
aws_sdk_type
|
4
|
+
aws_sdk_type ::Aws::SQS::Queue
|
5
5
|
|
6
6
|
attribute :name, kind_of: String, name_attribute: true
|
7
7
|
attribute :options, kind_of: Hash
|
8
8
|
|
9
9
|
def aws_object
|
10
10
|
begin
|
11
|
-
driver.sqs.
|
12
|
-
rescue
|
11
|
+
driver.sqs.get_queue_url(queue_name: name)
|
12
|
+
rescue ::Aws::SQS::Errors::NonExistentQueue
|
13
13
|
nil
|
14
14
|
end
|
15
15
|
end
|
@@ -16,7 +16,7 @@ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
|
16
16
|
class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
17
17
|
include Chef::Provisioning::AWSDriver::AWSTaggable
|
18
18
|
|
19
|
-
aws_sdk_type
|
19
|
+
aws_sdk_type ::Aws::EC2::Subnet, :id => :id
|
20
20
|
|
21
21
|
require 'chef/resource/aws_vpc'
|
22
22
|
require 'chef/resource/aws_network_acl'
|
@@ -35,7 +35,7 @@ class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWith
|
|
35
35
|
# - An actual `aws_vpc` resource.
|
36
36
|
# - An AWS `VPC` object.
|
37
37
|
#
|
38
|
-
attribute :vpc, kind_of: [ String, AwsVpc,
|
38
|
+
attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
|
39
39
|
|
40
40
|
#
|
41
41
|
# The CIDR block of IP addresses allocated to this subnet.
|
@@ -84,7 +84,7 @@ class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWith
|
|
84
84
|
#
|
85
85
|
# TODO: See if it's possible to disassociate a Network ACL.
|
86
86
|
#
|
87
|
-
attribute :network_acl, kind_of: [ String, AwsNetworkAcl,
|
87
|
+
attribute :network_acl, kind_of: [ String, AwsNetworkAcl, ::Aws::EC2::NetworkAcl ]
|
88
88
|
|
89
89
|
attribute :subnet_id, kind_of: String, aws_id_attribute: true, default: lazy {
|
90
90
|
name =~ /^subnet-[a-f0-9]{8}$/ ? name : nil
|
@@ -92,12 +92,12 @@ class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWith
|
|
92
92
|
|
93
93
|
def aws_object
|
94
94
|
driver, id = get_driver_and_id
|
95
|
-
result = driver.
|
95
|
+
result = driver.ec2_resource.subnet(id) if id
|
96
96
|
if result
|
97
97
|
begin
|
98
98
|
# Try to access it to see if it exists (no `exists?` method)
|
99
99
|
result.vpc_id
|
100
|
-
rescue
|
100
|
+
rescue ::Aws::EC2::Errors::InvalidSubnetIDNotFound
|
101
101
|
result = nil
|
102
102
|
end
|
103
103
|
end
|
@@ -27,13 +27,12 @@ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
|
27
27
|
#
|
28
28
|
class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
29
29
|
include Chef::Provisioning::AWSDriver::AWSTaggable
|
30
|
-
aws_sdk_type
|
30
|
+
aws_sdk_type ::Aws::EC2::Vpc,
|
31
31
|
id: :id,
|
32
32
|
option_names: [:vpc, :vpc_id, :peer_vpc_id]
|
33
33
|
|
34
34
|
require 'chef/resource/aws_dhcp_options'
|
35
35
|
require 'chef/resource/aws_route_table'
|
36
|
-
|
37
36
|
#
|
38
37
|
# The name of this VPC.
|
39
38
|
#
|
@@ -69,7 +68,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
69
68
|
# detach if not.
|
70
69
|
# - You may specify the AWS ID of an actual Internet Gateway
|
71
70
|
#
|
72
|
-
attribute :internet_gateway#, kind_of: [ String,
|
71
|
+
attribute :internet_gateway#, kind_of: [ String, ::Aws::EC2::InternetGateway ], equal_to: [ true, false, :detach ]
|
73
72
|
|
74
73
|
#
|
75
74
|
# The main route table.
|
@@ -105,7 +104,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
105
104
|
#
|
106
105
|
# The DHCP options for this VPC.
|
107
106
|
#
|
108
|
-
attribute :dhcp_options, kind_of: [ AwsDhcpOptions,
|
107
|
+
attribute :dhcp_options, kind_of: [ AwsDhcpOptions, ::Aws::EC2::DhcpOptions, String ]
|
109
108
|
|
110
109
|
#
|
111
110
|
# Indicates whether the DNS resolution is supported for the VPC. If this
|
@@ -134,7 +133,14 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
134
133
|
|
135
134
|
def aws_object
|
136
135
|
driver, id = get_driver_and_id
|
137
|
-
|
138
|
-
result
|
136
|
+
ec2_resource = ::Aws::EC2::Resource.new(driver.ec2)
|
137
|
+
result = ec2_resource.vpc(id) if id
|
138
|
+
result && exists?(result) ? result : nil
|
139
|
+
end
|
140
|
+
|
141
|
+
def exists?(result)
|
142
|
+
return true if result.data
|
143
|
+
rescue ::Aws::EC2::Errors::InvalidVpcIDNotFound
|
144
|
+
return false
|
139
145
|
end
|
140
146
|
end
|
@@ -32,7 +32,7 @@ class Chef::Resource::AwsVpcPeeringConnection < Chef::Provisioning::AWSDriver::A
|
|
32
32
|
#
|
33
33
|
# This is required for new peering connections.
|
34
34
|
#
|
35
|
-
attribute :vpc, kind_of: [ String, AwsVpc,
|
35
|
+
attribute :vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
|
36
36
|
|
37
37
|
#
|
38
38
|
# The VPC to peer
|
@@ -45,7 +45,7 @@ class Chef::Resource::AwsVpcPeeringConnection < Chef::Provisioning::AWSDriver::A
|
|
45
45
|
#
|
46
46
|
# This is required for new peering connections.
|
47
47
|
#
|
48
|
-
attribute :peer_vpc, kind_of: [ String, AwsVpc,
|
48
|
+
attribute :peer_vpc, kind_of: [ String, AwsVpc, ::Aws::EC2::Vpc ]
|
49
49
|
|
50
50
|
#
|
51
51
|
# The target VPC account id to peer
|
data/spec/aws_support.rb
CHANGED
@@ -20,18 +20,19 @@ module AWSSupport
|
|
20
20
|
require 'aws_support/aws_resource_run_wrapper'
|
21
21
|
|
22
22
|
# Add AWS to the list of objects which can be matched against a Hash or Array
|
23
|
-
require 'aws'
|
23
|
+
require 'aws-sdk'
|
24
24
|
require 'aws_support/deep_matcher/matchable_object'
|
25
25
|
require 'aws_support/deep_matcher/matchable_array'
|
26
26
|
DeepMatcher::MatchableObject.matchable_classes << proc { |o| o.class.name =~ /^(AWS|Aws)::(AutoScaling|EC2|ELB|IAM|S3|RDS|CloudSearch|CloudWatch|Route53|ElasticsearchService)($|::)/ }
|
27
|
-
DeepMatcher::MatchableArray.matchable_classes
|
27
|
+
DeepMatcher::MatchableArray.matchable_classes #<< AWS::Core::Data::List
|
28
28
|
|
29
29
|
def purge_all
|
30
30
|
before :all do
|
31
31
|
driver = self.driver
|
32
32
|
recipe do
|
33
|
-
driver.ec2.
|
34
|
-
|
33
|
+
vpcs = driver.ec2.describe_vpcs({filters: [{name: "tag-value", values: ["test_vpc"]}]})[:vpcs]
|
34
|
+
vpcs.each do |vpc|
|
35
|
+
aws_vpc vpc.vpc_id do
|
35
36
|
action :purge
|
36
37
|
end
|
37
38
|
end
|
@@ -47,7 +48,8 @@ module AWSSupport
|
|
47
48
|
cidr_block '10.0.0.0/16'
|
48
49
|
internet_gateway true
|
49
50
|
enable_dns_hostnames true
|
50
|
-
|
51
|
+
# TODO : uncomment this when fix main routes in aws_vpc resource as per new version
|
52
|
+
# main_routes '0.0.0.0/0' => :internet_gateway
|
51
53
|
end
|
52
54
|
|
53
55
|
aws_key_pair 'test_key_pair' do
|
@@ -55,10 +57,11 @@ module AWSSupport
|
|
55
57
|
end
|
56
58
|
|
57
59
|
before :context do
|
58
|
-
|
59
|
-
image.
|
60
|
+
# TODO : Need to fix below line as per version two commenting out for now since its failing and not able to proceed for other specs
|
61
|
+
image = driver.ec2.describe_images({filters: [{name: 'name', values: ['test_machine_image']}]}).first
|
62
|
+
image.delete unless image
|
60
63
|
|
61
|
-
default_sg = test_vpc.aws_object.security_groups
|
64
|
+
default_sg = test_vpc.aws_object.security_groups({filters: [{name: 'group-name', values: ['default']}]}).first
|
62
65
|
recipe do
|
63
66
|
aws_security_group default_sg do
|
64
67
|
inbound_rules '0.0.0.0/0' => 22
|
@@ -253,7 +256,7 @@ module AWSSupport
|
|
253
256
|
end
|
254
257
|
|
255
258
|
def default_vpc
|
256
|
-
@default_vpc ||= driver.ec2.
|
259
|
+
@default_vpc ||= driver.ec2.describe_vpcs({filters: [{name: "isDefault", values: ["true"]}]})[:vpcs].first
|
257
260
|
end
|
258
261
|
|
259
262
|
def driver
|
@@ -64,7 +64,6 @@ module AWSSupport
|
|
64
64
|
|
65
65
|
def match_hashes_failure_messages(expected_hash, actual_hash, identifier)
|
66
66
|
result = []
|
67
|
-
|
68
67
|
expected_hash.all? do |expected_key, expected_value|
|
69
68
|
missing_value = false
|
70
69
|
actual_value = actual_hash.fetch(expected_key) do
|
@@ -110,14 +109,14 @@ module AWSSupport
|
|
110
109
|
end
|
111
110
|
op = change.action
|
112
111
|
op = ' ' if op == '='
|
113
|
-
|
112
|
+
|
113
|
+
result += messages.flat_map { |m| m.split("\n") }.map { |m| "#{op} #{m}" } if messages
|
114
114
|
end
|
115
115
|
different ? result : []
|
116
116
|
end
|
117
117
|
|
118
118
|
def match_hash_and_object_failure_messages(expected_hash, actual_object, identifier)
|
119
119
|
result = []
|
120
|
-
|
121
120
|
expected_hash.all? do |expected_key, expected_value|
|
122
121
|
# 'a.b.c' => 1 -> { a: { b: { c: 1 }}}
|
123
122
|
names = expected_key.to_s.split('.')
|
@@ -130,7 +129,18 @@ module AWSSupport
|
|
130
129
|
|
131
130
|
# Grab the actual value from the object
|
132
131
|
begin
|
133
|
-
|
132
|
+
case expected_key.to_s
|
133
|
+
when "dhcp_configurations"
|
134
|
+
actual_value = actual_object.data.to_h[expected_key]
|
135
|
+
when "internet_gateways_entries"
|
136
|
+
actual_value = actual_object.internet_gateways.entries.first
|
137
|
+
when "routetables_entries_routes"
|
138
|
+
entries = []
|
139
|
+
actual_object.route_tables.entries.first.routes.each { |r| entries << r.data.to_h }
|
140
|
+
actual_value = entries
|
141
|
+
else
|
142
|
+
actual_value = actual_object.send(expected_key)
|
143
|
+
end
|
134
144
|
rescue NoMethodError
|
135
145
|
if !actual_value.respond_to?(expected_key)
|
136
146
|
result << "#{identifier || "object"}.send(#{expected_key.inspect}) is missing, expected value #{description_of(expected_value)}"
|
@@ -161,7 +171,7 @@ module AWSSupport
|
|
161
171
|
attr_reader :value
|
162
172
|
|
163
173
|
def failure_messages(actual)
|
164
|
-
@failure_messages[actual]
|
174
|
+
@failure_messages[actual] if @failure_messages
|
165
175
|
end
|
166
176
|
|
167
177
|
def ==(actual)
|
@@ -13,13 +13,13 @@ describe "AwsDhcpOptions" do
|
|
13
13
|
netbios_name_servers %w(8.8.8.8 8.8.4.4)
|
14
14
|
netbios_node_type 2
|
15
15
|
end
|
16
|
-
}.to create_an_aws_dhcp_options('test-dhcp-options',
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
}.to create_an_aws_dhcp_options('test-dhcp-options', dhcp_configurations: [
|
17
|
+
{key: "domain-name", values: [{value: "example.com"}]},
|
18
|
+
{key: "domain-name-servers", values: [{value: "8.8.8.8"}, {value: "8.8.4.4"}]},
|
19
|
+
{key: "ntp-servers", values: [{value: "8.8.8.8"}, {value: "8.8.4.4"}]},
|
20
|
+
{key: "netbios-node-type", values: [{value: "2"}]},
|
21
|
+
{key: "netbios-name-servers", values: [{value: "8.8.8.8"}, {value: "8.8.4.4"}]}
|
22
|
+
]).and be_idempotent
|
23
23
|
end
|
24
24
|
|
25
25
|
it "creates aws_dhcp_options tags" do
|
@@ -6,6 +6,7 @@ describe Chef::Resource::AwsInternetGateway do
|
|
6
6
|
when_the_chef_12_server 'exists', organization: 'foo', server_scope: :context do
|
7
7
|
with_aws 'with a VPC' do
|
8
8
|
|
9
|
+
purge_all
|
9
10
|
aws_vpc 'test_vpc_igw_a' do
|
10
11
|
cidr_block '10.0.0.0/24'
|
11
12
|
end
|
@@ -26,7 +27,7 @@ describe Chef::Resource::AwsInternetGateway do
|
|
26
27
|
vpc test_vpc_igw_a.aws_object.id
|
27
28
|
end
|
28
29
|
}.to create_an_aws_internet_gateway('test_internet_gateway',
|
29
|
-
|
30
|
+
id: test_vpc_igw_a.aws_object.internet_gateways.first.id
|
30
31
|
).and be_idempotent
|
31
32
|
end
|
32
33
|
|
@@ -41,7 +42,7 @@ describe Chef::Resource::AwsInternetGateway do
|
|
41
42
|
vpc test_vpc_igw_b
|
42
43
|
end
|
43
44
|
}.to update_an_aws_internet_gateway('test_internet_gateway',
|
44
|
-
|
45
|
+
id: test_vpc_igw_b.aws_object.internet_gateways.first.id
|
45
46
|
).and be_idempotent
|
46
47
|
end
|
47
48
|
end
|
@@ -57,7 +58,7 @@ describe Chef::Resource::AwsInternetGateway do
|
|
57
58
|
action :detach
|
58
59
|
end
|
59
60
|
}.to update_an_aws_internet_gateway('test_internet_gateway',
|
60
|
-
|
61
|
+
attachments: []
|
61
62
|
).and be_idempotent
|
62
63
|
end
|
63
64
|
end
|
@@ -75,7 +76,7 @@ describe Chef::Resource::AwsInternetGateway do
|
|
75
76
|
}
|
76
77
|
expect(r).to destroy_an_aws_internet_gateway('test_internet_gateway').and be_idempotent
|
77
78
|
|
78
|
-
expect(test_vpc_igw_a.aws_object.
|
79
|
+
expect(test_vpc_igw_a.aws_object.internet_gateways.first).to eq(nil)
|
79
80
|
end
|
80
81
|
|
81
82
|
context 'with a VPC with its own managed internet gateway' do
|
@@ -85,17 +86,18 @@ describe Chef::Resource::AwsInternetGateway do
|
|
85
86
|
end
|
86
87
|
|
87
88
|
it "deletes the old managed IGW and attaches the new one" do
|
88
|
-
|
89
|
+
old_attached_igw = test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id
|
89
90
|
|
90
91
|
expect_recipe {
|
91
92
|
aws_internet_gateway 'test_internet_gateway' do
|
92
|
-
vpc test_vpc_preexisting_igw.aws_object
|
93
|
+
vpc test_vpc_preexisting_igw.aws_object.id
|
93
94
|
end
|
94
95
|
}.to create_an_aws_internet_gateway('test_internet_gateway',
|
95
|
-
|
96
|
+
id: test_vpc_preexisting_igw.aws_object.internet_gateways.first.id
|
96
97
|
).and be_idempotent
|
97
98
|
|
98
|
-
|
99
|
+
current_attached_igw = test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id
|
100
|
+
expect(current_attached_igw).not_to eq(old_attached_igw)
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
@@ -107,14 +109,14 @@ describe Chef::Resource::AwsInternetGateway do
|
|
107
109
|
end
|
108
110
|
|
109
111
|
it "leaves the attachment alone if internet_gateway is set to true" do
|
110
|
-
expect(test_vpc_preexisting_igw.aws_object.
|
112
|
+
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id).to eq(test_internet_gateway.aws_object.id)
|
111
113
|
expect_recipe {
|
112
114
|
aws_vpc 'test_vpc_preexisting_igw' do
|
113
115
|
cidr_block '10.0.1.0/24'
|
114
116
|
internet_gateway true
|
115
117
|
end
|
116
118
|
}.to match_an_aws_vpc('test_vpc_preexisting_igw',
|
117
|
-
|
119
|
+
vpc_id: test_internet_gateway.aws_object.attachments.first.vpc_id
|
118
120
|
).and be_idempotent
|
119
121
|
end
|
120
122
|
|
@@ -124,11 +126,10 @@ describe Chef::Resource::AwsInternetGateway do
|
|
124
126
|
cidr_block '10.0.1.0/24'
|
125
127
|
internet_gateway false
|
126
128
|
end
|
127
|
-
}.to
|
128
|
-
|
129
|
-
).and match_an_aws_internet_gateway('test_internet_gateway',
|
130
|
-
vpc: nil
|
129
|
+
}.to match_an_aws_internet_gateway('test_internet_gateway',
|
130
|
+
attachments: []
|
131
131
|
).and be_idempotent
|
132
|
+
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.entries).to eq([])
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
@@ -137,19 +138,19 @@ describe Chef::Resource::AwsInternetGateway do
|
|
137
138
|
aws_internet_gateway 'test_internet_gateway2'
|
138
139
|
aws_vpc 'test_vpc_preexisting_igw' do
|
139
140
|
cidr_block '10.0.1.0/24'
|
140
|
-
internet_gateway test_internet_gateway1
|
141
|
+
internet_gateway test_internet_gateway1
|
141
142
|
end
|
142
143
|
|
143
144
|
it "switches the attachment to a newly specified aws_internet_gateway" do
|
144
|
-
expect(test_vpc_preexisting_igw.aws_object.
|
145
|
+
expect(test_vpc_preexisting_igw.aws_object.internet_gateways.first.internet_gateway_id).to eq(test_internet_gateway1.aws_object.id)
|
145
146
|
expect_recipe {
|
146
147
|
aws_internet_gateway 'test_internet_gateway2' do
|
147
148
|
vpc 'test_vpc_preexisting_igw'
|
148
149
|
end
|
149
150
|
}.to match_an_aws_internet_gateway('test_internet_gateway1',
|
150
|
-
|
151
|
+
attachments: []
|
151
152
|
).and match_an_aws_internet_gateway('test_internet_gateway2',
|
152
|
-
|
153
|
+
id: test_vpc_preexisting_igw.aws_object.internet_gateways.first.id
|
153
154
|
).and be_idempotent
|
154
155
|
end
|
155
156
|
|