lib/kitchen/driver/ec2.rb in kitchen-ec2-3.2.0 vs lib/kitchen/driver/ec2.rb in kitchen-ec2-3.3.0
- old
+ new
@@ -275,11 +275,11 @@
fetch_windows_admin_password(server, state)
end
info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
instance.transport.connection(state).wait_until_ready
- create_ec2_json(state) if instance.provisioner.name =~ /chef/
+ create_ec2_json(state) if instance.provisioner.name =~ /chef/i
debug("ec2:create '#{state[:hostname]}'")
rescue Exception
# Clean up any auto-created security groups or keys on the way out.
delete_security_group(state)
delete_key(state)
@@ -452,19 +452,20 @@
end
configs = expanded.flatten
expanded = []
end
+ errs = []
configs.each do |conf|
begin
@config = conf
return submit_spot(state)
- rescue
+ rescue => e
+ errs.append(e)
end
end
-
- raise "Could not create a spot"
+ raise ["Could not create a spot instance:", errs].flatten.join("\n")
end
def submit_spot(state)
debug("Creating EC2 Spot Instance..")
@@ -786,9 +787,10 @@
subnets.first.vpc_id
elsif config[:subnet_filter]
subnets = ec2.client.describe_subnets(filters: [{ name: "tag:#{config[:subnet_filter][:tag]}", values: [config[:subnet_filter][:value]] }]).subnets
raise "Subnets with tag '#{config[:subnet_filter][:tag]}=#{config[:subnet_filter][:value]}' not found during security group creation" if subnets.empty?
+
subnets.first.vpc_id
else
# Try to check for a default VPC.
vpcs = ec2.client.describe_vpcs(filters: [{ name: "isDefault", values: ["true"] }]).vpcs
if vpcs.empty?