Skip to content

googleAccessContextManagerServicePerimeter

ServicePerimeter describes a set of GCP resources which can freely import and export data amongst themselves, but not export outside of the ServicePerimeter. If a request with a source within this ServicePerimeter has a target outside of the ServicePerimeter, the request will be blocked. Otherwise the request is allowed. There are two types of Service Perimeter

  • Regular and Bridge. Regular Service Perimeters cannot overlap, a single GCP project can only belong to a single regular Service Perimeter. Service Perimeter Bridges can contain only GCP projects as members, a single GCP project may belong to multiple Service Perimeter Bridges.

To get more information about ServicePerimeter, see:

\~> Warning: If you are using User ADCs (Application Default Credentials) with this resource, you must specify a billingProject and set userProjectOverride to true in the provider configuration. Otherwise the ACM API will return a 403 error. Your account must have the serviceusageServicesUse permission on the billingProject you defined.

Example Usage - Access Context Manager Service Perimeter Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleAccessContextManagerAccessPolicyAccessPolicy =
  new google.accessContextManagerAccessPolicy.AccessContextManagerAccessPolicy(
    this,
    "access-policy",
    {
      parent: "organizations/123456789",
      title: "my policy",
    }
  );
new google.accessContextManagerServicePerimeter.AccessContextManagerServicePerimeter(
  this,
  "service-perimeter",
  {
    name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/servicePerimeters/restrict_storage`,
    parent: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}`,
    status: [
      {
        restricted_services: ["storage.googleapis.com"],
      },
    ],
    title: "restrict_storage",
  }
);
new google.accessContextManagerAccessLevel.AccessContextManagerAccessLevel(
  this,
  "access-level",
  {
    basic: [
      {
        conditions: [
          {
            device_policy: [
              {
                os_constraints: [
                  {
                    os_type: "DESKTOP_CHROME_OS",
                  },
                ],
                require_screen_lock: false,
              },
            ],
            regions: ["CH", "IT", "US"],
          },
        ],
      },
    ],
    name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/accessLevels/chromeos_no_lock`,
    parent: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}`,
    title: "chromeos_no_lock",
  }
);

Example Usage - Access Context Manager Service Perimeter Secure Data Exchange

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleAccessContextManagerAccessPolicyAccessPolicy =
  new google.accessContextManagerAccessPolicy.AccessContextManagerAccessPolicy(
    this,
    "access-policy",
    {
      parent: "organizations/123456789",
      title: "my policy",
    }
  );
