From 480c519fa4fe9f34154ecce1cd2c4c27189ef53a Mon Sep 17 00:00:00 2001 From: Upo Date: Tue, 14 Apr 2020 00:15:15 +0100 Subject: [PATCH] Added name field to both custom project and org roles (#3370) * added name field to both custom project and org roles * patched the schema to include computed values * Update third_party/terraform/resources/resource_google_organization_iam_custom_role.go Co-Authored-By: Cameron Thornton * Update third_party/terraform/resources/resource_google_project_iam_custom_role.go Co-Authored-By: Cameron Thornton Co-authored-by: Cameron Thornton --- .../resource_google_organization_iam_custom_role.go | 5 +++++ .../resources/resource_google_project_iam_custom_role.go | 5 +++++ .../docs/r/google_organization_iam_custom_role.html.markdown | 4 ++++ .../website/docs/r/google_project_iam.html.markdown | 3 ++- .../docs/r/google_project_iam_custom_role.html.markdown | 4 ++++ 5 files changed, 20 insertions(+), 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 bde1b7269e91..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 @@ -55,6 +55,10 @@ func resourceGoogleOrganizationIamCustomRole() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "name": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -122,6 +126,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..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 @@ -58,6 +58,10 @@ func resourceGoogleProjectIamCustomRole() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "name": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -126,6 +130,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..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,6 +60,10 @@ exported: * `deleted` - (Optional) The current deleted state of the role. +* `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 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..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,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, it is recommended to **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..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 @@ -60,6 +60,10 @@ exported: * `deleted` - (Optional) The current deleted state of the role. + * `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 Customized IAM project role can be imported using their URI, e.g.