Skip to content

Commit d86bbb2

Browse files
authored
Merge pull request hashicorp#1387 from terraform-providers/paddy_spanner_instance_iam
Add support for IAM on Spanner Instances.
2 parents 1335801 + 170cef5 commit d86bbb2

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
layout: "google"
3+
page_title: "Google: google_spanner_instance_iam"
4+
sidebar_current: "docs-google-spanner-instance-iam"
5+
description: |-
6+
Collection of resources to manage IAM policy for a Spanner instance.
7+
---
8+
9+
# IAM policy for Spanner Instances
10+
11+
Three different resources help you manage your IAM policy for a Spanner instance. Each of these resources serves a different use case:
12+
13+
* `google_spanner_instance_iam_policy`: Authoritative. Sets the IAM policy for the instance and replaces any existing policy already attached.
14+
15+
~> **Warning:** It's entirely possibly to lock yourself out of your instance using `google_spanner_instance_iam_policy`. Any permissions granted by default will be removed unless you include them in your config.
16+
17+
* `google_spanner_instance_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 instance are preserved.
18+
* `google_spanner_instance_iam_member`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the instance are preserved.
19+
20+
~> **Note:** `google_spanner_instance_iam_policy` **cannot** be used in conjunction with `google_spanner_instance_iam_binding` and `google_spanner_instance_iam_member` or they will fight over what your policy should be.
21+
22+
~> **Note:** `google_spanner_instance_iam_binding` resources **can be** used in conjunction with `google_spanner_instance_iam_member` resources **only if** they do not grant privilege to the same role.
23+
24+
## google\_spanner\_instance\_iam\_policy
25+
26+
```hcl
27+
data "google_iam_policy" "admin" {
28+
binding {
29+
role = "roles/editor"
30+
31+
members = [
32+
33+
]
34+
}
35+
}
36+
37+
resource "google_spanner_instance_iam_policy" "instance" {
38+
instance = "your-instance-name"
39+
policy_data = "${data.google_iam_policy.admin.policy_data}"
40+
}
41+
```
42+
43+
## google\_spanner\_instance\_iam\_binding
44+
45+
```hcl
46+
resource "google_spanner_instance_iam_binding" "instance" {
47+
instance = "your-instance-name"
48+
role = "roles/compute.networkUser"
49+
50+
members = [
51+
52+
]
53+
}
54+
```
55+
56+
## google\_spanner\_instance\_iam\_member
57+
58+
```hcl
59+
resource "google_spanner_instance_iam_member" "instance" {
60+
instance = "your-instance-name"
61+
role = "roles/compute.networkUser"
62+
member = "user:[email protected]"
63+
}
64+
```
65+
66+
## Argument Reference
67+
68+
The following arguments are supported:
69+
70+
* `instance` - (Required) The name of the instance.
71+
72+
* `member/members` - (Required) Identities that will be granted the privilege in `role`.
73+
Each entry can have one of the following values:
74+
* **allUsers**: A special identifier that represents anyone who is on the internet; with or without a Google account.
75+
* **allAuthenticatedUsers**: A special identifier that represents anyone who is authenticated with a Google account or a service account.
76+
* **user:{emailid}**: An email address that represents a specific Google account. For example, [email protected] or [email protected].
77+
* **serviceAccount:{emailid}**: An email address that represents a service account. For example, [email protected].
78+
* **group:{emailid}**: An email address that represents a Google group. For example, [email protected].
79+
* **domain:{domain}**: A Google Apps domain name that represents all the users of that domain. For example, google.com or example.com.
80+
81+
* `role` - (Required) The role that should be applied. Only one
82+
`google_spanner_instance_iam_binding` can be used per role. Note that custom roles must be of the format
83+
`[projects|organizations]/{parent-name}/roles/{role-name}`.
84+
85+
* `policy_data` - (Required only by `google_spanner_instance_iam_policy`) The policy data generated by
86+
a `google_iam_policy` data source.
87+
88+
* `project` - (Optional) The ID of the project in which the resource belongs. If it
89+
is not provided, the provider project is used.
90+
91+
## Attributes Reference
92+
93+
In addition to the arguments listed above, the following computed attributes are
94+
exported:
95+
96+
* `etag` - (Computed) The etag of the instance's IAM policy.
97+
98+
## Import
99+
100+
For all import syntaxes, the "resource in question" can take any of the following forms:
101+
102+
* {{project}}/{{name}}
103+
* {{name}} (project is taken from provider project)
104+
105+
IAM member imports use space-delimited identifiers; the resource in question, the role, and the account, e.g.
106+
107+
```
108+
$ terraform import google_spanner_instance_iam_member.instance "project-name/instance-name roles/viewer [email protected]"
109+
```
110+
111+
IAM binding imports use space-delimited identifiers; the resource in question and the role, e.g.
112+
113+
```
114+
$ terraform import google_spanner_instance_iam_binding.instance "project-name/instance-name roles/viewer"
115+
```
116+
117+
IAM policy imports use the identifier of the resource in question, e.g.
118+
119+
```
120+
$ terraform import google_spanner_instance_iam_policy.instance project-name/instance-name
121+
```

google.erb

+9
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,15 @@
536536
<li<%= sidebar_current("docs-google-spanner-instance") %>>
537537
<a href="/docs/providers/google/r/spanner_instance.html">google_spanner_instance</a>
538538
</li>
539+
<li<%= sidebar_current("docs-google-spanner-instance-iam") %>>
540+
<a href="/docs/providers/google/r/spanner_instance_iam.html">google_spanner_instance_iam_binding</a>
541+
</li>
542+
<li<%= sidebar_current("docs-google-spanner-instance-iam") %>>
543+
<a href="/docs/providers/google/r/spanner_instance_iam.html">google_spanner_instance_iam_member</a>
544+
</li>
545+
<li<%= sidebar_current("docs-google-spanner-instance-iam") %>>
546+
<a href="/docs/providers/google/r/spanner_instance_iam.html">google_spanner_instance_iam_policy</a>
547+
</li>
539548
</ul>
540549
</li>
541550

0 commit comments

Comments
 (0)