|
|
@ -205,6 +205,7 @@ subnet:
|
|
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
from distutils.version import LooseVersion
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import botocore
|
|
|
|
import botocore
|
|
|
@ -253,16 +254,17 @@ def describe_subnets_with_backoff(client, **params):
|
|
|
|
return client.describe_subnets(**params)
|
|
|
|
return client.describe_subnets(**params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wait_config(wait_timeout, start_time):
|
|
|
|
def waiter_params(module, params, start_time):
|
|
|
|
remaining_wait_timeout = int(wait_timeout + start_time - time.time())
|
|
|
|
if LooseVersion(botocore.__version__) >= "1.7.0":
|
|
|
|
return {'Delay': 5, 'MaxAttempts': remaining_wait_timeout // 5}
|
|
|
|
remaining_wait_timeout = int(module.params['wait_timeout'] + start_time - time.time())
|
|
|
|
|
|
|
|
params['WaiterConfig'] = {'Delay': 5, 'MaxAttempts': remaining_wait_timeout // 5}
|
|
|
|
|
|
|
|
return params
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_waiter(conn, module, waiter_name, params, start_time):
|
|
|
|
def handle_waiter(conn, module, waiter_name, params, start_time):
|
|
|
|
params['WaiterConfig'] = wait_config(module.params['wait_timeout'], start_time)
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
get_waiter(conn, waiter_name).wait(
|
|
|
|
get_waiter(conn, waiter_name).wait(
|
|
|
|
**params
|
|
|
|
**waiter_params(module, params, start_time)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except botocore.exceptions.WaiterError as e:
|
|
|
|
except botocore.exceptions.WaiterError as e:
|
|
|
|
module.fail_json_aws(e, "Failed to wait for updates to complete")
|
|
|
|
module.fail_json_aws(e, "Failed to wait for updates to complete")
|
|
|
@ -295,8 +297,7 @@ def create_subnet(conn, module, vpc_id, cidr, ipv6_cidr=None, az=None, start_tim
|
|
|
|
handle_waiter(conn, module, 'subnet_exists', {'SubnetIds': [subnet['id']]}, start_time)
|
|
|
|
handle_waiter(conn, module, 'subnet_exists', {'SubnetIds': [subnet['id']]}, start_time)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
conn.get_waiter('subnet_available').wait(
|
|
|
|
conn.get_waiter('subnet_available').wait(
|
|
|
|
SubnetIds=[subnet['id']],
|
|
|
|
**waiter_params(module, {'SubnetIds': [subnet['id']]}, start_time)
|
|
|
|
WaiterConfig=wait_config(wait_timeout, start_time)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
subnet['state'] = 'available'
|
|
|
|
subnet['state'] = 'available'
|
|
|
|
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
|
|
|
|
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
|
|
|
@ -577,6 +578,9 @@ def main():
|
|
|
|
if module.params.get('assign_instances_ipv6') and not module.params.get('ipv6_cidr'):
|
|
|
|
if module.params.get('assign_instances_ipv6') and not module.params.get('ipv6_cidr'):
|
|
|
|
module.fail_json(msg="assign_instances_ipv6 is True but ipv6_cidr is None or an empty string")
|
|
|
|
module.fail_json(msg="assign_instances_ipv6 is True but ipv6_cidr is None or an empty string")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if LooseVersion(botocore.__version__) < "1.7.0":
|
|
|
|
|
|
|
|
module.warn("botocore >= 1.7.0 is required to use wait_timeout for custom wait times")
|
|
|
|
|
|
|
|
|
|
|
|
region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True)
|
|
|
|
region, ec2_url, aws_connect_params = get_aws_connection_info(module, boto3=True)
|
|
|
|
connection = boto3_conn(module, conn_type='client', resource='ec2', region=region, endpoint=ec2_url, **aws_connect_params)
|
|
|
|
connection = boto3_conn(module, conn_type='client', resource='ec2', region=region, endpoint=ec2_url, **aws_connect_params)
|
|
|
|
|
|
|
|
|
|
|
|