new google.accessContextManagerServicePerimeters.AccessContextManagerServicePerimeters(
  this,
  "secure-data-exchange",
  {
    parent: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}`,
    service_perimeters: [
      {
        name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/servicePerimeters/`,
        status: [
          {
            restricted_services: ["storage.googleapis.com"],
          },
        ],
        title: "",
      },
      {
        name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/servicePerimeters/`,
        status: [
          {
            restricted_services: ["bigtable.googleapis.com"],
            vpcAccessibleServices: [
              {
                allowedServices: ["bigquery.googleapis.com"],
                enableRestriction: true,
              },
            ],
          },
        ],
        title: "",
      },
    ],
  }
);
const googleAccessContextManagerAccessLevelAccessLevel =
  new google.accessContextManagerAccessLevel.AccessContextManagerAccessLevel(
    this,
    "access-level",
    {
      basic: [
        {
          conditions: [
            {
              device_policy: [
                {
                  os_constraints: [
                    {
                      os_type: "DESKTOP_CHROME_OS",
                    },
                  ],
                  require_screen_lock: false,
                },
              ],
              regions: ["CH", "IT", "US"],
            },
          ],
        },
      ],
      name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/accessLevels/secure_data_exchange`,
      parent: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}`,
      title: "secure_data_exchange",
    }
  );
new google.accessContextManagerServicePerimeter.AccessContextManagerServicePerimeter(
  this,
  "test-access",
  {
    name: "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/servicePerimeters/%s",
    parent:
      "accessPolicies/${google_access_context_manager_access_policy.test-access.name}",
    perimeter_type: "PERIMETER_TYPE_REGULAR",
    status: [
      {
        access_levels: [googleAccessContextManagerAccessLevelAccessLevel.name],
        egress_policies: [
          {
            egress_from: [
              {
                identity_type: "ANY_USER_ACCOUNT",
              },
            ],
          },
        ],
        ingress_policies: [
          {
            ingress_from: [
              {
                identity_type: "ANY_IDENTITY",
                sources: [
                  {
                    access_level:
                      "${google_access_context_manager_access_level.test-access.name}",
                  },
                ],
              },
            ],
            ingress_to: [
              {
                operations: [
                  {
                    method_selectors: [
                      {
                        method: "BigQueryStorage.ReadRows",
                      },
                      {
                        method: "TableService.ListTables",
                      },
                      {
                        permission: "bigquery.jobs.get",
                      },
                    ],
                    service_name: "bigquery.googleapis.com",
                  },
                  {
                    method_selectors: [
                      {
                        method: "google.storage.objects.create",
                      },
                    ],
                    service_name: "storage.googleapis.com",
                  },
                ],
                resources: ["*"],
              },
            ],
          },
        ],
        restricted_services: [
          "bigquery.googleapis.com",
          "storage.googleapis.com",
        ],
        vpc_accessible_services: [
          {
            allowed_services: [
              "bigquery.googleapis.com",
              "storage.googleapis.com",
            ],
            enable_restriction: true,
          },
        ],
      },
    ],
    title: "%s",
  }
);

Example Usage - Access Context Manager Service Perimeter Dry Run

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleAccessContextManagerAccessPolicyAccessPolicy =
  new google.accessContextManagerAccessPolicy.AccessContextManagerAccessPolicy(
    this,
    "access-policy",
    {
      parent: "organizations/123456789",
      title: "my policy",
    }
  );
new google.accessContextManagerServicePerimeter.AccessContextManagerServicePerimeter(
  this,
  "service-perimeter",
  {
    name: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}/servicePerimeters/restrict_bigquery_dryrun_storage`,
    parent: `accessPolicies/\${${googleAccessContextManagerAccessPolicyAccessPolicy.name}}`,
    spec: [
      {
        restricted_services: ["storage.googleapis.com"],
      },
    ],
    status: [
      {
        restricted_services: ["bigquery.googleapis.com"],
      },
    ],
    title: "restrict_bigquery_dryrun_storage",
    use_explicit_dry_run_spec: true,
  }
);

Argument Reference

The following arguments are supported:

  • title - (Required) Human readable title. Must be unique within the Policy.

  • parent - (Required) The AccessPolicy this ServicePerimeter lives in. Format: accessPolicies/{policy_id}

  • name - (Required) Resource name for the ServicePerimeter. The short_name component must begin with a letter and only include alphanumeric and '_'. Format: accessPolicies/{policy_id}/servicePerimeters/{short_name}


  • description - (Optional) Description of the ServicePerimeter and its use. Does not affect behavior.

  • perimeterType - (Optional) Specifies the type of the Perimeter. There are two types: regular and bridge. Regular Service Perimeter contains resources, access levels, and restricted services. Every resource can be in at most ONE regular Service Perimeter. In addition to being in a regular service perimeter, a resource can also be in zero or more perimeter bridges. A perimeter bridge only contains resources. Cross project operations are permitted if all effected resources share some perimeter (whether bridge or regular). Perimeter Bridge does not contain access levels or services: those are governed entirely by the regular perimeter that resource is in. Perimeter Bridges are typically useful when building more complex topologies with many independent perimeters that need to share some data with a common perimeter, but should not be able to share data among themselves. Default value is perimeterTypeRegular. Possible values are perimeterTypeRegular and perimeterTypeBridge.

  • status - (Optional) ServicePerimeter configuration. Specifies sets of resources, restricted services and access levels that determine perimeter content and boundaries. Structure is documented below.

  • spec - (Optional) Proposed (or dry run) ServicePerimeter configuration. This configuration allows to specify and test ServicePerimeter configuration without enforcing actual access restrictions. Only allowed to be set when the useExplicitDryRunSpec flag is set. Structure is documented below.

  • useExplicitDryRunSpec - (Optional) Use explicit dry run spec flag. Ordinarily, a dry-run spec implicitly exists for all Service Perimeters, and that spec is identical to the status for those Service Perimeters. When this flag is set, it inhibits the generation of the implicit spec, thereby allowing the user to explicitly provide a configuration ("spec") to use in a dry-run version of the Service Perimeter. This allows the user to test changes to the enforced config ("status") without actually enforcing them. This testing is done through analyzing the differences between currently enforced and suggested restrictions. useExplicitDryRunSpec must bet set to True if any of the fields in the spec are set to non-default values.

