kitchen-ec2 3.9.0 → 3.10.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: aac8aebec145ee67e00276453fd2f8a1aaae0466d58bec03ffdc8b368f001118
4
- data.tar.gz: f14c9b4f85a0ebd1bf5c6398efc54b93e195e465ef4fc1c944688f96f53f1d39
3
+ metadata.gz: b5acaa7d4d497244e97e35e4d8c44f1b0a8771100dfb0ef01cae937a7904a853
4
+ data.tar.gz: 92a4bb2ffeb6c84295fc6432e0c0852e63e11f1a4cbea7ae4fad54888ad9869e
5
5
  SHA512:
6
- metadata.gz: d1e8f020cde0872c27abade96517dae1dcafa5d50aa4b08245ec928adfc024e309cc1977e5bdaebb30f3dfcea1f463ee01dabfe62baf4a0640b8bce527aa80b4
7
- data.tar.gz: 958a08022889c1bef5e0becc8cd75d53b5a0cd68445043c0c934bdc9a03822afcd9cc6f6dc49f15fe63928933f61f6d383d3b3bd3b7ad278d851f2c4957726a1
6
+ metadata.gz: fb7fc3f4d93a893455e274f0744c510526a79c2bd997bf6ef712f9e7774ab13a077b2c038402d7c41eaf8610f7b0bff9abeddddc5633b36c2e1142bfe72c4779
7
+ data.tar.gz: 44f07e5fb729c8fd106e3df0030a7d267322ebd80220f19f115e2f8addc6148a1ebd5c2da05bb4e5f84867c74b1889a4131881183f8f89ed5f67bde776e7ac7d
@@ -261,13 +261,14 @@ module Kitchen
261
261
 
262
262
  info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
263
263
  instance.transport.connection(state).wait_until_ready
264
+ attach_network_interface(state) unless config[:elastic_network_interface_id].nil?
264
265
  create_ec2_json(state) if /chef/i.match?(instance.provisioner.name)
265
266
  debug("ec2:create '#{state[:hostname]}'")
266
- rescue Exception
267
+ rescue Exception => e
267
268
  # Clean up any auto-created security groups or keys on the way out.
268
269
  delete_security_group(state)
269
270
  delete_key(state)
270
- raise
271
+ raise "#{e.message} in the specified region #{config[:region]}. Please check this AMI is available in this region."
271
272
  end
272
273
 
273
274
  def destroy(state)
@@ -824,6 +825,31 @@ module Kitchen
824
825
  state[:ssh_key] = key_path
825
826
  end
826
827
 
828
+ def attach_network_interface(state)
829
+ info("Attaching Network interface <#{config[:elastic_network_interface_id]}> with the instance <#{state[:server_id]}> .")
830
+ client = ::Aws::EC2::Client.new(region: config[:region])
831
+ begin
832
+ check_eni = client.describe_network_interface_attribute({
833
+ attribute: "attachment",
834
+ network_interface_id: config[:elastic_network_interface_id],
835
+ })
836
+ if check_eni.attachment.nil?
837
+ unless state[:server_id].nil?
838
+ client.attach_network_interface({
839
+ device_index: 1,
840
+ instance_id: state[:server_id],
841
+ network_interface_id: config[:elastic_network_interface_id],
842
+ })
843
+ info("Attached Network interface <#{config[:elastic_network_interface_id]}> with the instance <#{state[:server_id]}> .")
844
+ end
845
+ else
846
+ puts "ENI #{config[:elastic_network_interface_id]} already attached."
847
+ end
848
+ rescue ::Aws::EC2::Errors::InvalidNetworkInterfaceIDNotFound => e
849
+ warn("#{e}")
850
+ end
851
+ end
852
+
827
853
  # Clean up a temporary security group for this instance.
828
854
  #
829
855
  # @api private
@@ -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.9.0".freeze
24
+ EC2_VERSION = "3.10.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.9.0
4
+ version: 3.10.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-04-10 00:00:00.000000000 Z
11
+ date: 2021-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.4.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3'
22
+ version: '4'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.4.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3'
32
+ version: '4'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: aws-sdk-ec2
35
35
  requirement: !ruby/object:Gem::Requirement