Help Center> DataArts Lake Formation> API Reference> Application Examples> Connecting External Services to LakeFormation
Updated on 2024-02-21 GMT+08:00

Connecting External Services to LakeFormation

Overview

This section describes how to connect external services to LakeFormation by calling APIs.

If a tenant plan to perform this operation, the tenant should completed service authorization on the LakeFormation console. For details about how to call APIs, see API Calling.

Prerequisites

The following information has been obtained:

Procedure

  1. Call the Creating an Instance API to create a LakeFormation instance and record the instance ID returned by the API.

    Example request:

    POST https://{endpoint}/v1/{project_id}/instances

    Body:

    {
        "name": "lakeformation",
        "charge_mode": "postPaid",
        "shared": "false",
        "specs": [
            {
                "spec_code": "lakeformation.unit.basic.qps",
                "stride_num": 1
            }
        ],
        "enterprise_project_id": "0"
    }

    Example response

    {
        "instance_id": "13677734-a4ee-43e2-9d11-30b8b2e32a95",
        "name": "lakeformation",
        "description": "",
        "enterprise_project_id": "0",
        "shared": false,
        "default_instance": false,
        "create_time": "2023-06-29T09:08:33.000+00:00",
        "update_time": "2023-06-29T09:08:34.000+00:00",
        "status": "RESOURCE_PREPARATION",
        "resource_progress": 25,
        "resource_expected_duration": 15,
        "in_recycle_bin": false,
        "tags": [],
        "specs": [
            {
                "spec_code": "lakeformation.unit.basic.qps",
                "stride_num": 1
            },
            {
                "spec_code": "lakeformation.unit.basic.metadata",
                "stride_num": 0
            }
        ]
    }

  2. Call the Querying Instance Details API to query the instance status. Wait until the instance status changes to RUNNING, indicating that the instance is created.

    Example request:

    GET https://{endpoint}/v1/{project_id}/instances/{instance_id}

    instance_id indicates the value of instance_id in the response of the request made in 1.

    Example response

    {
        "instance_id": "13677734-a4ee-43e2-9d11-30b8b2e32a95",
        "name": "lakeformation",
        "description": "",
        "enterprise_project_id": "0",
        "shared": false,
        "default_instance": false,
        "create_time": "2023-06-29T09:08:33.000+00:00",
        "update_time": "2023-06-29T09:08:34.000+00:00",
        "status": "RUNNING",
        "in_recycle_bin": false,
        "tags": [],
        "specs": [
            {
                "spec_code": "lakeformation.unit.basic.qps",
                "stride_num": 1
            },
            {
                "spec_code": "lakeformation.unit.basic.metadata",
                "stride_num": 0
            }
        ]
    }

  3. (Optional) If the current tenant creates a LakeFormation instance for the first time, the instance is automatically used as the default instance. The client can directly access the default instance or access the corresponding instance by specifying the instance ID. You can set a non-default instance as the default instance by calling the Seting an Default Instance API.

    Example request:

    POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/default

    instance_id indicates the value of instance_id in the response of the request made in 1.

  4. Call the Creating a Service Access Client API and select the VPC information corresponding to the client to create an access client. LakeFormation automatically creates a VPC endpoint and a DNS private domain name for the client to connect to the network.

    Example request:

    POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/access-clients

    instance_id indicates the value of instance_id in the response of the request made in 1.

    Body:

    {
        "name": "access-client",
        "vpc_id": "131fb837-37ae-4aa6-9e87-312919df659f",
        "subnet_id": "2fa7ec47-c7f6-4a81-8e77-1dd41121b726"
    }

    Example response

    {
        "id": "b73a9311-1ce9-48fe-b714-21bc41ce7b82",
        "name": "access-client",
        "access_mode": "SYSTEM",
        "status": "CREATING",
        "vpc_id": "131fb837-37ae-4aa6-9e87-312919df659f",
        "subnet_id": "2fa7ec47-c7f6-4a81-8e77-1dd41121b726"
    }

  5. Call the Obtaining Service Access Client Details API to query the status of the access client. Wait until the status changes to RUNNING, indicating that the access client is created. In addition, you can view details such as the access IP address and domain name in the details.

    Example request:

    GET https://{endpoint}/v1/{project_id}/instances/{instance_id}/access-clients/{client_id}

    • instance_id indicates the value of instance_id in the response of the request made in 1.
    • client_id indicates the value of id in the response of the request made in 4.

    Example response

    {
        "id": "b73a9311-1ce9-48fe-b714-21bc41ce7b82",
        "name": "access-client",
        "access_mode": "SYSTEM",
        "status": "RUNNING",
        "vpc_id": "131fb837-37ae-4aa6-9e87-312919df659f",
        "subnet_id": "2fa7ec47-c7f6-4a81-8e77-1dd41121b726",
        "access_connections": [
            {
                "vpcep_id": "f72c8034-df38-4dbc-bd5d-2f50531ba104",
                "ip": "10.0.0.6",
                "owner": "555d9e8999c94705be3d7edb70a3199a",
                "domain": "xxx.dalf-ed1c-b3070cba-baae-4220-b7ff-9b2bca043efb.apig-lakeformation.com"
            }
        ],
        "create_time": "2023-06-29T12:12:12.000+00:00"
    }

  6. Use the access IP address and instance ID obtained in the preceding step to access the metadata management API and obtain the catalog list. For details, see the APIs in Catalog Management.

    Example request:

    GET https://{endpoint}/v1/{project_id}/instances/{instance_id}/catalogs

    • endpoint: Use {instance_id}.lakeformation.lakecat.com. If the instance has been set as the default instance, use default-{project_id}.lakeformation.lakecat.com.
    • instance_id: value of instance_id in the response of the request made in 1. If the instance has been set as the default instance, use default as the instance ID.

    Request header example

    Host: lakeformation.lakecat.com

    Example response

    [
        {
            "catalog_name": "hive",
            "description": "Default catalog, for Hive",
            "location": "obs://lakeformation-555d9e8999c94705-xxx/ed1ce787-1671-4ce4-b84f-6f40ccb26752"
        }
    ]