The status block supports:

  • resources - (Optional) A list of GCP resources that are inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}

  • accessLevels - (Optional) A list of AccessLevel resource names that allow resources within the ServicePerimeter to be accessed from the internet. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel is a syntax error. If no AccessLevel names are listed, resources within the perimeter can only be accessed via GCP calls with request origins within the perimeter. For Service Perimeter Bridge, must be empty. Format: accessPolicies/{policy_id}/accessLevels/{access_level_name}

  • restrictedServices - (Optional) GCP services that are subject to the Service Perimeter restrictions. Must contain a list of services. For example, if storageGoogleapisCom is specified, access to the storage buckets inside the perimeter must meet the perimeter's access restrictions.

  • vpcAccessibleServices - (Optional) Specifies how APIs are allowed to communicate within the Service Perimeter. Structure is documented below.

  • ingressPolicies - (Optional) List of ingressPolicies to apply to the perimeter. A perimeter may have multiple ingressPolicies, each of which is evaluated separately. Access is granted if any ingressPolicy grants it. Must be empty for a perimeter bridge. Structure is documented below.

  • egressPolicies - (Optional) List of EgressPolicies to apply to the perimeter. A perimeter may have multiple EgressPolicies, each of which is evaluated separately. Access is granted if any EgressPolicy grants it. Must be empty for a perimeter bridge. Structure is documented below.

The vpcAccessibleServices block supports:

  • enableRestriction - (Optional) Whether to restrict API calls within the Service Perimeter to the list of APIs specified in 'allowedServices'.

  • allowedServices - (Optional) The list of APIs usable within the Service Perimeter. Must be empty unless enableRestriction is True.

The ingressPolicies block supports:

  • ingressFrom - (Optional) Defines the conditions on the source of a request causing this ingressPolicy to apply. Structure is documented below.

  • ingressTo - (Optional) Defines the conditions on the apiOperation and request destination that cause this ingressPolicy to apply. Structure is documented below.

The ingressFrom block supports:

  • identityType - (Optional) Specifies the type of identities that are allowed access from outside the perimeter. If left unspecified, then members of identities field will be allowed access. Possible values are identityTypeUnspecified, anyIdentity, anyUserAccount, and anyServiceAccount.

  • identities - (Optional) A list of identities that are allowed access through this ingress policy. Should be in the format of email address. The email address should represent individual user or service account only.

  • sources - (Optional) Sources that this ingressPolicy authorizes access from. Structure is documented below.

The sources block supports:

  • accessLevel - (Optional) An accessLevel resource name that allow resources within the servicePerimeters to be accessed from the internet. accessLevels listed must be in the same policy as this servicePerimeter. Referencing a nonexistent accessLevel will cause an error. If no accessLevel names are listed, resources within the perimeter can only be accessed via Google Cloud calls with request origins within the perimeter. Example accessPolicies/myPolicy/accessLevels/myLevel If * is specified, then all IngressSources will be allowed.

  • resource - (Optional) A Google Cloud resource that is allowed to ingress the perimeter. Requests from these resources will be allowed to access perimeter data. Currently only projects are allowed. Format projects/{projectNumber} The project may be in any Google Cloud organization, not just the organization that the perimeter is defined in. * is not allowed, the case of allowing all Google Cloud resources only is not supported.

The ingressTo block supports:

  • resources - (Optional) A list of resources, currently only projects in the form projects/<projectnumber>, protected by this servicePerimeter that are allowed to be accessed by sources defined in the corresponding ingressFrom. A request matches if it contains a resource in this list. If * is specified for resources, then this ingressTo rule will authorize access to all resources inside the perimeter, provided that the request also matches the operations field.

  • operations - (Optional) A list of apiOperations the sources specified in corresponding ingressFrom are allowed to perform in this servicePerimeter. Structure is documented below.

The operations block supports:

  • serviceName - (Optional) The name of the API whose methods or permissions the ingressPolicy or egressPolicy want to allow. A single apiOperation with serviceName field set to * will allow all methods AND permissions for all services.

  • methodSelectors - (Optional) API methods or permissions to allow. Method or permission must belong to the service specified by serviceName field. A single methodSelector entry with * specified for the method field will allow all methods AND permissions for the service specified in serviceName. Structure is documented below.

The methodSelectors block supports:

  • method - (Optional) Value for method should be a valid method name for the corresponding serviceName in apiOperation. If * used as value for method, then ALL methods and permissions are allowed.

  • permission - (Optional) Value for permission should be a valid Cloud IAM permission for the corresponding serviceName in apiOperation.

