Skip to content

Commit

Permalink
Added name field to both custom project and org roles (#3370) (#6111)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
modular-magician and c2thorn authored Apr 13, 2020
1 parent 2d0480f commit 64b2780
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .changelog/3370.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
iam: Added `name` field to `google_project_iam_custom_role`
iam: Added `name` field to `google_organization_iam_custom_role`
```
5 changes: 5 additions & 0 deletions google/resource_google_organization_iam_custom_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func resourceGoogleOrganizationIamCustomRole() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions google/resource_google_project_iam_custom_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func resourceGoogleProjectIamCustomRole() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/google_project_iam.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/google_project_iam_custom_role.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 64b2780

Please sign in to comment.