kitchen-ec2 3.11.1 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8db131041ca62ab75984ff3a397e349838a750a6041bb4e57467e6bd74918b3f
4
- data.tar.gz: 171e39a4ff4eafb0bdf80789c517813360c8438e992329c76562815d3cf31719
3
+ metadata.gz: f76f759771ac4c8597dacffcf992e7d33fe1784c61be5ae6c84f00c77633b141
4
+ data.tar.gz: 324f1dd4944162dcd51bd6569dbfbabe9701ec58f6c1f8bf02ff96811bf48c65
5
5
  SHA512:
6
- metadata.gz: ed0a53d4b538412b96dbf872bf7a1dbebd0c64a65ed0620d506164296aade28893d410fb508a7073fa7a9ce7829f0a26afc88ecae1aecd2f972e3cea21bcaff6
7
- data.tar.gz: 0de4ad1727d5c286ae3d1fabc39d49b61b186dfbccfd6ba9e0275f85d3db00d9ccbf71ed1cfb10c4dd821b027836d6b3dcf3c2a0d7e75be895b21c9dd216b35d
6
+ metadata.gz: 48c946144405da7ec33817582d1115ac68dc76486307d86b8d7519a238d0aa0637d03152a0aad3b96fdfad25955e40eb96c513c862f7794f1ec4aeca3d029558
7
+ data.tar.gz: 136f94bcf170b07848f8bd7dd56d2918e38482003ece6d0da4029790651e60c1cd25ddd0e13749e6d90efdf6f6cf346f9d6d2eba17c45067db04ac8e4662558d
@@ -47,15 +47,19 @@ module Kitchen
47
47
  vpc_id = nil
48
48
  client = ::Aws::EC2::Client.new(region: config[:region])
49
49
  if config[:subnet_id].nil? && config[:subnet_filter]
50
- subnets = client.describe_subnets(
51
- filters: [
50
+ filters = [config[:subnet_filter]].flatten
51
+
52
+ r = { filters: [] }
53
+ filters.each do |subnet_filter|
54
+ r[:filters] <<
52
55
  {
53
- name: "tag:#{config[:subnet_filter][:tag]}",
54
- values: [config[:subnet_filter][:value]],
55
- },
56
- ]
57
- ).subnets
58
- raise "The subnet tagged '#{config[:subnet_filter][:tag]}:#{config[:subnet_filter][:value]}' does not exist!" unless subnets.any?
56
+ name: "tag:#{subnet_filter[:tag]}",
57
+ values: [subnet_filter[:value]],
58
+ }
59
+ end
60
+
61
+ subnets = client.describe_subnets(r).subnets
62
+ raise "Subnets with tags '#{filters}' not found during security group creation" if subnets.empty?
59
63
 
60
64
  # => Select the least-populated subnet if we have multiple matches
61
65
  subnet = subnets.max_by { |s| s[:available_ip_address_count] }
@@ -265,9 +265,8 @@ module Kitchen
265
265
  create_ec2_json(state) if /chef/i.match?(instance.provisioner.name)
266
266
  debug("ec2:create '#{state[:hostname]}'")
267
267
  rescue Exception => e
268
- # Clean up any auto-created security groups or keys on the way out.
269
- delete_security_group(state)
270
- delete_key(state)
268
+ # Clean up the instance and any auto-created security groups or keys on the way out.
269
+ destroy(state)
271
270
  raise "#{e.message} in the specified region #{config[:region]}. Please check this AMI is available in this region."
272
271
  end
273
272
 
@@ -433,15 +432,21 @@ module Kitchen
433
432
  else
434
433
  # => Enable cascading through matching subnets
435
434
  client = ::Aws::EC2::Client.new(region: config[:region])
436
- subnets = client.describe_subnets(
437
- filters: [
435
+
436
+ filters = [config[:subnet_filter]].flatten
437
+
438
+ r = { filters: [] }
439
+ filters.each do |subnet_filter|
440
+ r[:filters] <<
438
441
  {
439
- name: "tag:#{config[:subnet_filter][:tag]}",
440
- values: [config[:subnet_filter][:value]],
441
- },
442
- ]
443
- ).subnets
444
- raise "A subnet matching '#{config[:subnet_filter][:tag]}:#{config[:subnet_filter][:value]}' does not exist!" unless subnets.any?
442
+ name: "tag:#{subnet_filter[:tag]}",
443
+ values: [subnet_filter[:value]],
444
+ }
445
+ end
446
+
447
+ subnets = client.describe_subnets(r).subnets
448
+
449
+ raise "Subnets with tags '#{filters}' not found!" if subnets.empty?
445
450
 
446
451
  configs = subnets.map do |subnet|
447
452
  new_config = config.clone
@@ -751,8 +756,19 @@ module Kitchen
751
756
 
752
757
  subnets.first.vpc_id
753
758
  elsif config[:subnet_filter]
754
- subnets = ec2.client.describe_subnets(filters: [{ name: "tag:#{config[:subnet_filter][:tag]}", values: [config[:subnet_filter][:value]] }]).subnets
755
- raise "Subnets with tag '#{config[:subnet_filter][:tag]}=#{config[:subnet_filter][:value]}' not found during security group creation" if subnets.empty?
759
+ filters = [config[:subnet_filter]].flatten
760
+
761
+ r = { filters: [] }
762
+ filters.each do |subnet_filter|
763
+ r[:filters] << {
764
+ name: "tag:#{subnet_filter[:tag]}",
765
+ values: [subnet_filter[:value]],
766
+ }
767
+ end
768
+
769
+ subnets = ec2.client.describe_subnets(r).subnets
770
+
771
+ raise "Subnets with tags '#{filters}' not found during security group creation" if subnets.empty?
756
772
 
757
773
  subnets.first.vpc_id
758
774
  else
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for EC2 Test Kitchen driver
24
- EC2_VERSION = "3.11.1".freeze
24
+ EC2_VERSION = "3.12.0".freeze
25
25
  end
26
26
  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.11.1
4
+ version: 3.12.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: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.2.22
108
+ rubygems_version: 3.2.32
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: A Test Kitchen Driver for Amazon EC2