kitchen-ec2 3.9.0 → 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/ec2.rb +28 -2
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5acaa7d4d497244e97e35e4d8c44f1b0a8771100dfb0ef01cae937a7904a853
|
4
|
+
data.tar.gz: 92a4bb2ffeb6c84295fc6432e0c0852e63e11f1a4cbea7ae4fad54888ad9869e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb7fc3f4d93a893455e274f0744c510526a79c2bd997bf6ef712f9e7774ab13a077b2c038402d7c41eaf8610f7b0bff9abeddddc5633b36c2e1142bfe72c4779
|
7
|
+
data.tar.gz: 44f07e5fb729c8fd106e3df0030a7d267322ebd80220f19f115e2f8addc6148a1ebd5c2da05bb4e5f84867c74b1889a4131881183f8f89ed5f67bde776e7ac7d
|
data/lib/kitchen/driver/ec2.rb
CHANGED
@@ -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
|
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.
|
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-
|
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: '
|
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: '
|
32
|
+
version: '4'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: aws-sdk-ec2
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|