Skip to content

Commit

Permalink
Add IAM support for storage bucket (hashicorp#822)
Browse files Browse the repository at this point in the history
* Add IAM support for storage bucket
* Add documentation
* Test multiple roles
  • Loading branch information
rosbo authored Dec 7, 2017
1 parent 1162b74 commit a5d26c8
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
63 changes: 63 additions & 0 deletions docs/r/storage_bucket_iam.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
layout: "google"
page_title: "Google: google_storage_bucket_iam"
sidebar_current: "docs-google-storage-bucket-iam"
description: |-
Collection of resources to manage IAM policy for a Google storage bucket.
---

# IAM policy for Google storage bucket

Two different resources help you manage your IAM policy for storage bucket. Each of these resources serves a different use case:

* `google_storage_bucket_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 storage bucket are preserved.
* `google_storage_bucket_iam_member`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the storage bucket are preserved.

~> **Note:** `google_storage_bucket_iam_binding` resources **can be** used in conjunction with `google_storage_bucket_iam_member` resources **only if** they do not grant privilege to the same role.

## google\_storage\_bucket\_iam\_binding

```hcl
resource "google_storage_bucket_iam_binding" "binding" {
bucket = "your-bucket-name"
role = "roles/storage.objectViewer"
members = [
"user:[email protected]",
]
}
```

## google\_storage\_bucket\_iam\_member

```hcl
resource "google_storage_bucket_iam_member" "member" {
bucket = "your-bucket-name"
role = "roles/storage.objectViewer"
member = "user:[email protected]"
}
```

## Argument Reference

The following arguments are supported:

* `bucket` - (Required) The name of the bucket it applies to.

* `member/members` - (Required) Identities that will be granted the privilege in `role`.
Each entry can have one of the following values:
* **allUsers**: A special identifier that represents anyone who is on the internet; with or without a Google account.
* **allAuthenticatedUsers**: A special identifier that represents anyone who is authenticated with a Google account or a service account.
* **user:{emailid}**: An email address that represents a specific Google account. For example, [email protected] or [email protected].
* **serviceAccount:{emailid}**: An email address that represents a service account. For example, [email protected].
* **group:{emailid}**: An email address that represents a Google group. For example, [email protected].
* **domain:{domain}**: A Google Apps domain name that represents all the users of that domain. For example, google.com or example.com.

* `role` - (Required) The role that should be applied.

## Attributes Reference

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

* `etag` - (Computed) The etag of the storage bucket's IAM policy.
16 changes: 15 additions & 1 deletion google.erb
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@
<a href="/docs/providers/google/r/storage_bucket_acl.html">google_storage_bucket_acl</a>
</li>

<li<%= sidebar_current("docs-google-storage-bucket-iam") %>>
<a href="/docs/providers/google/r/storage_bucket_iam.html">google_storage_bucket_iam_binding</a>
</li>

<li<%= sidebar_current("docs-google-storage-bucket-iam") %>>
<a href="/docs/providers/google/r/storage_bucket_iam.html">google_storage_bucket_iam_member</a>
</li>

<li<%= sidebar_current("docs-google-storage-bucket-object") %>>
<a href="/docs/providers/google/r/storage_bucket_object.html">google_storage_bucket_object</a>
</li>
Expand All @@ -451,7 +459,13 @@
<a href="/docs/providers/google/r/google_kms_key_ring.html">google_kms_key_ring</a>
</li>
<li<%= sidebar_current("docs-google-kms-key-ring-iam") %>>
<a href="/docs/providers/google/r/google_kms_key_ring_iam.html">google_kms_key_ring_iam_*</a>
<a href="/docs/providers/google/r/google_kms_key_ring_iam.html">google_kms_key_ring_iam_binding</a>
</li>
<li<%= sidebar_current("docs-google-kms-key-ring-iam") %>>
<a href="/docs/providers/google/r/google_kms_key_ring_iam.html">google_kms_key_ring_iam_member</a>
</li>
<li<%= sidebar_current("docs-google-kms-key-ring-iam") %>>
<a href="/docs/providers/google/r/google_kms_key_ring_iam.html">google_kms_key_ring_iam_policy</a>
</li>
<li<%= sidebar_current("docs-google-kms-crypto-key-x") %>>
<a href="/docs/providers/google/r/google_kms_crypto_key.html">google_kms_crypto_key</a>
Expand Down

0 comments on commit a5d26c8

Please sign in to comment.