Making bulk changes to service perimeters

Using Access Context Manager, you can make bulk updates to resources that belong to your organization's access policy, such as access levels and service perimeters. Changes to your resources are applied only if all parts of the bulk operation are successful.

This topic describes only bulk replacement of service perimeters. For more information about bulk replacement of access levels, refer to the Access Context Manager documentation.

Get a list of service perimeters

Because bulk operations affect all service perimeters for your organization, you can obtain a complete list of your perimeters. Also, you can format this list as YAML and use it to make bulk changes to your perimeters.

To get a formatted list of service perimeters, refer to List service perimeters (formatted).

When overriding all service perimeter configurations with the replace-all command, you must not set the etag fields within perimeters. Etags are likely to change between fetching and updating the perimeters, causing the replace-all command to return an etag mismatch error. However, you can set an etag for the entire replace-all request with the top-level --etag parameter if you want to enforce the etag check.

Instead of manually removing each of the etag properties within the perimeters, you can fetch the perimeters without etag properties by specifying a --format with all fields except etag.

gcloud access-context-manager perimeters list \
  --policy=POLICY_NAME \
  --format="json(name,title,description,perimeterType,status,spec,useExplicitDryRunSpec)"

Bulk replace service perimeters

The following section details how to bulk replace your service perimeters.

gcloud

To bulk replace all service perimeters, use the replace-all command.

gcloud access-context-manager perimeters replace-all POLICY_NAME