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,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource"
|
2
2
|
|
3
3
|
class Chef::Resource::AwsServerCertificate < Chef::Provisioning::AWSDriver::AWSResource
|
4
4
|
aws_sdk_type ::Aws::IAM::ServerCertificate
|
@@ -10,12 +10,10 @@ class Chef::Resource::AwsServerCertificate < Chef::Provisioning::AWSDriver::AWSR
|
|
10
10
|
attribute :private_key, kind_of: String
|
11
11
|
|
12
12
|
def aws_object
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
nil
|
19
|
-
end
|
13
|
+
cert = ::Aws::IAM::ServerCertificate.new(name, client: driver.iam)
|
14
|
+
cert.data
|
15
|
+
cert
|
16
|
+
rescue ::Aws::IAM::Errors::NoSuchEntity
|
17
|
+
nil
|
20
18
|
end
|
21
19
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource"
|
2
2
|
|
3
3
|
class Chef::Resource::AwsSnsTopic < Chef::Provisioning::AWSDriver::AWSResource
|
4
4
|
aws_sdk_type ::Aws::SNS::Topic
|
5
5
|
|
6
6
|
attribute :name, kind_of: String, name_attribute: true
|
7
|
-
attribute :arn, kind_of: String, default: lazy { driver.build_arn(service:
|
7
|
+
attribute :arn, kind_of: String, default: lazy { driver.build_arn(service: "sns", resource: name) }
|
8
8
|
|
9
9
|
def aws_object
|
10
10
|
begin
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource"
|
2
2
|
|
3
3
|
class Chef::Resource::AwsSqsQueue < Chef::Provisioning::AWSDriver::AWSResource
|
4
4
|
aws_sdk_type ::Aws::SQS::Queue
|
@@ -7,17 +7,15 @@ class Chef::Resource::AwsSqsQueue < Chef::Provisioning::AWSDriver::AWSResource
|
|
7
7
|
attribute :options, kind_of: Hash
|
8
8
|
|
9
9
|
def aws_object
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
nil
|
14
|
-
end
|
10
|
+
driver.sqs.get_queue_url(queue_name: name)
|
11
|
+
rescue ::Aws::SQS::Errors::NonExistentQueue
|
12
|
+
nil
|
15
13
|
end
|
16
14
|
|
17
15
|
protected
|
18
16
|
|
19
17
|
def self.get_aws_object_id(value, **options)
|
20
18
|
aws_object = get_aws_object(value, **options)
|
21
|
-
aws_object.arn.split(
|
19
|
+
aws_object.arn.split(":")[-1] if aws_object
|
22
20
|
end
|
23
21
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource_with_entry"
|
2
2
|
|
3
3
|
#
|
4
4
|
# An AWS subnet is a sub-section of a VPC, walled gardens within the walled garden;
|
@@ -16,11 +16,11 @@ 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 ::Aws::EC2::Subnet, :
|
19
|
+
aws_sdk_type ::Aws::EC2::Subnet, id: :id
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
21
|
+
require "chef/resource/aws_vpc"
|
22
|
+
require "chef/resource/aws_network_acl"
|
23
|
+
require "chef/resource/aws_route_table"
|
24
24
|
|
25
25
|
#
|
26
26
|
# The name of this subnet.
|
@@ -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: [
|
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.
|
@@ -62,7 +62,7 @@ class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWith
|
|
62
62
|
#
|
63
63
|
# Whether to give public IP addresses to new instances in this subnet by default.
|
64
64
|
#
|
65
|
-
attribute :map_public_ip_on_launch, kind_of: [
|
65
|
+
attribute :map_public_ip_on_launch, kind_of: [TrueClass, FalseClass]
|
66
66
|
|
67
67
|
#
|
68
68
|
# The route table to associate with this subnet.
|
@@ -76,7 +76,7 @@ class Chef::Resource::AwsSubnet < Chef::Provisioning::AWSDriver::AWSResourceWith
|
|
76
76
|
#
|
77
77
|
# By default, an implicit association with the main route table is made (`:default_to_main`)
|
78
78
|
#
|
79
|
-
attribute :route_table
|
79
|
+
attribute :route_table # , kind_of: [ String, AwsRouteTable, ::Aws::EC2::RouteTable ], equal_to: [ :default_to_main ]
|
80
80
|
|
81
81
|
#
|
82
82
|
# The Network ACL to associate with this subnet. Subnets may only
|
@@ -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: [
|
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]+$/ ? name : nil
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource_with_entry"
|
2
2
|
|
3
3
|
#
|
4
4
|
# Represents an AWS VPC.
|
@@ -29,10 +29,10 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
29
29
|
include Chef::Provisioning::AWSDriver::AWSTaggable
|
30
30
|
aws_sdk_type ::Aws::EC2::Vpc,
|
31
31
|
id: :id,
|
32
|
-
option_names:
|
32
|
+
option_names: %i{vpc vpc_id peer_vpc_id}
|
33
33
|
|
34
|
-
require
|
35
|
-
require
|
34
|
+
require "chef/resource/aws_dhcp_options"
|
35
|
+
require "chef/resource/aws_route_table"
|
36
36
|
#
|
37
37
|
# The name of this VPC.
|
38
38
|
#
|
@@ -57,7 +57,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
57
57
|
#
|
58
58
|
# Defaults, not surprisingly, to `default`.
|
59
59
|
#
|
60
|
-
attribute :instance_tenancy, equal_to:
|
60
|
+
attribute :instance_tenancy, equal_to: %i{default dedicated}
|
61
61
|
|
62
62
|
#
|
63
63
|
# Whether this VPC should have an Internet Gateway or not.
|
@@ -68,7 +68,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
68
68
|
# detach if not.
|
69
69
|
# - You may specify the AWS ID of an actual Internet Gateway
|
70
70
|
#
|
71
|
-
attribute :internet_gateway
|
71
|
+
attribute :internet_gateway # , kind_of: [ String, ::Aws::EC2::InternetGateway ], equal_to: [ true, false, :detach ]
|
72
72
|
|
73
73
|
#
|
74
74
|
# The main route table.
|
@@ -78,7 +78,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
78
78
|
# - An actual `aws_route_table` resource.
|
79
79
|
# - An AWS `route_table` object.
|
80
80
|
#
|
81
|
-
attribute :main_route_table, kind_of: [
|
81
|
+
attribute :main_route_table, kind_of: [String, AwsRouteTable, ::Aws::EC2::RouteTable]
|
82
82
|
|
83
83
|
#
|
84
84
|
# The routes for the main route table.
|
@@ -104,7 +104,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
104
104
|
#
|
105
105
|
# The DHCP options for this VPC.
|
106
106
|
#
|
107
|
-
attribute :dhcp_options, kind_of: [
|
107
|
+
attribute :dhcp_options, kind_of: [AwsDhcpOptions, ::Aws::EC2::DhcpOptions, String]
|
108
108
|
|
109
109
|
#
|
110
110
|
# Indicates whether the DNS resolution is supported for the VPC. If this
|
@@ -117,7 +117,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
117
117
|
# For more information, see Amazon DNS Server:
|
118
118
|
# - http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html#AmazonDNS
|
119
119
|
#
|
120
|
-
attribute :enable_dns_support, equal_to: [
|
120
|
+
attribute :enable_dns_support, equal_to: [true, false]
|
121
121
|
|
122
122
|
#
|
123
123
|
# Indicates whether the instances launched in the VPC get DNS hostnames. If
|
@@ -125,7 +125,7 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
125
125
|
# they do not. If you want your instances to get DNS hostnames, you must also
|
126
126
|
# set enable_dns_support to true.
|
127
127
|
#
|
128
|
-
attribute :enable_dns_hostnames, equal_to: [
|
128
|
+
attribute :enable_dns_hostnames, equal_to: [true, false]
|
129
129
|
|
130
130
|
attribute :vpc_id, kind_of: String, aws_id_attribute: true, default: lazy {
|
131
131
|
name =~ /^vpc-[a-f0-9]+$/ ? name : nil
|
@@ -141,6 +141,6 @@ class Chef::Resource::AwsVpc < Chef::Provisioning::AWSDriver::AWSResourceWithEnt
|
|
141
141
|
def exists?(result)
|
142
142
|
return true if result.data
|
143
143
|
rescue ::Aws::EC2::Errors::InvalidVpcIDNotFound
|
144
|
-
|
144
|
+
false
|
145
145
|
end
|
146
146
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_resource_with_entry"
|
2
2
|
|
3
3
|
#
|
4
4
|
# An AWS peering connection, specifying which VPC to peer.
|
@@ -15,7 +15,7 @@ class Chef::Resource::AwsVpcPeeringConnection < Chef::Provisioning::AWSDriver::A
|
|
15
15
|
aws_sdk_type ::Aws::EC2::VpcPeeringConnection
|
16
16
|
actions :accept, :create, :destroy, :purge, :nothing
|
17
17
|
|
18
|
-
require
|
18
|
+
require "chef/resource/aws_vpc"
|
19
19
|
|
20
20
|
#
|
21
21
|
# The name of this peering connection.
|
@@ -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: [
|
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: [
|
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
@@ -4,39 +4,39 @@
|
|
4
4
|
# AWS objects and clean them up.
|
5
5
|
#
|
6
6
|
module AWSSupport
|
7
|
-
require
|
7
|
+
require "cheffish/rspec/chef_run_support"
|
8
8
|
def self.extended(other)
|
9
9
|
other.extend Cheffish::RSpec::ChefRunSupport
|
10
10
|
end
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
12
|
+
require "chef/provisioning/aws_driver"
|
13
|
+
require "aws_support/matchers/create_an_aws_object"
|
14
|
+
require "aws_support/matchers/update_an_aws_object"
|
15
|
+
require "aws_support/matchers/destroy_an_aws_object"
|
16
|
+
require "aws_support/matchers/have_aws_object_tags"
|
17
|
+
require "aws_support/matchers/match_an_aws_object"
|
18
|
+
require "aws_support/delayed_stream"
|
19
|
+
require "chef/provisioning/aws_driver/resources"
|
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
|
24
|
-
require
|
25
|
-
require
|
23
|
+
require "aws-sdk"
|
24
|
+
require "aws_support/deep_matcher/matchable_object"
|
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
|
-
vpcs = driver.ec2.describe_vpcs(
|
33
|
+
vpcs = driver.ec2.describe_vpcs(filters: [{ name: "tag-value", values: ["test_vpc"] }])[:vpcs]
|
34
34
|
vpcs.each do |vpc|
|
35
35
|
aws_vpc vpc.vpc_id do
|
36
36
|
action :purge
|
37
37
|
end
|
38
38
|
end
|
39
|
-
aws_key_pair
|
39
|
+
aws_key_pair "test_key_pair" do
|
40
40
|
action :purge
|
41
41
|
end
|
42
42
|
end.converge
|
@@ -44,41 +44,41 @@ module AWSSupport
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def setup_public_vpc
|
47
|
-
aws_vpc
|
48
|
-
cidr_block
|
47
|
+
aws_vpc "test_vpc" do
|
48
|
+
cidr_block "10.0.0.0/16"
|
49
49
|
internet_gateway true
|
50
50
|
enable_dns_hostnames true
|
51
51
|
# TODO : uncomment this when fix main routes in aws_vpc resource as per new version
|
52
52
|
# main_routes '0.0.0.0/0' => :internet_gateway
|
53
53
|
end
|
54
54
|
|
55
|
-
aws_key_pair
|
55
|
+
aws_key_pair "test_key_pair" do
|
56
56
|
allow_overwrite true
|
57
57
|
end
|
58
58
|
|
59
59
|
before :context do
|
60
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(
|
61
|
+
image = driver.ec2.describe_images(filters: [{ name: "name", values: ["test_machine_image"] }]).first
|
62
62
|
image.delete unless image
|
63
63
|
|
64
|
-
default_sg = test_vpc.aws_object.security_groups(
|
64
|
+
default_sg = test_vpc.aws_object.security_groups(filters: [{ name: "group-name", values: ["default"] }]).first
|
65
65
|
recipe do
|
66
66
|
aws_security_group default_sg do
|
67
|
-
inbound_rules
|
67
|
+
inbound_rules "0.0.0.0/0" => 22
|
68
68
|
end
|
69
69
|
end.converge
|
70
70
|
end
|
71
71
|
|
72
|
-
aws_security_group
|
73
|
-
vpc
|
74
|
-
inbound_rules
|
75
|
-
outbound_rules [
|
72
|
+
aws_security_group "test_security_group" do
|
73
|
+
vpc "test_vpc"
|
74
|
+
inbound_rules "0.0.0.0/0" => [22, 80]
|
75
|
+
outbound_rules [22, 80] => "0.0.0.0/0"
|
76
76
|
end
|
77
77
|
|
78
|
-
azs = driver.ec2_client.describe_availability_zones.availability_zones.map
|
79
|
-
aws_subnet
|
80
|
-
vpc
|
81
|
-
cidr_block
|
78
|
+
azs = driver.ec2_client.describe_availability_zones.availability_zones.map(&:zone_name)
|
79
|
+
aws_subnet "test_public_subnet" do
|
80
|
+
vpc "test_vpc"
|
81
|
+
cidr_block "10.0.0.0/24"
|
82
82
|
map_public_ip_on_launch true
|
83
83
|
availability_zone azs.first
|
84
84
|
end
|
@@ -98,9 +98,9 @@ module AWSSupport
|
|
98
98
|
module_eval(&block)
|
99
99
|
end
|
100
100
|
|
101
|
-
if ENV[
|
102
|
-
aws_driver = Chef::Provisioning.driver_for_url(ENV[
|
103
|
-
when_the_repository "exists #{description ? "and #{description}" :
|
101
|
+
if ENV["AWS_TEST_DRIVER"] && !ENV["AWS_TEST_DRIVER"].empty?
|
102
|
+
aws_driver = Chef::Provisioning.driver_for_url(ENV["AWS_TEST_DRIVER"])
|
103
|
+
when_the_repository "exists #{description ? "and #{description}" : ''}", *tags, &context_block
|
104
104
|
else
|
105
105
|
skip "AWS_TEST_DRIVER not set ... cannot run AWS tests. Set AWS_TEST_DRIVER=aws or aws:profile:region to run tests that hit AWS." do
|
106
106
|
context description, *tags, &context_block
|
@@ -126,7 +126,7 @@ module AWSSupport
|
|
126
126
|
# in the order declared, and destroyed in reverse order.
|
127
127
|
#
|
128
128
|
aws_resources = Chef::Provisioning::AWSDriver::Resources.constants
|
129
|
-
aws_resources.map! {|r| Chef::Provisioning::AWSDriver::Resources.const_get(r) }
|
129
|
+
aws_resources.map! { |r| Chef::Provisioning::AWSDriver::Resources.const_get(r) }
|
130
130
|
|
131
131
|
aws_resources += [Chef::Resource::Machine, Chef::Resource::MachineImage, Chef::Resource::MachineBatch, Chef::Resource::LoadBalancer]
|
132
132
|
aws_resources.each do |resource_class|
|
@@ -154,9 +154,9 @@ module AWSSupport
|
|
154
154
|
end
|
155
155
|
begin
|
156
156
|
resource.converge
|
157
|
-
rescue
|
158
|
-
puts "ERROR #{
|
159
|
-
puts
|
157
|
+
rescue StandardError
|
158
|
+
puts "ERROR #{$ERROR_INFO}"
|
159
|
+
puts $ERROR_INFO.backtrace.join("\n")
|
160
160
|
raise
|
161
161
|
end
|
162
162
|
end
|
@@ -175,7 +175,7 @@ module AWSSupport
|
|
175
175
|
after :example do
|
176
176
|
# Close up delayed streams so they don't print out their garbage later in the run
|
177
177
|
unless chef_config[:include_output_after_example]
|
178
|
-
delayed_streams.each
|
178
|
+
delayed_streams.each(&:close)
|
179
179
|
end
|
180
180
|
|
181
181
|
# Destroy any objects we know got created during the test
|
@@ -205,19 +205,19 @@ module AWSSupport
|
|
205
205
|
Chef::Provisioning::AWSDriver::Resources.constants.each do |resource_class|
|
206
206
|
resource_class = Chef::Provisioning::AWSDriver::Resources.const_get(resource_class)
|
207
207
|
resource_name = resource_class.resource_name
|
208
|
-
define_method("update_an_#{resource_name}") do |name, expected_updates={}, &block|
|
208
|
+
define_method("update_an_#{resource_name}") do |name, expected_updates = {}, &block|
|
209
209
|
AWSSupport::Matchers::UpdateAnAWSObject.new(self, resource_class, name, expected_updates, block)
|
210
210
|
end
|
211
|
-
define_method("create_an_#{resource_name}") do |name, expected_values={}, &block|
|
211
|
+
define_method("create_an_#{resource_name}") do |name, expected_values = {}, &block|
|
212
212
|
AWSSupport::Matchers::CreateAnAWSObject.new(self, resource_class, name, expected_values, block)
|
213
213
|
end
|
214
|
-
define_method("have_#{resource_name}_tags") do |name, expected_tags={}|
|
214
|
+
define_method("have_#{resource_name}_tags") do |name, expected_tags = {}|
|
215
215
|
AWSSupport::Matchers::HaveAWSObjectTags.new(self, resource_class, name, expected_tags)
|
216
216
|
end
|
217
|
-
define_method("destroy_an_#{resource_name}") do |name,
|
217
|
+
define_method("destroy_an_#{resource_name}") do |name, _expected_values = {}|
|
218
218
|
AWSSupport::Matchers::DestroyAnAWSObject.new(self, resource_class, name)
|
219
219
|
end
|
220
|
-
define_method("match_an_#{resource_name}") do |name, expected_values={}, &block|
|
220
|
+
define_method("match_an_#{resource_name}") do |name, expected_values = {}, &block|
|
221
221
|
AWSSupport::Matchers::MatchAnAWSObject.new(self, resource_class, name, expected_values, block)
|
222
222
|
end
|
223
223
|
end
|
@@ -256,12 +256,11 @@ module AWSSupport
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def default_vpc
|
259
|
-
@default_vpc ||= driver.ec2.describe_vpcs(
|
259
|
+
@default_vpc ||= driver.ec2.describe_vpcs(filters: [{ name: "isDefault", values: ["true"] }])[:vpcs].first
|
260
260
|
end
|
261
261
|
|
262
262
|
def driver
|
263
263
|
self.class.driver
|
264
264
|
end
|
265
265
|
end
|
266
|
-
|
267
266
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "cheffish/rspec/recipe_run_wrapper"
|
2
2
|
|
3
3
|
module AWSSupport
|
4
4
|
class AWSResourceRunWrapper < Cheffish::RSpec::RecipeRunWrapper
|
5
5
|
def initialize(example, resource_type, name, &properties)
|
6
6
|
super(example.chef_config) do
|
7
|
-
if properties && properties.parameters.
|
7
|
+
if properties && !properties.parameters.empty?
|
8
8
|
public_send(resource_type, name) { instance_exec(example, &properties) }
|
9
9
|
else
|
10
10
|
public_send(resource_type, name, &properties)
|
@@ -5,8 +5,7 @@ module AWSSupport
|
|
5
5
|
# cache the result, which is then returned verbatim from failure_message.
|
6
6
|
#
|
7
7
|
module DeepMatcher
|
8
|
-
|
9
|
-
require 'aws_support/deep_matcher/match_values_failure_messages'
|
8
|
+
require "aws_support/deep_matcher/match_values_failure_messages"
|
10
9
|
|
11
10
|
include MatchValuesFailureMessages
|
12
11
|
|
@@ -33,7 +32,7 @@ module AWSSupport
|
|
33
32
|
#
|
34
33
|
# @return A failure message, or empty string if it does not fail.
|
35
34
|
#
|
36
|
-
def match_failure_messages(
|
35
|
+
def match_failure_messages(_actual, _identifier = "value")
|
37
36
|
raise NotImplementedError, :match_failure_messages
|
38
37
|
end
|
39
38
|
end
|