The egressPolicies block supports:

  • egressFrom - (Optional) Defines conditions on the source of a request causing this egressPolicy to apply. Structure is documented below.

  • egressTo - (Optional) Defines the conditions on the apiOperation and destination resources that cause this egressPolicy to apply. Structure is documented below.

The egressFrom block supports:

  • identityType - (Optional) Specifies the type of identities that are allowed access to outside the perimeter. If left unspecified, then members of identities field will be allowed access. Possible values are identityTypeUnspecified, anyIdentity, anyUserAccount, and anyServiceAccount.

  • identities - (Optional) A list of identities that are allowed access through this egressPolicy. Should be in the format of email address. The email address should represent individual user or service account only.

The egressTo block supports:

  • resources - (Optional) A list of resources, currently only projects in the form projects/<projectnumber>, that match this to stanza. A request matches if it contains a resource in this list. If * is specified for resources, then this egressTo rule will authorize access to all resources outside the perimeter.

  • externalResources - (Optional) A list of external resources that are allowed to be accessed. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.

  • operations - (Optional) A list of apiOperations that this egress rule applies to. A request matches if it contains an operation/service in this list. Structure is documented below.

The operations block supports:

  • serviceName - (Optional) The name of the API whose methods or permissions the ingressPolicy or egressPolicy want to allow. A single apiOperation with serviceName field set to * will allow all methods AND permissions for all services.

  • methodSelectors - (Optional) API methods or permissions to allow. Method or permission must belong to the service specified by serviceName field. A single MethodSelector entry with * specified for the method field will allow all methods AND permissions for the service specified in serviceName. Structure is documented below.

The methodSelectors block supports:

  • method - (Optional) Value for method should be a valid method name for the corresponding serviceName in apiOperation. If * used as value for method, then ALL methods and permissions are allowed.

  • permission - (Optional) Value for permission should be a valid Cloud IAM permission for the corresponding serviceName in apiOperation.

The spec block supports:

  • resources - (Optional) A list of GCP resources that are inside of the service perimeter. Currently only projects are allowed. Format: projects/{project_number}

  • accessLevels - (Optional) A list of AccessLevel resource names that allow resources within the ServicePerimeter to be accessed from the internet. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel is a syntax error. If no AccessLevel names are listed, resources within the perimeter can only be accessed via GCP calls with request origins within the perimeter. For Service Perimeter Bridge, must be empty. Format: accessPolicies/{policy_id}/accessLevels/{access_level_name}

  • restrictedServices - (Optional) GCP services that are subject to the Service Perimeter restrictions. Must contain a list of services. For example, if storageGoogleapisCom is specified, access to the storage buckets inside the perimeter must meet the perimeter's access restrictions.

  • vpcAccessibleServices - (Optional) Specifies how APIs are allowed to communicate within the Service Perimeter. Structure is documented below.

  • ingressPolicies - (Optional) List of ingressPolicies to apply to the perimeter. A perimeter may have multiple ingressPolicies, each of which is evaluated separately. Access is granted if any ingressPolicy grants it. Must be empty for a perimeter bridge. Structure is documented below.

  • egressPolicies - (Optional) List of EgressPolicies to apply to the perimeter. A perimeter may have multiple EgressPolicies, each of which is evaluated separately. Access is granted if any EgressPolicy grants it. Must be empty for a perimeter bridge. Structure is documented below.

The vpcAccessibleServices block supports:

  • enableRestriction - (Optional) Whether to restrict API calls within the Service Perimeter to the list of APIs specified in 'allowedServices'.

  • allowedServices - (Optional) The list of APIs usable within the Service Perimeter. Must be empty unless enableRestriction is True.

The ingressPolicies block supports:

  • ingressFrom - (Optional) Defines the conditions on the source of a request causing this ingressPolicy to apply. Structure is documented below.

  • ingressTo - (Optional) Defines the conditions on the apiOperation and request destination that cause this ingressPolicy to apply. Structure is documented below.

The ingressFrom block supports:

  • identityType - (Optional) Specifies the type of identities that are allowed access from outside the perimeter. If left unspecified, then members of identities field will be allowed access. Possible values are identityTypeUnspecified, anyIdentity, anyUserAccount, and anyServiceAccount.

  • identities - (Optional) A list of identities that are allowed access through this ingress policy. Should be in the format of email address. The email address should represent individual user or service account only.

  • sources - (Optional) Sources that this ingressPolicy authorizes access from. Structure is documented below.

