# Buggy code
def create_subnet(conn, module, vpc_id, cidr, ipv6_cidr=None, az=None):
    wait = module.params["wait"]
    wait_timeout = module.params["wait_timeout"]

    params = dict(VpcId=vpc_id, CidrBlock=cidr)

    if ipv6_cidr:
        params["Ipv6CidrBlock"] = ipv6_cidr

    if az:
        params["AvailabilityZone"] = az

    try:
        subnet = get_subnet_info(conn.create_subnet(**params))
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg="Couldn't create subnet")

    # Sometimes AWS takes its time to create a subnet and so using
    # new subnets's id to do things like create tags results in
    # exception.
    if wait and subnet.get("state") != "available":
        delay = 5
        max_attempts = wait_timeout / delay
        waiter_config = dict(Delay=delay, MaxAttempts=max_attempts)
        waiter = conn.get_waiter("subnet_available")
        try:
            waiter.wait(SubnetIds=[subnet["id"]], WaiterConfig=waiter_config)
            subnet["state"] = "available"
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json(
                msg="Create subnet action timed out waiting for Subnet to become available."
            )

    return subnet


# Traceback (ClientError)
Traceback (most recent call last):
File "/tmp/ansible_dPE6PL/ansible_module_ec2_vpc_net.py", line 203, in get_vpc
classic_link = connection.describe_vpc_classic_link(VpcIds=[vpc_id])['Vpcs'][0].get('ClassicLinkEnabled')
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 317, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 615, in _make_api_call
raise error_class(parsed_response, operation_name)
ClientError: An error occurred (InvalidVpcID.NotFound) when calling the DescribeVpcClassicLink operation: The vpc ID 'vpc-1b2bda60' does not exist

# Fixed code
def create_subnet(conn, module, vpc_id, cidr, ipv6_cidr=None, az=None, start_time=None):
    wait = module.params["wait"]
    wait_timeout = module.params["wait_timeout"]

    params = dict(VpcId=vpc_id, CidrBlock=cidr)

    if ipv6_cidr:
        params["Ipv6CidrBlock"] = ipv6_cidr

    if az:
        params["AvailabilityZone"] = az

    try:
        subnet = get_subnet_info(conn.create_subnet(**params))
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg="Couldn't create subnet")

    # Sometimes AWS takes its time to create a subnet and so using
    # new subnets's id to do things like create tags results in
    # exception.
    if wait and subnet.get("state") != "available":
        handle_waiter(
            conn, module, "subnet_exists", {"SubnetIds": [subnet["id"]]}, start_time
        )
        try:
            conn.get_waiter("subnet_available").wait(
                SubnetIds=[subnet["id"]],
                WaiterConfig=wait_config(wait_timeout, start_time),
            )
            subnet["state"] = "available"
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(
                e,
                "Create subnet action timed out waiting for subnet to become available",
            )

    return subnet