-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b3ceef7
commit dda2677
Showing
5 changed files
with
179 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,12 @@ description: |- | |
|
||
# 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: | ||
Three 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. | ||
* `google_storage_bucket_iam_policy`: Setting a policy removes all other permissions on the bucket, and if done incorrectly, there's a real chance you will lock yourself out of the bucket. If possible for your use case, using multiple google_storage_bucket_iam_binding resources will be much safer. See the usage example on how to work with policy correctly. | ||
|
||
|
||
~> **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. | ||
|
||
|
@@ -38,6 +40,30 @@ resource "google_storage_bucket_iam_member" "member" { | |
} | ||
``` | ||
|
||
## google\_storage\_bucket\_iam\_policy | ||
|
||
When applying a policy that does not include the roles listed below, you lose the default permissions which google adds to your bucket: | ||
* `roles/storage.legacyBucketOwner` | ||
* `roles/storage.legacyBucketReader` | ||
|
||
If this happens only an entity with `roles/storage.admin` privileges can repair this bucket's policies. It is recommended to include the above roles in policies to get the same behaviour as with the other two options. | ||
|
||
```hcl | ||
data "google_iam_policy" "foo-policy" { | ||
binding { | ||
role = "roles/your-role" | ||
members = [ "group:[email protected]" ] | ||
} | ||
} | ||
resource "google_storage_bucket_iam_policy" "member" { | ||
bucket = "your-bucket-name" | ||
policy_data = "${data.google_iam_policy.foo-policy.policy_data}" | ||
} | ||
``` | ||
|
||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
@@ -61,4 +87,4 @@ The following arguments are supported: | |
In addition to the arguments listed above, the following computed attributes are | ||
exported: | ||
|
||
* `etag` - (Computed) The etag of the storage bucket's IAM policy. | ||
* `etag` - (Computed) The etag of the storage bucket's IAM policy. |