This document describes how to add ingress and egress rules to allow Virtual Machine Threat Detection to scan VMs in your VPC Service Controls perimeters. Perform this task if your organization uses VPC Service Controls to restrict services in projects that you want VM Threat Detection to scan. For more information about VM Threat Detection, see VM Threat Detection overview.
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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the organization.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the organization.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
Create the egress and ingress rules
To allow VM Threat Detection to scan the VMs in VPC Service Controls perimeters, add the required egress and ingress rules in those perimeters. Perform these steps for each perimeter that you want VM Threat Detection to scan.
For more information, see Updating ingress and egress policies for a service perimeter in the VPC Service Controls documentation.
Console
In the Google Cloud console go to the VPC Service Controls page.
Select your organization or project.
If you selected an organization, click Select an access policy and select the access policy associated with the perimeter that you want to update.
Click the title of the perimeter that you want to update.
Click Edit perimeter.
Click Egress Policy.
Click Add rule.
In the FROM attributes of the API client section, set the fields as follows:
- For Identity, select Select Identities & Groups.
- For Add User/Service Account, enter the name of the Security Center service agent. The service agent's name has the following format:
service-org-ORGANIZATION_ID@security-center-api.iam.gserviceaccount.com
Replace ORGANIZATION_ID with your organization ID.
In the TO attributes of GCP services/resources section, set the fields as follows:
- For Project, select All projects.
- For Services, select Selected services and then select the Compute Engine API service.
- For Methods, select Selected method and then select the DisksService.Insert method.
Click Ingress Policy.
Click Add rule.
In the FROM attributes of the API client section, set the fields as follows:
- For Identity, select Select Identities & Groups.
- For Add User/Service Account, enter the name of the Security Center service agent again.
- For Source, select All sources.
In the TO attributes of GCP services/resources section, set the fields as follows:
- For Project, select All projects.
- For Services, select Selected services and then select the Compute Engine API service.
For Methods, select Selected method and then select the following methods:
- DisksService.Insert
- InstancesService.AggregatedList
- InstancesService.List
Click Save.
gcloud
If a quota project isn't already set, then set it. Choose a project that has the Access Context Manager API enabled.
gcloud config set billing/quota_project QUOTA_PROJECT_ID
Replace QUOTA_PROJECT_ID with the ID of the project that you want to use for billing and quota.
Create a file named
egress-rule.yaml
with the following contents:- egressFrom: identities: - serviceAccount:service-org-ORGANIZATION_ID@security-center-api.iam.gserviceaccount.com egressTo: operations: - methodSelectors: - method: DisksService.Insert serviceName: compute.googleapis.com resources: - '*'
Replace ORGANIZATION_ID with your organization ID.
Create a file named
ingress-rule.yaml
with the following contents:- ingressFrom: identities: - serviceAccount:service-org-ORGANIZATION_ID@security-center-api.iam.gserviceaccount.com sources: - accessLevel: '*' ingressTo: operations: - methodSelectors: - method: DisksService.Insert - method: InstancesService.AggregatedList - method: InstancesService.List serviceName: compute.googleapis.com resources: - '*'
Add the egress rule to the perimeter:
gcloud access-context-manager perimeters update PERIMETER_NAME --set-egress-policies=EGRESS_RULE_FILENAME
Replace the following:
- PERIMETER_NAME: the name of the perimeter—for example,
accessPolicies/1234567890/servicePerimeters/example_perimeter
- EGRESS_RULE_FILENAME: the name of the file that contains the egress rule
- PERIMETER_NAME: the name of the perimeter—for example,
Add the ingress rule to the perimeter:
gcloud access-context-manager perimeters update PERIMETER_NAME --set-ingress-policies=INGRESS_RULE_FILENAME
Replace the following:
- PERIMETER_NAME: the name of the perimeter—for example,
accessPolicies/1234567890/servicePerimeters/example_perimeter
- INGRESS_RULE_FILENAME: the name of the file that contains the ingress rule
- PERIMETER_NAME: the name of the perimeter—for example,
What's next
- Learn how to use VM Threat Detection.