The sources block supports:

  • accessLevel - (Optional) An accessLevel resource name that allow resources within the servicePerimeters to be accessed from the internet. accessLevels listed must be in the same policy as this servicePerimeter. Referencing a nonexistent accessLevel will cause an error. If no accessLevel names are listed, resources within the perimeter can only be accessed via Google Cloud calls with request origins within the perimeter. Example accessPolicies/myPolicy/accessLevels/myLevel If * is specified, then all IngressSources will be allowed.

  • resource - (Optional) A Google Cloud resource that is allowed to ingress the perimeter. Requests from these resources will be allowed to access perimeter data. Currently only projects are allowed. Format projects/{projectNumber} The project may be in any Google Cloud organization, not just the organization that the perimeter is defined in. * is not allowed, the case of allowing all Google Cloud resources only is not supported.

The ingressTo block supports:

  • resources - (Optional) A list of resources, currently only projects in the form projects/<projectnumber>, protected by this servicePerimeter that are allowed to be accessed by sources defined in the corresponding ingressFrom. A request matches if it contains a resource in this list. If * is specified for resources, then this ingressTo rule will authorize access to all resources inside the perimeter, provided that the request also matches the operations field.

  • operations - (Optional) A list of apiOperations the sources specified in corresponding ingressFrom are allowed to perform in this servicePerimeter. Structure is documented below.

The operations block supports:

  • serviceName - (Optional) The name of the API whose methods or permissions the ingressPolicy or egressPolicy want to allow. A single apiOperation with serviceName field set to * will allow all methods AND permissions for all services.

  • methodSelectors - (Optional) API methods or permissions to allow. Method or permission must belong to the service specified by serviceName field. A single methodSelector entry with * specified for the method field will allow all methods AND permissions for the service specified in serviceName. Structure is documented below.

The methodSelectors block supports:

  • method - (Optional) Value for method should be a valid method name for the corresponding serviceName in apiOperation. If * used as value for method, then ALL methods and permissions are allowed.

  • permission - (Optional) Value for permission should be a valid Cloud IAM permission for the corresponding serviceName in apiOperation.

The egressPolicies block supports:

  • egressFrom - (Optional) Defines conditions on the source of a request causing this egressPolicy to apply. Structure is documented below.

  • egressTo - (Optional) Defines the conditions on the apiOperation and destination resources that cause this egressPolicy to apply. Structure is documented below.

The egressFrom block supports:

  • identityType - (Optional) Specifies the type of identities that are allowed access to outside the perimeter. If left unspecified, then members of identities field will be allowed access. Possible values are identityTypeUnspecified, anyIdentity, anyUserAccount, and anyServiceAccount.

  • identities - (Optional) A list of identities that are allowed access through this egressPolicy. Should be in the format of email address. The email address should represent individual user or service account only.

The egressTo block supports:

  • resources - (Optional) A list of resources, currently only projects in the form projects/<projectnumber>, that match this to stanza. A request matches if it contains a resource in this list. If * is specified for resources, then this egressTo rule will authorize access to all resources outside the perimeter.

  • externalResources - (Optional) A list of external resources that are allowed to be accessed. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.

  • operations - (Optional) A list of apiOperations that this egress rule applies to. A request matches if it contains an operation/service in this list. Structure is documented below.

The operations block supports:

  • serviceName - (Optional) The name of the API whose methods or permissions the ingressPolicy or egressPolicy want to allow. A single apiOperation with serviceName field set to * will allow all methods AND permissions for all services.

  • methodSelectors - (Optional) API methods or permissions to allow. Method or permission must belong to the service specified by serviceName field. A single MethodSelector entry with * specified for the method field will allow all methods AND permissions for the service specified in serviceName. Structure is documented below.

The methodSelectors block supports:

  • method - (Optional) Value for method should be a valid method name for the corresponding serviceName in apiOperation. If * used as value for method, then ALL methods and permissions are allowed.

  • permission - (Optional) Value for permission should be a valid Cloud IAM permission for the corresponding serviceName in apiOperation.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format {{name}}

  • createTime - Time the AccessPolicy was created in UTC.

  • updateTime - Time the AccessPolicy was updated in UTC.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

ServicePerimeter can be imported using any of these accepted formats:

$ terraform import google_access_context_manager_service_perimeter.default {{name}}