Skip to content

Commit 60816e5

Browse files
Added name field to both custom project and org roles (#3370) (#1951)
* 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 <[email protected]> * Update third_party/terraform/resources/resource_google_project_iam_custom_role.go Co-Authored-By: Cameron Thornton <[email protected]> Co-authored-by: Cameron Thornton <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Cameron Thornton <[email protected]>
1 parent 051877b commit 60816e5

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

.changelog/3370.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:enhancement
2+
iam: Added `name` field to `google_project_iam_custom_role`
3+
iam: Added `name` field to `google_organization_iam_custom_role`
4+
```

google-beta/resource_google_organization_iam_custom_role.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func resourceGoogleOrganizationIamCustomRole() *schema.Resource {
5555
Type: schema.TypeBool,
5656
Computed: true,
5757
},
58+
"name": {
59+
Type: schema.TypeString,
60+
Computed: true,
61+
},
5862
},
5963
}
6064
}
@@ -122,6 +126,7 @@ func resourceGoogleOrganizationIamCustomRoleRead(d *schema.ResourceData, meta in
122126
d.Set("role_id", parsedRoleName.Name)
123127
d.Set("org_id", parsedRoleName.OrgId)
124128
d.Set("title", role.Title)
129+
d.Set("name", role.Name)
125130
d.Set("description", role.Description)
126131
d.Set("permissions", role.IncludedPermissions)
127132
d.Set("stage", role.Stage)

google-beta/resource_google_project_iam_custom_role.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ func resourceGoogleProjectIamCustomRole() *schema.Resource {
5858
Type: schema.TypeBool,
5959
Computed: true,
6060
},
61+
"name": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
},
6165
},
6266
}
6367
}
@@ -126,6 +130,7 @@ func resourceGoogleProjectIamCustomRoleRead(d *schema.ResourceData, meta interfa
126130

127131
d.Set("role_id", GetResourceNameFromSelfLink(role.Name))
128132
d.Set("title", role.Title)
133+
d.Set("name", role.Name)
129134
d.Set("description", role.Description)
130135
d.Set("permissions", role.IncludedPermissions)
131136
d.Set("stage", role.Stage)

website/docs/r/google_organization_iam_custom_role.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ exported:
6060

6161
* `deleted` - (Optional) The current deleted state of the role.
6262

63+
* `id` - an identifier for the resource with the format `organizations/{{org_id}}/roles/{{role_id}}`
64+
65+
* `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.
66+
6367
## Import
6468

6569
Customized IAM organization role can be imported using their URI, e.g.

website/docs/r/google_project_iam.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Four different resources help you manage your IAM policy for a project. Each of
2828
from anyone without organization-level access to the project. Proceed with caution.
2929
It's not recommended to use `google_project_iam_policy` with your provider project
3030
to avoid locking yourself out, and it should generally only be used with projects
31-
fully managed by Terraform.
31+
fully managed by Terraform. If you do use this resource, it is recommended to **import** the policy before
32+
applying the change.
3233

3334
```hcl
3435
resource "google_project_iam_policy" "project" {

website/docs/r/google_project_iam_custom_role.html.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ exported:
6060

6161
* `deleted` - (Optional) The current deleted state of the role.
6262

63+
* `id` - an identifier for the resource with the format `projects/{{project}}/roles/{{role_id}}`
64+
65+
* `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.
66+
6367
## Import
6468

6569
Customized IAM project role can be imported using their URI, e.g.

0 commit comments

Comments
 (0)