Skip to content

Commit fe800f5

Browse files
Add new resource iam_projects_policy_binding. addresses #20198 (#12302) (#20438)
[upstream:bd1c0c0ca95b750d88a138997f5ef26dbac35db0] Signed-off-by: Modular Magician <[email protected]>
1 parent ff576ca commit fe800f5

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed

.changelog/12302.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_iam_projects_policy_binding` (beta)
3+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package iam3_test
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This file is automatically generated by Magic Modules and manual
9+
# changes will be clobbered when the file is regenerated.
10+
#
11+
# Please read more about how to change this file in
12+
# .github/CONTRIBUTING.md.
13+
#
14+
# ----------------------------------------------------------------------------
15+
subcategory: "Cloud IAM"
16+
description: |-
17+
A policy binding to a Project
18+
---
19+
20+
# google_iam_projects_policy_binding
21+
22+
A policy binding to a Project
23+
24+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
25+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
26+
27+
To get more information about ProjectsPolicyBinding, see:
28+
29+
* [API documentation](https://cloud.google.com/iam/docs/reference/rest/v3beta/projects.locations.policyBindings)
30+
* How-to Guides
31+
* [Apply a policy binding](https://cloud.google.com/iam/docs/principal-access-boundary-policies-create#create_binding)
32+
33+
## Example Usage - Iam Projects Policy Binding
34+
35+
36+
```hcl
37+
data "google_project" "project" {
38+
provider = google-beta
39+
}
40+
41+
resource "google_iam_principal_access_boundary_policy" "pab_policy" {
42+
provider = google-beta
43+
organization = "123456789"
44+
location = "global"
45+
display_name = "test project binding"
46+
principal_access_boundary_policy_id = "my-pab-policy"
47+
}
48+
49+
resource "google_iam_projects_policy_binding" "my-project-binding" {
50+
provider = google-beta
51+
project = data.google_project.project.project_id
52+
location = "global"
53+
display_name = "test project binding"
54+
policy_kind = "PRINCIPAL_ACCESS_BOUNDARY"
55+
policy_binding_id = "test-project-binding"
56+
policy = "organizations/123456789/locations/global/principalAccessBoundaryPolicies/${google_iam_principal_access_boundary_policy.pab_policy.principal_access_boundary_policy_id}"
57+
target {
58+
principal_set = "//cloudresourcemanager.googleapis.com/projects/${data.google_project.project.project_id}"
59+
}
60+
}
61+
```
62+
63+
## Argument Reference
64+
65+
The following arguments are supported:
66+
67+
68+
* `target` -
69+
(Required)
70+
Target is the full resource name of the resource to which the policy will be bound. Immutable once set.
71+
Structure is [documented below](#nested_target).
72+
73+
* `policy` -
74+
(Required)
75+
Required. Immutable. The resource name of the policy to be bound. The binding parent and policy must belong to the same Organization (or Project).
76+
77+
* `location` -
78+
(Required)
79+
The location of the Policy Binding
80+
81+
* `policy_binding_id` -
82+
(Required)
83+
The Policy Binding ID.
84+
85+
86+
<a name="nested_target"></a>The `target` block supports:
87+
88+
* `principal_set` -
89+
(Optional)
90+
Required. Immutable. The resource name of the policy to be bound.
91+
The binding parent and policy must belong to the same Organization (or Project).
92+
93+
- - -
94+
95+
96+
* `display_name` -
97+
(Optional)
98+
Optional. The description of the policy binding. Must be less than or equal to 63 characters.
99+
100+
* `annotations` -
101+
(Optional)
102+
Optional. User defined annotations. See https://google.aip.dev/148#annotations for more details such as format and size limitations
103+
104+
**Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
105+
Please refer to the field `effective_annotations` for all of the annotations present on the resource.
106+
107+
* `policy_kind` -
108+
(Optional)
109+
Immutable. The kind of the policy to attach in this binding. This
110+
field must be one of the following: - Left empty (will be automatically set
111+
to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSPECIFIED PRINCIPAL_ACCESS_BOUNDARY ACCESS
112+
113+
* `condition` -
114+
(Optional)
115+
Represents a textual expression in the Common Expression Language
116+
(CEL) syntax. CEL is a C-like expression language. The syntax and semantics of
117+
CEL are documented at https://github.com/google/cel-spec.
118+
Example (Comparison):
119+
title: \"Summary size limit\"
120+
description: \"Determines if a summary is less than 100 chars\"
121+
expression: \"document.summary.size() < 100\"
122+
Example
123+
(Equality):
124+
title: \"Requestor is owner\"
125+
description: \"Determines if requestor is the document owner\"
126+
expression: \"document.owner == request.auth.claims.email\" Example
127+
(Logic):
128+
title: \"Public documents\"
129+
description: \"Determine whether the document should be publicly visible\"
130+
expression: \"document.type != 'private' && document.type != 'internal'\"
131+
Example (Data Manipulation):
132+
title: \"Notification string\"
133+
description: \"Create a notification string with a timestamp.\"
134+
expression: \"'New message received at ' + string(document.create_time)\"
135+
The exact variables and functions that may be referenced within an expression are
136+
determined by the service that evaluates it. See the service documentation for
137+
additional information.
138+
Structure is [documented below](#nested_condition).
139+
140+
* `project` - (Optional) The ID of the project in which the resource belongs.
141+
If it is not provided, the provider project is used.
142+
143+
144+
<a name="nested_condition"></a>The `condition` block supports:
145+
146+
* `expression` -
147+
(Optional)
148+
Textual representation of an expression in Common Expression Language syntax.
149+
150+
* `title` -
151+
(Optional)
152+
Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
153+
154+
* `description` -
155+
(Optional)
156+
Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
157+
158+
* `location` -
159+
(Optional)
160+
Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
161+
162+
## Attributes Reference
163+
164+
In addition to the arguments listed above, the following computed attributes are exported:
165+
166+
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}`
167+
168+
* `name` -
169+
The name of the policy binding in the format `{binding_parent/locations/{location}/policyBindings/{policy_binding_id}`
170+
171+
* `uid` -
172+
Output only. The globally unique ID of the policy binding. Assigned when the policy binding is created.
173+
174+
* `etag` -
175+
Optional. The etag for the policy binding. If this is provided on update, it must match the server's etag.
176+
177+
* `policy_uid` -
178+
Output only. The globally unique ID of the policy to be bound.
179+
180+
* `create_time` -
181+
Output only. The time when the policy binding was created.
182+
183+
* `update_time` -
184+
Output only. The time when the policy binding was most recently updated.
185+
186+
* `effective_annotations` -
187+
All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services.
188+
189+
190+
## Timeouts
191+
192+
This resource provides the following
193+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
194+
195+
- `create` - Default is 20 minutes.
196+
- `update` - Default is 20 minutes.
197+
- `delete` - Default is 20 minutes.
198+
199+
## Import
200+
201+
202+
ProjectsPolicyBinding can be imported using any of these accepted formats:
203+
204+
* `projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}`
205+
* `{{project}}/{{location}}/{{policy_binding_id}}`
206+
* `{{location}}/{{policy_binding_id}}`
207+
208+
209+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import ProjectsPolicyBinding using one of the formats above. For example:
210+
211+
```tf
212+
import {
213+
id = "projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}"
214+
to = google_iam_projects_policy_binding.default
215+
}
216+
```
217+
218+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), ProjectsPolicyBinding can be imported using one of the formats above. For example:
219+
220+
```
221+
$ terraform import google_iam_projects_policy_binding.default projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}
222+
$ terraform import google_iam_projects_policy_binding.default {{project}}/{{location}}/{{policy_binding_id}}
223+
$ terraform import google_iam_projects_policy_binding.default {{location}}/{{policy_binding_id}}
224+
```
225+
226+
## User Project Overrides
227+
228+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)