Skip to content

Commit

Permalink
Wait for VPC creation before waiting for availability (on creation)
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Feb 25, 2021
1 parent 4c6d23c commit 67a51b0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion plugins/modules/ec2_vpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ def get_classic_link_with_backoff(connection, vpc_id):
return False


def wait_for_vpc_to_exist(module, connection, **params):
# wait for vpc to be available
try:
get_waiter(connection, 'vpc_exists').wait(**params)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Unable to wait for VPC creation.")


def wait_for_vpc(module, connection, **params):
# wait for vpc to be available
try:
Expand Down Expand Up @@ -327,7 +335,13 @@ def create_vpc(connection, module, cidr_block, tenancy):
module.fail_json_aws(e, "Failed to create the VPC")

# wait up to 30 seconds for vpc to exist
wait_for_vpc(
wait_for_vpc_to_exist(
module, connection,
VpcIds=[vpc_obj['Vpc']['VpcId']],
WaiterConfig=dict(MaxAttempts=30)
)
# Wait for the VPC to enter an 'Available' State
wait_for_vpc_to_exist(
module, connection,
VpcIds=[vpc_obj['Vpc']['VpcId']],
WaiterConfig=dict(MaxAttempts=30)
Expand Down

0 comments on commit 67a51b0

Please sign in to comment.