This document is for security administrators and data engineers who need to
secure Knowledge Catalog (formerly Dataplex Universal Catalog) services. It explains how to use
VPC Service Controls to create service perimeters that protect your
Knowledge Catalog resources and mitigate data exfiltration risks.
For more information, see
[Overview of VPC Service Controls](https://docs.cloud.google.com/vpc-service-controls/docs/overview.md.txt).

## Supported features

When you secure Knowledge Catalog with a service perimeter, the following
features are supported:

- **Lakes**: you can create and manage Knowledge Catalog lakes within
  the perimeter.

- **Assets**: you can manage assets within the perimeter.

- **Metadata resources in Catalog**: you can manage metadata resources within the perimeter.

- **Metadata export** : you can export metadata to Dataproc Metastore,
  which requires additional VPC Service Controls configuration. For more
  information, see
  [VPC Service Controls](https://docs.cloud.google.com/knowledge-catalog/docs/export-metadata.md.txt#vpc-service-controls).

- **Data insights**: you can run data profiling, data quality, and metadata
  insights scans.

- **Data lineage** : you can track data lineage by using the restricted [Virtual
  IP (VIP)](https://docs.cloud.google.com/vpc-service-controls/docs/restricted-vip-services).

- **Knowledge Catalog Search** : you can use the [`SearchEntries`
  API](https://docs.cloud.google.com/knowledge-catalog/docs/reference/rest/v1/projects.locations/searchEntries).
  When you use Knowledge Catalog search in a project
  protected by a service perimeter, search results include only resources that
  are within the same perimeter. For more information, see [Search
  scope](https://docs.cloud.google.com/knowledge-catalog/docs/about-search#search-scope) and [Isolate search
  results by environment using
  VPC Service Controls](https://docs.cloud.google.com/knowledge-catalog/docs/about-search#environments).

- **Data products** : you can use VPC Service Controls to secure
  data products, ensuring that communication between the data product, its
  constituent data assets (such as BigQuery tables), and users
  remains within authorized perimeters. For more information, see
  [Use VPC Service Controls with data products](https://docs.cloud.google.com/knowledge-catalog/docs/vpcsc-data-products.md.txt).

### Knowledge Catalog search and VPC Service Controls

When you use Knowledge Catalog search in a project protected by a service
perimeter, search results include only resources that belong to the same project
under which the search is performed.

To include resources from other projects that are in the same service perimeter,
you must configure VPC Service Controls egress rules for the
Knowledge Catalog caller project. For more information, see
[Configuring ingress and egress policies](https://docs.cloud.google.com/vpc-service-controls/docs/configuring-ingress-egress-policies.md.txt).
These rules allow the search results to cross project boundaries within the
perimeter.

The following example shows an egress policy configuration that allows search
results to include BigQuery resources from `project A` when the
search is performed from `project B`:

```yaml
egressPolicies:
-   egressFrom:
    identityType: ANY_USER_ACCOUNT
  egressTo:
    operations:
    -   serviceName: bigquery.googleapis.com
      methodSelectors:
      -   method: '*'
    resources:
    -   projects/projectA
```

When you perform a Knowledge Catalog search in `project B`,
Knowledge Catalog calls the BigQuery API to locate assets
in `project A`. This policy explicitly permits any user account in `project B` to
make BigQuery API calls against `project A`, allowing
BigQuery assets from `project A` to appear in your
Knowledge Catalog search results.

## Limitations

You can create Knowledge Catalog resources before setting up
the VPC Service Controls security perimeter, but those
resources won't have perimeter protection.

By design, VPC Service Controls prevents resources within a service
perimeter from accessing data and services outside that perimeter. For example,
Knowledge Catalog data profiling and data quality scans cannot access data
sources, such as BigQuery tables or Cloud Storage files, that are
outside the service perimeter. Similarly, when exporting data scan results, the
destination BigQuery table must be in a project protected by the
perimeter. For information about granting access to your protected resources
from outside the perimeter, see [Create an access
level](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc#creating-an-access-level).

## Set up VPC Service Controls

To protect Knowledge Catalog resources with VPC Service Controls, perform the following steps:

1. [Configure the VPC network](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc.md.txt#configuring-the-vpc-network).
2. [Create a service perimeter](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc.md.txt#creating-a-service-perimeter).
3. [Add projects to the perimeter](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc.md.txt#adding-more-projects).
4. [Add the Dataplex API to the service perimeter](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc.md.txt#adding-dataplex-and-cloud-storage-apis).
5. Optional: [Create an access level](https://docs.cloud.google.com/knowledge-catalog/docs/vpc-sc.md.txt#creating-an-access-level).

### Configure the Virtual Private Cloud (VPC) network

You can configure the VPC network to restrict
Private Google Access with respect to a service perimeter. This ensures that
hosts on your VPC or on-premises network can only communicate
with Google APIs and services that are supported by VPC Service Controls
in ways which conform to the associated perimeter's policy.

For more information, see [Setting up private connectivity to Google APIs and services](https://docs.cloud.google.com/vpc-service-controls/docs/set-up-private-connectivity.md.txt).

### Create a service perimeter

When you create a service perimeter, you select the Knowledge Catalog
projects that you want the VPC Service Controls service perimeter to protect.

To create a service perimeter, follow the instructions in [Create a service perimeter](https://docs.cloud.google.com/vpc-service-controls/docs/create-service-perimeters.md.txt).

### Add more projects to the service perimeter

To add existing Knowledge Catalog projects to the perimeter,
follow the instructions in [Update a service perimeter](https://docs.cloud.google.com/vpc-service-controls/docs/manage-service-perimeters.md.txt#update).

### Add the Dataplex API to the service perimeter

To mitigate the risk of your data being exfiltrated from Knowledge Catalog,
for example, using Dataplex API methods, you
must restrict the Dataplex API.

To add the Dataplex API as a restricted service, follow these steps:

### Console

1. In the Google Cloud console, go to the **VPC Service Controls** page.

   [Go to VPC Service Controls](https://console.cloud.google.com/security/service-perimeter)
2. On the **VPC Service Controls** page, in the table, click the name of
   the service perimeter that you want to modify.

3. Click **Edit Perimeter**.

4. On the **Edit Service Perimeter** page,
   click **Add Services**.

5. Add **Dataplex API**.

6. Click **Save**.

### gcloud

- Use the `gcloud access-context-manager perimeters update` command:

  ```
  gcloud access-context-manager perimeters update PERIMETER_ID \
  --policy=POLICY_ID \
  --add-restricted-services=dataplex.googleapis.com
  ```

  Replace the following:
  - `PERIMETER_ID`: the ID of the perimeter or the fully qualified identifier for the perimeter
  - `POLICY_ID`: the ID of the access policy

### Optional: Create an access level

To permit external access to protected resources inside a perimeter,
you can use access levels. Access levels apply only to requests for protected
resources coming from outside the service perimeter. You can't use access levels
to give protected resources permission to access data and services outside the
perimeter.

For more information, see
[Allow access to protected resources from outside a perimeter](https://docs.cloud.google.com/vpc-service-controls/docs/use-access-levels.md.txt).

## What's next

- Learn more about [VPC Service Controls](https://docs.cloud.google.com/vpc-service-controls/docs.md.txt).
- Learn more about [Knowledge Catalog access control with IAM](https://docs.cloud.google.com/knowledge-catalog/docs/iam-and-access-control.md.txt).
- Learn more about [Knowledge Catalog security](https://docs.cloud.google.com/knowledge-catalog/docs/security-privacy-compliance.md.txt).