Skip to content

Commit 14ad733

Browse files
Update documentation for Folder and Organization IAM resources. (#3844) (#2365)
Signed-off-by: Modular Magician <[email protected]>
1 parent 181fa81 commit 14ad733

12 files changed

+489
-521
lines changed

.changelog/3844.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource-manager: updated documentation for `folder_iam_*` and `organization_iam_*` resources.
3+
```
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
---
2+
subcategory: "Cloud Platform"
3+
layout: "google"
4+
page_title: "Google: google_folder_iam"
5+
sidebar_current: "docs-google-folder-iam"
6+
description: |-
7+
Collection of resources to manage IAM policy for a folder.
8+
---
9+
10+
# IAM policy for folders
11+
12+
Four different resources help you manage your IAM policy for a folder. Each of these resources serves a different use case:
13+
14+
* `google_folder_iam_policy`: Authoritative. Sets the IAM policy for the folder and replaces any existing policy already attached.
15+
* `google_folder_iam_binding`: Authoritative for a given role. Updates the IAM policy to grant a role to a list of members. Other roles within the IAM policy for the folder are preserved.
16+
* `google_folder_iam_member`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the folder are preserved.
17+
* `google_folder_iam_audit_config`: Authoritative for a given service. Updates the IAM policy to enable audit logging for the given service.
18+
19+
20+
~> **Note:** `google_folder_iam_policy` **cannot** be used in conjunction with `google_folder_iam_binding`, `google_folder_iam_member`, or `google_folder_iam_audit_config` or they will fight over what your policy should be.
21+
22+
~> **Note:** `google_folder_iam_binding` resources **can be** used in conjunction with `google_folder_iam_member` resources **only if** they do not grant privilege to the same role.
23+
24+
## google\_folder\_iam\_policy
25+
26+
~> **Be careful!** You can accidentally lock yourself out of your folder
27+
using this resource. Deleting a `google_folder_iam_policy` removes access
28+
from anyone without folder-level access to the folder. Proceed with caution.
29+
It's not recommended to use `google_folder_iam_policy` with your provider folder
30+
to avoid locking yourself out, and it should generally only be used with folders
31+
fully managed by Terraform. If you do use this resource, it is recommended to **import** the policy before
32+
applying the change.
33+
34+
```hcl
35+
resource "google_folder_iam_policy" "folder" {
36+
folder = "folders/1234567"
37+
policy_data = data.google_iam_policy.admin.policy_data
38+
}
39+
40+
data "google_iam_policy" "admin" {
41+
binding {
42+
role = "roles/editor"
43+
44+
members = [
45+
46+
]
47+
}
48+
}
49+
```
50+
51+
With IAM Conditions:
52+
53+
```hcl
54+
resource "google_folder_iam_policy" "folder" {
55+
folder = "folders/1234567"
56+
policy_data = "${data.google_iam_policy.admin.policy_data}"
57+
}
58+
59+
data "google_iam_policy" "admin" {
60+
binding {
61+
role = "roles/editor"
62+
63+
members = [
64+
65+
]
66+
67+
condition {
68+
title = "expires_after_2019_12_31"
69+
description = "Expiring at midnight of 2019-12-31"
70+
expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")"
71+
}
72+
}
73+
}
74+
```
75+
76+
## google\_folder\_iam\_binding
77+
78+
```hcl
79+
resource "google_folder_iam_binding" "folder" {
80+
folder = "folders/1234567"
81+
role = "roles/editor"
82+
83+
members = [
84+
85+
]
86+
}
87+
```
88+
89+
With IAM Conditions:
90+
91+
```hcl
92+
resource "google_folder_iam_binding" "folder" {
93+
folder = "folders/1234567"
94+
role = "roles/editor"
95+
96+
members = [
97+
98+
]
99+
100+
condition {
101+
title = "expires_after_2019_12_31"
102+
description = "Expiring at midnight of 2019-12-31"
103+
expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")"
104+
}
105+
}
106+
```
107+
108+
## google\_folder\_iam\_member
109+
110+
```hcl
111+
resource "google_folder_iam_member" "folder" {
112+
folder = "folders/1234567"
113+
role = "roles/editor"
114+
member = "user:[email protected]"
115+
}
116+
```
117+
118+
With IAM Conditions:
119+
120+
```hcl
121+
resource "google_folder_iam_member" "folder" {
122+
folder = "folders/1234567"
123+
role = "roles/editor"
124+
member = "user:[email protected]"
125+
126+
condition {
127+
title = "expires_after_2019_12_31"
128+
description = "Expiring at midnight of 2019-12-31"
129+
expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")"
130+
}
131+
}
132+
```
133+
134+
## google\_folder\_iam\_audit\_config
135+
136+
```hcl
137+
resource "google_folder_iam_audit_config" "folder" {
138+
folder = "folders/1234567"
139+
service = "allServices"
140+
audit_log_config {
141+
log_type = "ADMIN_READ"
142+
}
143+
audit_log_config {
144+
log_type = "DATA_READ"
145+
exempted_members = [
146+
147+
]
148+
}
149+
}
150+
```
151+
152+
## Argument Reference
153+
154+
The following arguments are supported:
155+
156+
* `member/members` - (Required except for google\_folder\_iam\_audit\_config) Identities that will be granted the privilege in `role`.
157+
Each entry can have one of the following values:
158+
* **user:{emailid}**: An email address that represents a specific Google account. For example, [email protected] or [email protected].
159+
* **serviceAccount:{emailid}**: An email address that represents a service account. For example, [email protected].
160+
* **group:{emailid}**: An email address that represents a Google group. For example, [email protected].
161+
* **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com.
162+
163+
* `role` - (Required except for google\_folder\_iam\_audit\_config) The role that should be applied. Only one
164+
`google_folder_iam_binding` can be used per role. Note that custom roles must be of the format
165+
`organizations/{{org_id}}/roles/{{role_id}}`.
166+
167+
* `policy_data` - (Required only by `google_folder_iam_policy`) The `google_iam_policy` data source that represents
168+
the IAM policy that will be applied to the folder. The policy will be
169+
merged with any existing policy applied to the folder.
170+
171+
Changing this updates the policy.
172+
173+
Deleting this removes all policies from the folder, locking out users without
174+
folder-level access.
175+
176+
* `folder` - (Required) The resource name of the folder the policy is attached to. Its format is folders/{folder_id}.
177+
178+
* `service` - (Required only by google\_folder\_iam\_audit\_config) Service which will be enabled for audit logging. The special value `allServices` covers all services. Note that if there are google\_folder\_iam\_audit\_config resources covering both `allServices` and a specific service then the union of the two AuditConfigs is used for that service: the `log_types` specified in each `audit_log_config` are enabled, and the `exempted_members` in each `audit_log_config` are exempted.
179+
180+
* `audit_log_config` - (Required only by google\_folder\_iam\_audit\_config) The configuration for logging of each type of permission. This can be specified multiple times. Structure is documented below.
181+
182+
* `condition` - (Optional) An [IAM Condition](https://cloud.google.com/iam/docs/conditions-overview) for a given binding.
183+
Structure is documented below.
184+
185+
---
186+
187+
The `audit_log_config` block supports:
188+
189+
* `log_type` - (Required) Permission type for which logging is to be configured. Must be one of `DATA_READ`, `DATA_WRITE`, or `ADMIN_READ`.
190+
191+
* `exempted_members` - (Optional) Identities that do not cause logging for this type of permission. The format is the same as that for `members`.
192+
193+
The `condition` block supports:
194+
195+
* `expression` - (Required) Textual representation of an expression in Common Expression Language syntax.
196+
197+
* `title` - (Required) A title for the expression, i.e. a short string describing its purpose.
198+
199+
* `description` - (Optional) An optional description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
200+
201+
~> **Warning:** Terraform considers the `role` and condition contents (`title`+`description`+`expression`) as the
202+
identifier for the binding. This means that if any part of the condition is changed out-of-band, Terraform will
203+
consider it to be an entirely different resource and will treat it as such.
204+
205+
## Attributes Reference
206+
207+
In addition to the arguments listed above, the following computed attributes are
208+
exported:
209+
210+
* `etag` - (Computed) The etag of the folder's IAM policy.
211+
212+
213+
## Import
214+
215+
IAM member imports use space-delimited identifiers; the resource in question, the role, and the account. This member resource can be imported using the `folder`, role, and member e.g.
216+
217+
```
218+
$ terraform import google_folder_iam_member.my_folder "folder roles/viewer user:[email protected]"
219+
```
220+
221+
IAM binding imports use space-delimited identifiers; the resource in question and the role. This binding resource can be imported using the `folder` and role, e.g.
222+
223+
```
224+
terraform import google_folder_iam_binding.my_folder "folder roles/viewer"
225+
```
226+
227+
IAM policy imports use the identifier of the resource in question. This policy resource can be imported using the `folder`.
228+
229+
```
230+
$ terraform import google_folder_iam_policy.my_folder folder
231+
```
232+
233+
IAM audit config imports use the identifier of the resource in question and the service, e.g.
234+
235+
```
236+
terraform import google_folder_iam_audit_config.my_folder "folder foo.googleapis.com"
237+
```
238+
239+
-> **Custom Roles**: If you're importing a IAM resource with a custom role, make sure to use the
240+
full name of the custom role, e.g. `organizations/{{org_id}}/roles/{{role_id}}`.

website/docs/r/google_folder_iam_audit_config.html.markdown

Lines changed: 0 additions & 55 deletions
This file was deleted.

website/docs/r/google_folder_iam_binding.html.markdown

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)