This document describes how to let Sensitive Data Protection discover and
profile data in your [VPC Service Controls
perimeters](https://docs.cloud.google.com/vpc-service-controls/docs/service-perimeters). If your organization
uses VPC Service Controls to restrict services in projects that
Sensitive Data Protection scans, then perform the tasks in this document.

For more information, see [Overview of sensitive data
discovery](https://docs.cloud.google.com/sensitive-data-protection/docs/data-profiles).

For information about VPC Service Controls support for Sensitive Data Protection,
see the [Supported
products](https://docs.cloud.google.com/vpc-service-controls/docs/supported-products#table_dlp) table in the
VPC Service Controls documentation.

## Before you begin


Make sure that you have the following role or roles on the organization:

Access Context Manager Editor
(`roles/accesscontextmanager.policyEditor`).

#### Check for the roles

1.
   In the Google Cloud console, go to the **IAM** page.

   [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=organizationId)
2. Select the organization.
3.
   In the **Principal** column, find all rows that identify you or a group that
   you're included in. To learn which groups you're included in, contact your
   administrator.

4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.

#### Grant the roles

1.
   In the Google Cloud console, go to the **IAM** page.

   [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=organizationId)
2. Select the organization.
3. Click **Grant access**.
4.
   In the **New principals** field, enter your user identifier.

   This is typically the email address for a Google Account.

5. Click **Select a role**, then search for the role.
6. To grant additional roles, click **Add
   another role** and add each additional role.
7. Click **Save**.

## Configure sensitive data discovery within VPC Service Controls

You can configure Sensitive Data Protection discovery within a
VPC Service Controls perimeter using one of these architectural approaches.

### Option 1: All required resources in the same perimeter as the data to scan

Ensure that all components involved in the discovery operation are located
within the same perimeter. That is, these components must all be in the
same perimeter:

- The projects to scan.
- The [discovery scan
  configuration](https://docs.cloud.google.com/sensitive-data-protection/docs/data-profiles#scan-configuration).
- The [service agent](https://docs.cloud.google.com/sensitive-data-protection/docs/data-profiles.md.txt#service-agent-container) specified in the discovery scan configuration.
- The *service agent container* (also known as the *driver project*), which hosts the service agent.
- Any [inspection
  templates](https://docs.cloud.google.com/sensitive-data-protection/docs/data-profiles#inspection-template) specified in the discovery scan configuration.

If you have multiple VPC Service Controls perimeters in your organization, then
create dedicated components inside each of those perimeters.

For example, if a perimeter includes multiple projects that belong to the same
folder, create a discovery scan configuration that is scoped to that folder.
Make sure that the service agent container that you use is one of the projects
in that same perimeter.

If you choose this option, you don't need to create ingress and egress rules for
sensitive data discovery.

### Option 2: Centralized discovery configuration with ingress and egress rules

Create a centralized discovery scan configuration for your
entire organization or for multiple projects across multiple perimeters.

If this centralized discovery scan configuration doesn't reside within the same
perimeter as the data to scan, then create ingress and egress rules.

## Create the ingress and egress rules

Create these ingress and egress rules if you choose [Option
2](https://docs.cloud.google.com/sensitive-data-protection/docs/allow-discovery-vpcsc#centralized-config) and the data to scan is in a different perimeter
from the centralized discovery scan configuration.

For more information, see [Updating ingress and egress policies for a service
perimeter](https://docs.cloud.google.com/vpc-service-controls/docs/configuring-ingress-egress-policies)
in the VPC Service Controls documentation.

To define your ingress and egress rules, you can use one or both of the
following:

- Service agent ID specified in the centralized discovery scan configuration
- Project that contains the centralized discovery scan configuration

### Ingress rules

For each perimeter that contains data to scan, [update the ingress
policy](https://docs.cloud.google.com/vpc-service-controls/docs/configuring-ingress-egress-policies#updating)
to add an ingress rule for sensitive data discovery operations.

- To use the service agent ID, in the **From** section, set **Identities** to
  **Select identities \& groups**. Add and select the service agent ID specified
  in the centralized discovery scan configuration. The service agent's ID has
  the following format:

      service-PROJECT_NUMBER@dlp-api.iam.iam.gserviceaccount.com

  Replace `PROJECT_NUMBER` with the numerical identifier
  of the service agent container.
- To use the project, in the **From** section, set **Sources** to the project
  that contains the centralized discovery scan configuration.

The following example uses both the service agent ID and the project to define
the ingress rule.

![Ingress rule with both a service agent ID and a project set.](https://docs.cloud.google.com/static/sensitive-data-protection/docs/images/discovery-ingress.png)

### Egress rules

For each perimeter that contains data to scan, [update the egress
policy](https://docs.cloud.google.com/vpc-service-controls/docs/configuring-ingress-egress-policies#updating)
to add an egress rule for sensitive data discovery operations.

- To use the service agent ID, in the **From** section, set **Identities** to
  **Select identities \& groups**. Add and select the service agent ID specified
  in the centralized discovery scan configuration. The service agent's ID has
  the following format:

      service-PROJECT_NUMBER@dlp-api.iam.iam.gserviceaccount.com

  Replace `PROJECT_NUMBER` with the numerical identifier
  of the service agent container.
- To use the project, in the **To** section, set **Resources** to **Select
  projects**. Add and select the project that contains the centralized discovery
  scan configuration.

The following example uses both the service agent ID and the project to define
the egress rule.

![Egress rule with both a service agent ID and a project set.](https://docs.cloud.google.com/static/sensitive-data-protection/docs/images/discovery-egress.png)