kitchen-ec2 3.2.0 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 828a479cf1ebe8de5423fad1926bc74f1cb66ddc1a1b4f853977424e65dd4709
4
- data.tar.gz: 67851982c4d376be9ca701040e38d8e7b5cb308a7cf52cd0056da8f898558dcd
3
+ metadata.gz: 1132f5a8bcb58e6a8c4d38ad342ac2e38afeabbd51abf63b6980a6b4c9474339
4
+ data.tar.gz: 876fb813038936051338a3be5682fc6633b420aa6faa201b3156879bc9f29430
5
5
  SHA512:
6
- metadata.gz: 1165fa8225401552970c19983091d8cb38f234a08f9f84a68ebb45cdf05b5670271e92b780b9e8fa0fdecc1c18083e3702f3ddace3561a76628226d09f67ce26
7
- data.tar.gz: abe70ab29dacefda005ec11ffa0710841532e7f8407c203daf6bd782acb1c1da59d95c1c188bfca81cc20bd010d2ce7df5c6e78371eff0960f46dcbf3c885245
6
+ metadata.gz: ae1058987c9efd9e8b7e0f2e0fa152b0a7cefb297d82fb6ab50cc77e1ee84f59e7b9a7fb54b391e9a3b35ae3ee7f3ef704ab6edd7e8fb908c1abe90870cc2c3d
7
+ data.tar.gz: 5fd929e0e1752d3b7cd1ff5b1e83383be321c95569bc00fee8ab9ad19539e815a3a1d9f692c516550cf5d4da5f667e500bc2ea8d64704a0fc337152fe34744df
@@ -43,25 +43,26 @@ module Kitchen
43
43
  # can be passed in null, others need to be ommitted if they are null
44
44
  def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
45
45
  # Support for looking up security group id and subnet id using tags.
46
-
46
+ vpc_id = nil
47
+ client = ::Aws::EC2::Client.new(region: config[:region])
47
48
  if config[:subnet_id].nil? && config[:subnet_filter]
48
- config[:subnet_id] = ::Aws::EC2::Client
49
- .new(region: config[:region]).describe_subnets(
50
- filters: [
51
- {
52
- name: "tag:#{config[:subnet_filter][:tag]}",
53
- values: [config[:subnet_filter][:value]],
54
- },
55
- ]
56
- )[0][0].subnet_id
57
-
58
- if config[:subnet_id].nil?
59
- raise "The subnet tagged '#{config[:subnet_filter][:tag]}\
60
- #{config[:subnet_filter][:value]}' does not exist!"
61
- end
49
+ subnets = client.describe_subnets(
50
+ filters: [
51
+ {
52
+ name: "tag:#{config[:subnet_filter][:tag]}",
53
+ values: [config[:subnet_filter][:value]],
54
+ },
55
+ ]
56
+ ).subnets
57
+ raise "The subnet tagged '#{config[:subnet_filter][:tag]}:#{config[:subnet_filter][:value]}' does not exist!" unless subnets.any?
58
+
59
+ vpc_id = subnets[0].vpc_id
60
+ config[:subnet_id] = subnets[0].subnet_id
62
61
  end
63
62
 
64
63
  if config[:security_group_ids].nil? && config[:security_group_filter]
64
+ # => Grab the VPC in the case a Subnet ID rather than Filter was set
65
+ vpc_id ||= client.describe_subnets(subnet_ids: [config[:subnet_id]]).subnets[0].vpc_id
65
66
  security_groups = []
66
67
  filters = [config[:security_group_filter]].flatten
67
68
  filters.each do |sg_filter|
@@ -72,6 +73,10 @@ module Kitchen
72
73
  name: "group-name",
73
74
  values: [sg_filter[:name]],
74
75
  },
76
+ {
77
+ name: "vpc-id",
78
+ values: [vpc_id],
79
+ },
75
80
  ]
76
81
  end
77
82
 
@@ -81,13 +86,17 @@ module Kitchen
81
86
  name: "tag:#{sg_filter[:tag]}",
82
87
  values: [sg_filter[:value]],
83
88
  },
89
+ {
90
+ name: "vpc-id",
91
+ values: [vpc_id],
92
+ },
84
93
  ]
85
94
  end
86
95
 
87
- security_group = ::Aws::EC2::Client.new(region: config[:region]).describe_security_groups(r)[0][0]
96
+ security_group = client.describe_security_groups(r).security_groups
88
97
 
89
- if security_group
90
- security_groups.push(security_group.group_id)
98
+ if security_group.any?
99
+ security_group.each { |sg| security_groups.push(sg.group_id) }
91
100
  else
92
101
  raise "A Security Group matching the following filter could not be found:\n#{sg_filter}"
93
102
  end
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -13,7 +13,7 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/driver/aws/standard_platform"
16
+ require_relative "../standard_platform"
17
17
 
18
18
  module Kitchen
19
19
  module Driver
@@ -277,7 +277,7 @@ module Kitchen
277
277
 
278
278
  info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
279
279
  instance.transport.connection(state).wait_until_ready
280
- create_ec2_json(state) if instance.provisioner.name =~ /chef/
280
+ create_ec2_json(state) if instance.provisioner.name =~ /chef/i
281
281
  debug("ec2:create '#{state[:hostname]}'")
282
282
  rescue Exception
283
283
  # Clean up any auto-created security groups or keys on the way out.
@@ -454,15 +454,16 @@ module Kitchen
454
454
  expanded = []
455
455
  end
456
456
 
457
+ errs = []
457
458
  configs.each do |conf|
458
459
  begin
459
460
  @config = conf
460
461
  return submit_spot(state)
461
- rescue
462
+ rescue => e
463
+ errs.append(e)
462
464
  end
463
465
  end
464
-
465
- raise "Could not create a spot"
466
+ raise ["Could not create a spot instance:", errs].flatten.join("\n")
466
467
  end
467
468
 
468
469
  def submit_spot(state)
@@ -788,6 +789,7 @@ module Kitchen
788
789
  elsif config[:subnet_filter]
789
790
  subnets = ec2.client.describe_subnets(filters: [{ name: "tag:#{config[:subnet_filter][:tag]}", values: [config[:subnet_filter][:value]] }]).subnets
790
791
  raise "Subnets with tag '#{config[:subnet_filter][:tag]}=#{config[:subnet_filter][:value]}' not found during security group creation" if subnets.empty?
792
+
791
793
  subnets.first.vpc_id
792
794
  else
793
795
  # Try to check for a default VPC.
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
4
  #
5
- # Copyright:: 2016-2018, Chef Software, Inc.
5
+ # Copyright:: 2016-2020, Chef Software, Inc.
6
6
  # Copyright:: 2012-2018, Fletcher Nichol
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,6 +22,6 @@ module Kitchen
22
22
  module Driver
23
23
 
24
24
  # Version string for EC2 Test Kitchen driver
25
- EC2_VERSION = "3.2.0".freeze
25
+ EC2_VERSION = "3.3.0".freeze
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -168,14 +168,14 @@ dependencies:
168
168
  requirements:
169
169
  - - '='
170
170
  - !ruby/object:Gem::Version
171
- version: 0.13.3
171
+ version: 0.14.0
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - '='
177
177
  - !ruby/object:Gem::Version
178
- version: 0.13.3
178
+ version: 0.14.0
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: climate_control
181
181
  requirement: !ruby/object:Gem::Requirement