# Both min_count and max_count equal count parameter. This means the launch request is explicit (we want count, or fail) in how many instances we want.
# Both min_count and max_count equal count parameter. This means the launch request is explicit (we want count, or fail) in how many instances we want.
if count_remaining > 0:
try:
try:
res = ec2.run_instances(image, key_name = key_name,
res = ec2.run_instances(image, key_name = key_name,
min_count = count,
client_token=id,
max_count = count,
min_count = count_remaining,
max_count = count_remaining,
monitoring_enabled = monitoring,
monitoring_enabled = monitoring,
security_groups = [group_name],
security_groups = [group_name],
instance_type = instance_type,
instance_type = instance_type,
@ -259,16 +285,20 @@ def main():
if wait and wait_timeout <= time.time():
if wait and wait_timeout <= time.time():
# waiting took too long
# waiting took too long
module.fail_json(msg = "wait for instances running timeout on %s" % time.asctime())
module.fail_json(msg = "wait for instances running timeout on %s" % time.asctime())