lib/kitchen/driver/ec2.rb in kitchen-ec2-1.0.1 vs lib/kitchen/driver/ec2.rb in kitchen-ec2-1.1.0
- old
+ new
@@ -82,13 +82,13 @@
required_config :aws_ssh_key_id
def initialize(*args, &block)
super
- # Access these so they are eagerly loaded (since we'll reference them later)
- ::Aws::EC2::Client # rubocop:disable Lint/Void
- ::Aws::EC2::Resource # rubocop:disable Lint/Void
+ # AWS Ruby SDK loading isn't thread safe, so as soon as we know we're
+ # going to use EC2, autoload it. Seems to have been fixed in Ruby 2.3+
+ ::Aws.eager_autoload! unless RUBY_VERSION.to_f >= 2.3
end
def self.validation_warn(driver, old_key, new_key)
driver.warn "WARN: The driver[#{driver.class.name}] config key `#{old_key}` " \
"is deprecated, please use `#{new_key}`"
@@ -360,14 +360,16 @@
response = ec2.client.request_spot_instances(request_data)
response[:spot_instance_requests][0][:spot_instance_request_id]
end
def tag_server(server)
- tags = []
- config[:tags].each do |k, v|
- tags << { :key => k, :value => v }
+ if config[:tags]
+ tags = []
+ config[:tags].each do |k, v|
+ tags << { :key => k, :value => v }
+ end
+ server.create_tags(:tags => tags)
end
- server.create_tags(:tags => tags)
end
# Normally we could use `server.wait_until_running` but we actually need
# to check more than just the instance state
def wait_until_ready(server, state)