# Buggy code
def ensure_tags(conn, module, subnet, tags, purge_tags):
    changed = False

    filters = ansible_dict_to_boto3_filter_list(
        {"resource-id": subnet["id"], "resource-type": "subnet"}
    )
    try:
        cur_tags = conn.describe_tags(Filters=filters)
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg="Couldn't describe tags")

    to_update, to_delete = compare_aws_tags(
        boto3_tag_list_to_ansible_dict(cur_tags.get("Tags")), tags, purge_tags
    )

    if to_update:
        try:
            if not module.check_mode:
                conn.create_tags(
                    Resources=[subnet["id"]],
                    Tags=ansible_dict_to_boto3_tag_list(to_update),
                )

            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't create tags")

    if to_delete:
        try:
            if not module.check_mode:
                tags_list = []
                for key in to_delete:
                    tags_list.append({"Key": key})

                conn.delete_tags(Resources=[subnet["id"]], Tags=tags_list)

            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't delete tags")

    return changed


# 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 ensure_tags(conn, module, subnet, tags, purge_tags, start_time):
    changed = False

    filters = ansible_dict_to_boto3_filter_list(
        {"resource-id": subnet["id"], "resource-type": "subnet"}
    )
    try:
        cur_tags = conn.describe_tags(Filters=filters)
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg="Couldn't describe tags")

    to_update, to_delete = compare_aws_tags(
        boto3_tag_list_to_ansible_dict(cur_tags.get("Tags")), tags, purge_tags
    )

    if to_update:
        try:
            if not module.check_mode:
                AWSRetry.exponential_backoff(
                    catch_extra_error_codes=["InvalidSubnetID.NotFound"]
                )(conn.create_tags)(
                    Resources=[subnet["id"]],
                    Tags=ansible_dict_to_boto3_tag_list(to_update),
                )

            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't create tags")

    if to_delete:
        try:
            if not module.check_mode:
                tags_list = []
                for key in to_delete:
                    tags_list.append({"Key": key})

                AWSRetry.exponential_backoff(
                    catch_extra_error_codes=["InvalidSubnetID.NotFound"]
                )(conn.delete_tags)(Resources=[subnet["id"]], Tags=tags_list)

            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't delete tags")

    if module.params["wait"] and not module.check_mode:
        # Wait for tags to be updated
        filters = [
            {"Name": "tag:{0}".format(k), "Values": [v]} for k, v in tags.items()
        ]
        handle_waiter(
            conn,
            module,
            "subnet_exists",
            {"SubnetIds": [subnet["id"]], "Filters": filters},
            start_time,
        )

    return changed