From 34edaf56d6bbaf329f1c5caa89cbd7dbd4238d1a Mon Sep 17 00:00:00 2001 From: Evan Brown Date: Tue, 23 Aug 2016 21:34:54 +0100 Subject: [PATCH] providers/google: Add documentation for google_iam_policy resource --- d/google_iam_policy.html.markdown | 60 ++++++++++++++++++++++++++++++ r/google_project.html.markdown | 61 +++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 d/google_iam_policy.html.markdown create mode 100644 r/google_project.html.markdown diff --git a/d/google_iam_policy.html.markdown b/d/google_iam_policy.html.markdown new file mode 100644 index 00000000..4151fdc9 --- /dev/null +++ b/d/google_iam_policy.html.markdown @@ -0,0 +1,60 @@ +--- +layout: "google" +page_title: "Google: google_iam_policy" +sidebar_current: "docs-google-datasource-iam-policy" +description: |- + Generates an IAM policy that can be referenced by other resources, applying + the policy to them. +--- + +# google\_iam\_policy + +Generates an IAM policy document that may be referenced by and applied to +other Google Cloud Platform resources, such as the `google_project` resource. + +``` +data "google_iam_policy" "admin" { + binding { + role = "roles/compute.instanceAdmin" + members = [ + "serviceAccount:your-custom-sa@your-project.iam.gserviceaccount.com", + ] + } + binding { + role = "roles/storage.objectViewer" + members = [ + "user:evanbrown@google.com", + ] + } +} +``` + +This data source is used to define IAM policies to apply to othe resources. +Currently, defining a policy through a datasource and referencing that policy +from another resource is the only way to apply an IAM policy to a resource. + +## Argument Reference + +The following arguments are supported: + +* `binding` (Required) - A nested configuration block (described below) + defining a binding to be included in the policy document. Multiple + `binding` arguments are supported. + +Each document configuration must have one or more `binding` blocks, which +each accept the following arguments: + +* `role` (Required) - The role/permission that will be granted to the members. + See the [IAM Roles](https://cloud.google.com/compute/docs/access/iam) documentation for a complete list of roles. +* `members` (Required) - An array of users/principals that will be granted + the privilege in the `role`. For a human user, prefix the user's e-mail + address with `user:` (e.g., `user:evandbrown@gmail.com`). For a service + account, prefix the service account e-mail address with `serviceAccount:` + (e.g., `serviceAccount:your-service-account@your-project.iam.gserviceaccount.com`). + +## Attributes Reference + +The following attribute is exported: + +* `policy_data` - The above bindings serialized in a format suitable for + referencing from a resource that supports IAM. diff --git a/r/google_project.html.markdown b/r/google_project.html.markdown new file mode 100644 index 00000000..72a34c5c --- /dev/null +++ b/r/google_project.html.markdown @@ -0,0 +1,61 @@ +--- +layout: "google" +page_title: "Google: google_project" +sidebar_current: "docs-google-project" +description: |- + Allows management of a Google Cloud Platform project. +--- + +# google\_project + +Allows management of an existing Google Cloud Platform project, and is +currently limited to adding or modifying the IAM Policy for the project. + +When adding a policy to a project, the policy will be merged with the +project's existing policy. The policy is always specified in a +`google_iam_policy` data source and referencd from the project's +`policy_data` attribute. + +## Example Usage + +```js +resource "google_project" "my-project" { + id = "your-project-id" + policy_data = "${data.google_iam_policy.admin.policy}" +} + +data "google_iam_policy" "admin" { + binding { + role = "roles/storage.objectViewer" + members = [ + "user:evandbrown@gmail.com", + ] + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `id` - (Required) The project ID. + Changing this forces a new project to be referenced. + +* `policy` - (Optional) The `google_iam_policy` data source that represents + the IAM policy that will be applied to the project. The policy will be + merged with any existing policy applied to the project. + + Changing this updates the policy. + + Deleting this removes the policy, but leaves the original project policy + intact. If there are overlapping `binding` entries between the original + project policy and the data source policy, they will be removed. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are +exported: + +* `name` - The name of the project. + +* `number` - The numeric identifier of the project.