blob: 8a8cbbb97e188d7e35d10467cea969858c537414 [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Access Context Manager (VPC Service Controls)"
description: |-
Replace all existing Service Perimeters in an Access Policy with the Service Perimeters provided.
---
# google\_access\_context\_manager\_service\_perimeters
Replace all existing Service Perimeters in an Access Policy with the Service Perimeters provided. This is done atomically.
This is a bulk edit of all Service Perimeters and may override existing Service Perimeters created by `google_access_context_manager_service_perimeter`,
thus causing a permadiff if used alongside `google_access_context_manager_service_perimeter` on the same parent.
To get more information about ServicePerimeters, see:
* [API documentation](https://cloud.google.com/access-context-manager/docs/reference/rest/v1/accessPolicies.servicePerimeters)
* How-to Guides
* [Service Perimeter Quickstart](https://cloud.google.com/vpc-service-controls/docs/quickstart)
## Example Usage - Access Context Manager Service Perimeters Basic
```hcl
resource "google_access_context_manager_service_perimeters" "service-perimeter" {
parent = "accessPolicies/${google_access_context_manager_access_policy.access-policy.name}"
service_perimeters {
name = "accessPolicies/${google_access_context_manager_access_policy.access-policy.name}/servicePerimeters/"
title = ""
status {
restricted_services = ["storage.googleapis.com"]
}
}
service_perimeters {
name = "accessPolicies/${google_access_context_manager_access_policy.access-policy.name}/servicePerimeters/"
title = ""
status {
restricted_services = ["bigtable.googleapis.com"]
}
}
}
resource "google_access_context_manager_access_level" "access-level" {
parent = "accessPolicies/${google_access_context_manager_access_policy.access-policy.name}"
name = "accessPolicies/${google_access_context_manager_access_policy.access-policy.name}/accessLevels/chromeos_no_lock"
title = "chromeos_no_lock"
basic {
conditions {
device_policy {
require_screen_lock = false
os_constraints {
os_type = "DESKTOP_CHROME_OS"
}
}
regions = [
"CH",
"IT",
"US",
]
}
}
}
resource "google_access_context_manager_access_policy" "access-policy" {
parent = "organizations/123456789"
title = "my policy"
}
```
## Argument Reference
The following arguments are supported:
* `parent` -
(Required)
The AccessPolicy this ServicePerimeter lives in.
Format: accessPolicies/{policy_id}
- - -
* `service_perimeters` -
(Optional)
The desired Service Perimeters that should replace all existing Service Perimeters in the Access Policy.
Structure is [documented below](#nested_service_perimeters).
<a name="nested_service_perimeters"></a>The `service_perimeters` block supports:
* `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}
* `title` -
(Required)
Human readable title. Must be unique within the Policy.
* `description` -
(Optional)
Description of the ServicePerimeter and its use. Does not affect
behavior.
* `create_time` -
(Output)
Time the AccessPolicy was created in UTC.
* `update_time` -
(Output)
Time the AccessPolicy was updated in UTC.
* `perimeter_type` -
(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 `PERIMETER_TYPE_REGULAR`.
Possible values are: `PERIMETER_TYPE_REGULAR`, `PERIMETER_TYPE_BRIDGE`.
* `status` -
(Optional)
ServicePerimeter configuration. Specifies sets of resources,
restricted services and access levels that determine
perimeter content and boundaries.
Structure is [documented below](#nested_status).
* `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](#nested_spec).
* `use_explicit_dry_run_spec` -
(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.
<a name="nested_status"></a>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}
* `access_levels` -
(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}
* `restricted_services` -
(Optional)
GCP services that are subject to the Service Perimeter
restrictions. Must contain a list of services. For example, if
`storage.googleapis.com` is specified, access to the storage
buckets inside the perimeter must meet the perimeter's access
restrictions.
* `vpc_accessible_services` -
(Optional)
Specifies how APIs are allowed to communicate within the Service
Perimeter.
Structure is [documented below](#nested_vpc_accessible_services).
* `ingress_policies` -
(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 `Ingress Policy` grants it.
Must be empty for a perimeter bridge.
Structure is [documented below](#nested_ingress_policies).
* `egress_policies` -
(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](#nested_egress_policies).
<a name="nested_vpc_accessible_services"></a>The `vpc_accessible_services` block supports:
* `enable_restriction` -
(Optional)
Whether to restrict API calls within the Service Perimeter to the
list of APIs specified in 'allowedServices'.
* `allowed_services` -
(Optional)
The list of APIs usable within the Service Perimeter.
Must be empty unless `enableRestriction` is True.
<a name="nested_ingress_policies"></a>The `ingress_policies` block supports:
* `ingress_from` -
(Optional)
Defines the conditions on the source of a request causing this `IngressPolicy`
to apply.
Structure is [documented below](#nested_ingress_from).
* `ingress_to` -
(Optional)
Defines the conditions on the `ApiOperation` and request destination that cause
this `IngressPolicy` to apply.
Structure is [documented below](#nested_ingress_to).
<a name="nested_ingress_from"></a>The `ingress_from` block supports:
* `identity_type` -
(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: `IDENTITY_TYPE_UNSPECIFIED`, `ANY_IDENTITY`, `ANY_USER_ACCOUNT`, `ANY_SERVICE_ACCOUNT`.
* `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](#nested_sources).
<a name="nested_sources"></a>The `sources` block supports:
* `access_level` -
(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/MY_POLICY/accessLevels/MY_LEVEL.`
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/{project_number}`
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.
<a name="nested_ingress_to"></a>The `ingress_to` 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](#nested_operations).
<a name="nested_operations"></a>The `operations` block supports:
* `service_name` -
(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.
* `method_selectors` -
(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](#nested_method_selectors).
<a name="nested_method_selectors"></a>The `method_selectors` 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`.
<a name="nested_egress_policies"></a>The `egress_policies` block supports:
* `egress_from` -
(Optional)
Defines conditions on the source of a request causing this `EgressPolicy` to apply.
Structure is [documented below](#nested_egress_from).
* `egress_to` -
(Optional)
Defines the conditions on the `ApiOperation` and destination resources that
cause this `EgressPolicy` to apply.
Structure is [documented below](#nested_egress_to).
<a name="nested_egress_from"></a>The `egress_from` block supports:
* `identity_type` -
(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: `IDENTITY_TYPE_UNSPECIFIED`, `ANY_IDENTITY`, `ANY_USER_ACCOUNT`, `ANY_SERVICE_ACCOUNT`.
* `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.
* `sources` -
(Optional)
Sources that this EgressPolicy authorizes access from.
Structure is [documented below](#nested_sources).
* `source_restriction` -
(Optional)
Whether to enforce traffic restrictions based on `sources` field. If the `sources` field is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.
Possible values are: `SOURCE_RESTRICTION_UNSPECIFIED`, `SOURCE_RESTRICTION_ENABLED`, `SOURCE_RESTRICTION_DISABLED`.
<a name="nested_sources"></a>The `sources` block supports:
* `access_level` -
(Optional)
An AccessLevel resource name that allows resources outside the ServicePerimeter to be accessed from the inside.
<a name="nested_egress_to"></a>The `egress_to` 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.
* `external_resources` -
(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](#nested_operations).
<a name="nested_operations"></a>The `operations` block supports:
* `service_name` -
(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.
* `method_selectors` -
(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](#nested_method_selectors).
<a name="nested_method_selectors"></a>The `method_selectors` 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`.
<a name="nested_spec"></a>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}
* `access_levels` -
(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}
* `restricted_services` -
(Optional)
GCP services that are subject to the Service Perimeter
restrictions. Must contain a list of services. For example, if
`storage.googleapis.com` is specified, access to the storage
buckets inside the perimeter must meet the perimeter's access
restrictions.
* `vpc_accessible_services` -
(Optional)
Specifies how APIs are allowed to communicate within the Service
Perimeter.
Structure is [documented below](#nested_vpc_accessible_services).
* `ingress_policies` -
(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 `Ingress Policy` grants it.
Must be empty for a perimeter bridge.
Structure is [documented below](#nested_ingress_policies).
* `egress_policies` -
(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](#nested_egress_policies).
<a name="nested_vpc_accessible_services"></a>The `vpc_accessible_services` block supports:
* `enable_restriction` -
(Optional)
Whether to restrict API calls within the Service Perimeter to the
list of APIs specified in 'allowedServices'.
* `allowed_services` -
(Optional)
The list of APIs usable within the Service Perimeter.
Must be empty unless `enableRestriction` is True.
<a name="nested_ingress_policies"></a>The `ingress_policies` block supports:
* `ingress_from` -
(Optional)
Defines the conditions on the source of a request causing this `IngressPolicy`
to apply.
Structure is [documented below](#nested_ingress_from).
* `ingress_to` -
(Optional)
Defines the conditions on the `ApiOperation` and request destination that cause
this `IngressPolicy` to apply.
Structure is [documented below](#nested_ingress_to).
<a name="nested_ingress_from"></a>The `ingress_from` block supports:
* `identity_type` -
(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: `IDENTITY_TYPE_UNSPECIFIED`, `ANY_IDENTITY`, `ANY_USER_ACCOUNT`, `ANY_SERVICE_ACCOUNT`.
* `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](#nested_sources).
<a name="nested_sources"></a>The `sources` block supports:
* `access_level` -
(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/MY_POLICY/accessLevels/MY_LEVEL.`
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/{project_number}`
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.
<a name="nested_ingress_to"></a>The `ingress_to` 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](#nested_operations).
<a name="nested_operations"></a>The `operations` block supports:
* `service_name` -
(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.
* `method_selectors` -
(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](#nested_method_selectors).
<a name="nested_method_selectors"></a>The `method_selectors` 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`.
<a name="nested_egress_policies"></a>The `egress_policies` block supports:
* `egress_from` -
(Optional)
Defines conditions on the source of a request causing this `EgressPolicy` to apply.
Structure is [documented below](#nested_egress_from).
* `egress_to` -
(Optional)
Defines the conditions on the `ApiOperation` and destination resources that
cause this `EgressPolicy` to apply.
Structure is [documented below](#nested_egress_to).
<a name="nested_egress_from"></a>The `egress_from` block supports:
* `identity_type` -
(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: `IDENTITY_TYPE_UNSPECIFIED`, `ANY_IDENTITY`, `ANY_USER_ACCOUNT`, `ANY_SERVICE_ACCOUNT`.
* `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.
* `sources` -
(Optional)
Sources that this EgressPolicy authorizes access from.
Structure is [documented below](#nested_sources).
* `source_restriction` -
(Optional)
Whether to enforce traffic restrictions based on `sources` field. If the `sources` field is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.
Possible values are: `SOURCE_RESTRICTION_UNSPECIFIED`, `SOURCE_RESTRICTION_ENABLED`, `SOURCE_RESTRICTION_DISABLED`.
<a name="nested_sources"></a>The `sources` block supports:
* `access_level` -
(Optional)
An AccessLevel resource name that allows resources outside the ServicePerimeter to be accessed from the inside.
<a name="nested_egress_to"></a>The `egress_to` 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.
* `external_resources` -
(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](#nested_operations).
<a name="nested_operations"></a>The `operations` block supports:
* `service_name` -
(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.
* `method_selectors` -
(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](#nested_method_selectors).
<a name="nested_method_selectors"></a>The `method_selectors` 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 `{{parent}}/servicePerimeters`
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## Import
ServicePerimeters can be imported using any of these accepted formats:
* `{{parent}}/servicePerimeters`
* `{{parent}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import ServicePerimeters using one of the formats above. For example:
```tf
import {
id = "{{parent}}/servicePerimeters"
to = google_access_context_manager_service_perimeters.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), ServicePerimeters can be imported using one of the formats above. For example:
```
$ terraform import google_access_context_manager_service_perimeters.default {{parent}}/servicePerimeters
$ terraform import google_access_context_manager_service_perimeters.default {{parent}}
```