-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CC-27365] add user_role_grant resource
Previously, the provider supported user role management but only in an authoritative way. Using the user_role_grants resource would overwrite all roles for a user. This caused churn for terraform users trying to manage user roles across multiple projects or via the console UI. We now add a resource, user_role_grant which allows management of a single user role grant. The existing user_role_grants resource is left to maintain the previous functionality for those that need it. As part of this changes, I've also renamed the role_resource files which contain the user_role_grants resource after the full name of the role since that seems to be the convention. Additionally, cloud SDK is Update to 1.9.0
- Loading branch information
Showing
22 changed files
with
2,022 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "cockroach_user_role_grant Resource - terraform-provider-cockroach" | ||
subcategory: "" | ||
description: |- | ||
A role grant for a user. This resource is recommended to be used when a user's roles are managed across multiple terraform projects or in conjunction with console UI granted roles. For authoritative management over a user's roles, use the userrolegrants user_role_grants resource. | ||
As with all terraform resources, care must be taken to limit management of the same resource to a single project. | ||
--- | ||
|
||
# cockroach_user_role_grant (Resource) | ||
|
||
A role grant for a user. This resource is recommended to be used when a user's roles are managed across multiple terraform projects or in conjunction with console UI granted roles. For authoritative management over a user's roles, use the [user_role_grants](user_role_grants) resource. | ||
|
||
As with all terraform resources, care must be taken to limit management of the same resource to a single project. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
variable "user_id" { | ||
type = string | ||
} | ||
resource "cockroach_user_role_grant" "admin_grant" { | ||
user_id = var.user_id | ||
role = { | ||
role_name = "CLUSTER_ADMIN", | ||
resource_type = "CLUSTER", | ||
resource_id = cockroach_cluster.example.id | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `role` (Attributes) (see [below for nested schema](#nestedatt--role)) | ||
- `user_id` (String) ID of the user to grant these roles to. | ||
|
||
<a id="nestedatt--role"></a> | ||
### Nested Schema for `role` | ||
|
||
Required: | ||
|
||
- `resource_type` (String) Type of resource. Allowed values are: | ||
* ORGANIZATION | ||
* CLUSTER | ||
* FOLDER | ||
- `role_name` (String) Name of the role to grant. Allowed values are: | ||
* BILLING_COORDINATOR | ||
* ORG_ADMIN | ||
* ORG_MEMBER | ||
* CLUSTER_ADMIN | ||
* CLUSTER_OPERATOR_WRITER | ||
* CLUSTER_DEVELOPER | ||
* CLUSTER_CREATOR | ||
* FOLDER_ADMIN | ||
* FOLDER_MOVER | ||
|
||
Optional: | ||
|
||
- `resource_id` (String) ID of the resource. Required if the resource_type is 'FOLDER' or 'CLUSTER'. It should be omitted otherwise. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Cluster and folder level role grants can be imported using: | ||
# <user_id>,<role_name>,<resource_type>,<resource_id> | ||
terraform import cockroach_user_role_grant.admin_grant 1f69fdd2-600a-4cfc-a9ba-16995df0d77d,CLUSTER_ADMIN,CLUSTER,9b9d23fe-3848-40b2-a3c5-d8ccb1c4f831 | ||
|
||
# Organization level grants can omit the resource_id | ||
terraform import cockroach_user_role_grant.org_level_grant 1f69fdd2-600a-4cfc-a9ba-16995df0d77d,ORG_ADMIN,ORGANIZATION | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Cluster and folder level role grants can be imported using: | ||
# <user_id>,<role_name>,<resource_type>,<resource_id> | ||
terraform import cockroach_user_role_grant.admin_grant 1f69fdd2-600a-4cfc-a9ba-16995df0d77d,CLUSTER_ADMIN,CLUSTER,9b9d23fe-3848-40b2-a3c5-d8ccb1c4f831 | ||
|
||
# Organization level grants can omit the resource_id | ||
terraform import cockroach_user_role_grant.org_level_grant 1f69fdd2-600a-4cfc-a9ba-16995df0d77d,ORG_ADMIN,ORGANIZATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
variable "user_id" { | ||
type = string | ||
} | ||
|
||
resource "cockroach_user_role_grant" "admin_grant" { | ||
user_id = var.user_id | ||
role = { | ||
role_name = "CLUSTER_ADMIN", | ||
resource_type = "CLUSTER", | ||
resource_id = cockroach_cluster.example.id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.