From 43396b754226df36e8b936ffc55f5b100a6f515f Mon Sep 17 00:00:00 2001 From: Upo Date: Sun, 12 Apr 2020 13:56:50 +0100 Subject: [PATCH 1/4] added name field to both custom project and org roles --- .../resources/resource_google_organization_iam_custom_role.go | 1 + .../resources/resource_google_project_iam_custom_role.go | 1 + .../docs/r/google_organization_iam_custom_role.html.markdown | 2 ++ .../terraform/website/docs/r/google_project_iam.html.markdown | 3 ++- .../docs/r/google_project_iam_custom_role.html.markdown | 4 +++- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go index bde1b7269e91..4feeb1341a12 100644 --- a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go @@ -122,6 +122,7 @@ func resourceGoogleOrganizationIamCustomRoleRead(d *schema.ResourceData, meta in d.Set("role_id", parsedRoleName.Name) d.Set("org_id", parsedRoleName.OrgId) d.Set("title", role.Title) + d.Set("name", role.Name) d.Set("description", role.Description) d.Set("permissions", role.IncludedPermissions) d.Set("stage", role.Stage) diff --git a/third_party/terraform/resources/resource_google_project_iam_custom_role.go b/third_party/terraform/resources/resource_google_project_iam_custom_role.go index c3df43e2a3f7..794278b4120a 100644 --- a/third_party/terraform/resources/resource_google_project_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_project_iam_custom_role.go @@ -126,6 +126,7 @@ func resourceGoogleProjectIamCustomRoleRead(d *schema.ResourceData, meta interfa d.Set("role_id", GetResourceNameFromSelfLink(role.Name)) d.Set("title", role.Title) + d.Set("name", role.Name) d.Set("description", role.Description) d.Set("permissions", role.IncludedPermissions) d.Set("stage", role.Stage) diff --git a/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown b/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown index 69a007ad5f6a..b7961d20037d 100644 --- a/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown +++ b/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown @@ -60,6 +60,8 @@ exported: * `deleted` - (Optional) The current deleted state of the role. +* `name` - The name of the role which can be used with iam role bindings in the format `organizations/{{org_id}}/roles/{{role_id}}` + ## Import Customized IAM organization role can be imported using their URI, e.g. diff --git a/third_party/terraform/website/docs/r/google_project_iam.html.markdown b/third_party/terraform/website/docs/r/google_project_iam.html.markdown index 14a427b82d7b..158db6c1fad6 100644 --- a/third_party/terraform/website/docs/r/google_project_iam.html.markdown +++ b/third_party/terraform/website/docs/r/google_project_iam.html.markdown @@ -28,7 +28,8 @@ Four different resources help you manage your IAM policy for a project. Each of from anyone without organization-level access to the project. Proceed with caution. It's not recommended to use `google_project_iam_policy` with your provider project to avoid locking yourself out, and it should generally only be used with projects - fully managed by Terraform. + fully managed by Terraform. If you do use this resource, **import** the policy before + applying the change. ```hcl resource "google_project_iam_policy" "project" { diff --git a/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown b/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown index d4dd6c8ed557..4b79c81ef375 100644 --- a/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown +++ b/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown @@ -49,7 +49,7 @@ The following arguments are supported: * `stage` - (Optional) The current launch stage of the role. Defaults to `GA`. - List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage). + List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/projects.roles#Role.RoleLaunchStage). * `description` - (Optional) A human-readable description for the role. @@ -60,6 +60,8 @@ exported: * `deleted` - (Optional) The current deleted state of the role. + * `name` - The name of the role which can be used with iam role bindings in the format `projects/{{project}}/roles/{{role_id}}` + ## Import Customized IAM project role can be imported using their URI, e.g. From 0d06b29b9517029830e60275c0ee382ba00b0cd8 Mon Sep 17 00:00:00 2001 From: Upo Date: Mon, 13 Apr 2020 23:31:11 +0100 Subject: [PATCH 2/4] patched the schema to include computed values --- .../resource_google_organization_iam_custom_role.go | 4 ++++ .../resources/resource_google_project_iam_custom_role.go | 4 ++++ .../r/google_organization_iam_custom_role.html.markdown | 4 +++- .../website/docs/r/google_project_iam.html.markdown | 2 +- .../docs/r/google_project_iam_custom_role.html.markdown | 6 ++++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go index 4feeb1341a12..d7f5d61ff910 100644 --- a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go @@ -55,6 +55,10 @@ func resourceGoogleOrganizationIamCustomRole() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "name": { + Type: schema.TypeBool, + Computed: true, + }, }, } } diff --git a/third_party/terraform/resources/resource_google_project_iam_custom_role.go b/third_party/terraform/resources/resource_google_project_iam_custom_role.go index 794278b4120a..e7eb5c4b24d4 100644 --- a/third_party/terraform/resources/resource_google_project_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_project_iam_custom_role.go @@ -58,6 +58,10 @@ func resourceGoogleProjectIamCustomRole() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "name": { + Type: schema.TypeBool, + Computed: true, + }, }, } } diff --git a/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown b/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown index b7961d20037d..59b0591ca325 100644 --- a/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown +++ b/third_party/terraform/website/docs/r/google_organization_iam_custom_role.html.markdown @@ -60,7 +60,9 @@ exported: * `deleted` - (Optional) The current deleted state of the role. -* `name` - The name of the role which can be used with iam role bindings in the format `organizations/{{org_id}}/roles/{{role_id}}` +* `id` - an identifier for the resource with the format `organizations/{{org_id}}/roles/{{role_id}}` + +* `name` - The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings. ## Import diff --git a/third_party/terraform/website/docs/r/google_project_iam.html.markdown b/third_party/terraform/website/docs/r/google_project_iam.html.markdown index 158db6c1fad6..f94e6c151e1e 100644 --- a/third_party/terraform/website/docs/r/google_project_iam.html.markdown +++ b/third_party/terraform/website/docs/r/google_project_iam.html.markdown @@ -28,7 +28,7 @@ Four different resources help you manage your IAM policy for a project. Each of from anyone without organization-level access to the project. Proceed with caution. It's not recommended to use `google_project_iam_policy` with your provider project to avoid locking yourself out, and it should generally only be used with projects - fully managed by Terraform. If you do use this resource, **import** the policy before + fully managed by Terraform. If you do use this resource, it is recommended to **import** the policy before applying the change. ```hcl diff --git a/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown b/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown index 4b79c81ef375..d4081d15ec23 100644 --- a/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown +++ b/third_party/terraform/website/docs/r/google_project_iam_custom_role.html.markdown @@ -49,7 +49,7 @@ The following arguments are supported: * `stage` - (Optional) The current launch stage of the role. Defaults to `GA`. - List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/projects.roles#Role.RoleLaunchStage). + List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage). * `description` - (Optional) A human-readable description for the role. @@ -60,7 +60,9 @@ exported: * `deleted` - (Optional) The current deleted state of the role. - * `name` - The name of the role which can be used with iam role bindings in the format `projects/{{project}}/roles/{{role_id}}` + * `id` - an identifier for the resource with the format `projects/{{project}}/roles/{{role_id}}` + + * `name` - The name of the role in the format `projects/{{project}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings. ## Import From e290faf09efda817a2ca2f68e50df79411728778 Mon Sep 17 00:00:00 2001 From: Upo Date: Mon, 13 Apr 2020 23:53:28 +0100 Subject: [PATCH 3/4] Update third_party/terraform/resources/resource_google_organization_iam_custom_role.go Co-Authored-By: Cameron Thornton --- .../resources/resource_google_organization_iam_custom_role.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go index d7f5d61ff910..6582ea4af3ea 100644 --- a/third_party/terraform/resources/resource_google_organization_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_organization_iam_custom_role.go @@ -56,7 +56,7 @@ func resourceGoogleOrganizationIamCustomRole() *schema.Resource { Computed: true, }, "name": { - Type: schema.TypeBool, + Type: schema.TypeString, Computed: true, }, }, From 72c12892c807b68f91ca841d767ac488c7de65bd Mon Sep 17 00:00:00 2001 From: Upo Date: Mon, 13 Apr 2020 23:53:40 +0100 Subject: [PATCH 4/4] Update third_party/terraform/resources/resource_google_project_iam_custom_role.go Co-Authored-By: Cameron Thornton --- .../resources/resource_google_project_iam_custom_role.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/terraform/resources/resource_google_project_iam_custom_role.go b/third_party/terraform/resources/resource_google_project_iam_custom_role.go index e7eb5c4b24d4..5879ff62d4b5 100644 --- a/third_party/terraform/resources/resource_google_project_iam_custom_role.go +++ b/third_party/terraform/resources/resource_google_project_iam_custom_role.go @@ -59,7 +59,7 @@ func resourceGoogleProjectIamCustomRole() *schema.Resource { Computed: true, }, "name": { - Type: schema.TypeBool, + Type: schema.TypeString, Computed: true, }, },