lib/kitchen/driver/ec2.rb in kitchen-ec2-3.10.0 vs lib/kitchen/driver/ec2.rb in kitchen-ec2-3.10.1
- old
+ new
@@ -283,10 +283,10 @@
end
end
# If we are going to clean up an automatic security group, we need
# to wait for the instance to shut down. This slightly breaks the
# subsystem encapsulation, sorry not sorry.
- if state[:auto_security_group_id] && server
+ if state[:auto_security_group_id] && server && ec2.instance_exists?(state[:server_id])
server.wait_until_terminated do |waiter|
waiter.max_attempts = config[:retryable_tries]
waiter.delay = config[:retryable_sleep]
waiter.before_attempt do |attempts|
info "Waited #{attempts * waiter.delay}/#{waiter.delay * waiter.max_attempts}s for instance <#{server.id}> to terminate."