# Buggy code
def ensure_ipv6_cidr_block(conn, module, subnet, ipv6_cidr, check_mode):
    changed = False

    if subnet["ipv6_association_id"] and not ipv6_cidr:
        if not check_mode:
            disassociate_ipv6_cidr(conn, module, subnet)
        changed = True

    if ipv6_cidr:
        filters = ansible_dict_to_boto3_filter_list(
            {
                "ipv6-cidr-block-association.ipv6-cidr-block": ipv6_cidr,
                "vpc-id": subnet["vpc_id"],
            }
        )

        try:
            check_subnets = get_subnet_info(
                describe_subnets_with_backoff(conn, Filters=filters)
            )
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't get subnet info")

        if check_subnets and check_subnets[0]["ipv6_cidr_block"]:
            module.fail_json(
                msg="The IPv6 CIDR '{0}' conflicts with another subnet".format(
                    ipv6_cidr
                )
            )

        if subnet["ipv6_association_id"]:
            if not check_mode:
                disassociate_ipv6_cidr(conn, module, subnet)
            changed = True

        try:
            if not check_mode:
                associate_resp = conn.associate_subnet_cidr_block(
                    SubnetId=subnet["id"], Ipv6CidrBlock=ipv6_cidr
                )
            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(
                e,
                msg="Couldn't associate ipv6 cidr {0} to {1}".format(
                    ipv6_cidr, subnet["id"]
                ),
            )

        if associate_resp.get("Ipv6CidrBlockAssociation", {}).get("AssociationId"):
            subnet["ipv6_association_id"] = associate_resp["Ipv6CidrBlockAssociation"][
                "AssociationId"
            ]
            subnet["ipv6_cidr_block"] = associate_resp["Ipv6CidrBlockAssociation"][
                "Ipv6CidrBlock"
            ]
            if subnet["ipv6_cidr_block_association_set"]:
                subnet["ipv6_cidr_block_association_set"][0] = camel_dict_to_snake_dict(
                    associate_resp["Ipv6CidrBlockAssociation"]
                )
            else:
                subnet["ipv6_cidr_block_association_set"].append(
                    camel_dict_to_snake_dict(associate_resp["Ipv6CidrBlockAssociation"])
                )

    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_ipv6_cidr_block(conn, module, subnet, ipv6_cidr, check_mode, start_time):
    wait = module.params["wait"]
    changed = False

    if subnet["ipv6_association_id"] and not ipv6_cidr:
        if not check_mode:
            disassociate_ipv6_cidr(conn, module, subnet, start_time)
        changed = True

    if ipv6_cidr:
        filters = ansible_dict_to_boto3_filter_list(
            {
                "ipv6-cidr-block-association.ipv6-cidr-block": ipv6_cidr,
                "vpc-id": subnet["vpc_id"],
            }
        )

        try:
            check_subnets = get_subnet_info(
                describe_subnets_with_backoff(conn, Filters=filters)
            )
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(e, msg="Couldn't get subnet info")

        if check_subnets and check_subnets[0]["ipv6_cidr_block"]:
            module.fail_json(
                msg="The IPv6 CIDR '{0}' conflicts with another subnet".format(
                    ipv6_cidr
                )
            )

        if subnet["ipv6_association_id"]:
            if not check_mode:
                disassociate_ipv6_cidr(conn, module, subnet, start_time)
            changed = True

        try:
            if not check_mode:
                associate_resp = conn.associate_subnet_cidr_block(
                    SubnetId=subnet["id"], Ipv6CidrBlock=ipv6_cidr
                )
            changed = True
        except (
            botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError,
        ) as e:
            module.fail_json_aws(
                e,
                msg="Couldn't associate ipv6 cidr {0} to {1}".format(
                    ipv6_cidr, subnet["id"]
                ),
            )
        else:
            if not check_mode and wait:
                filters = ansible_dict_to_boto3_filter_list(
                    {
                        "ipv6-cidr-block-association.state": ["associated"],
                        "vpc-id": subnet["vpc_id"],
                    }
                )
                handle_waiter(
                    conn,
                    module,
                    "subnet_exists",
                    {"SubnetIds": [subnet["id"]], "Filters": filters},
                    start_time,
                )

        if associate_resp.get("Ipv6CidrBlockAssociation", {}).get("AssociationId"):
            subnet["ipv6_association_id"] = associate_resp["Ipv6CidrBlockAssociation"][
                "AssociationId"
            ]
            subnet["ipv6_cidr_block"] = associate_resp["Ipv6CidrBlockAssociation"][
                "Ipv6CidrBlock"
            ]
            if subnet["ipv6_cidr_block_association_set"]:
                subnet["ipv6_cidr_block_association_set"][0] = camel_dict_to_snake_dict(
                    associate_resp["Ipv6CidrBlockAssociation"]
                )
            else:
                subnet["ipv6_cidr_block_association_set"].append(
                    camel_dict_to_snake_dict(associate_resp["Ipv6CidrBlockAssociation"])
                )

    return changed