|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "workos_environment_role Resource - workos" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + Manages a WorkOS environment-level role. |
| 7 | + Environment roles are global to a WorkOS environment and can be assigned across |
| 8 | + organizations. They are identified by an immutable slug. |
| 9 | + The WorkOS public API does not currently expose environment-role deletion. Terraform |
| 10 | + can create, import, read, and update environment roles, but destroying this resource |
| 11 | + returns a diagnostic instead of silently leaving the role behind. Use terraform state rm |
| 12 | + or tofu state rm if you need Terraform to stop managing an existing role. |
| 13 | + When permissions is configured, the provider manages the complete permission set for |
| 14 | + the role by using WorkOS' replace-all permissions endpoint. |
| 15 | + Example Usage |
| 16 | + |
| 17 | + resource "workos_environment_role" "billing_admin" { |
| 18 | + slug = "billing-admin" |
| 19 | + name = "Billing Admin" |
| 20 | + description = "Can manage billing across organizations" |
| 21 | + |
| 22 | + permissions = [ |
| 23 | + workos_permission.billing_read.slug, |
| 24 | + workos_permission.billing_write.slug, |
| 25 | + ] |
| 26 | + } |
| 27 | + |
| 28 | + Import |
| 29 | + Environment roles can be imported using their slug: |
| 30 | + |
| 31 | + terraform import workos_environment_role.example billing-admin |
| 32 | + |
| 33 | + OpenTofu uses the same import ID format: |
| 34 | + |
| 35 | + tofu import workos_environment_role.example billing-admin |
| 36 | +--- |
| 37 | + |
| 38 | +# workos_environment_role (Resource) |
| 39 | + |
| 40 | +Manages a WorkOS environment-level role. |
| 41 | + |
| 42 | +Environment roles are global to a WorkOS environment and can be assigned across |
| 43 | +organizations. They are identified by an immutable slug. |
| 44 | + |
| 45 | +The WorkOS public API does not currently expose environment-role deletion. Terraform |
| 46 | +can create, import, read, and update environment roles, but destroying this resource |
| 47 | +returns a diagnostic instead of silently leaving the role behind. Use `terraform state rm` |
| 48 | +or `tofu state rm` if you need Terraform to stop managing an existing role. |
| 49 | + |
| 50 | +When `permissions` is configured, the provider manages the complete permission set for |
| 51 | +the role by using WorkOS' replace-all permissions endpoint. |
| 52 | + |
| 53 | +## Example Usage |
| 54 | + |
| 55 | +```hcl |
| 56 | +resource "workos_environment_role" "billing_admin" { |
| 57 | + slug = "billing-admin" |
| 58 | + name = "Billing Admin" |
| 59 | + description = "Can manage billing across organizations" |
| 60 | +
|
| 61 | + permissions = [ |
| 62 | + workos_permission.billing_read.slug, |
| 63 | + workos_permission.billing_write.slug, |
| 64 | + ] |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +## Import |
| 69 | + |
| 70 | +Environment roles can be imported using their slug: |
| 71 | + |
| 72 | +```shell |
| 73 | +terraform import workos_environment_role.example billing-admin |
| 74 | +``` |
| 75 | + |
| 76 | +OpenTofu uses the same import ID format: |
| 77 | + |
| 78 | +```shell |
| 79 | +tofu import workos_environment_role.example billing-admin |
| 80 | +``` |
| 81 | + |
| 82 | +## Example Usage |
| 83 | + |
| 84 | +```terraform |
| 85 | +# Manage an environment-level role |
| 86 | +resource "workos_environment_role" "billing_admin" { |
| 87 | + slug = "billing-admin" |
| 88 | + name = "Billing Admin" |
| 89 | + description = "Can manage billing across organizations" |
| 90 | +
|
| 91 | + permissions = [ |
| 92 | + workos_permission.billing_read.slug, |
| 93 | + workos_permission.billing_write.slug, |
| 94 | + ] |
| 95 | +} |
| 96 | +
|
| 97 | +resource "workos_permission" "billing_read" { |
| 98 | + slug = "billing:read" |
| 99 | + name = "Read Billing" |
| 100 | +} |
| 101 | +
|
| 102 | +resource "workos_permission" "billing_write" { |
| 103 | + slug = "billing:write" |
| 104 | + name = "Write Billing" |
| 105 | +} |
| 106 | +
|
| 107 | +output "billing_admin_role_id" { |
| 108 | + value = workos_environment_role.billing_admin.id |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +<!-- schema generated by tfplugindocs --> |
| 113 | +## Schema |
| 114 | + |
| 115 | +### Required |
| 116 | + |
| 117 | +- `name` (String) The display name of the role. |
| 118 | +- `slug` (String) The slug identifier for the role. Must be unique within the environment. Changing this value after creation is not supported because WorkOS does not currently expose a public delete API for environment roles. |
| 119 | + |
| 120 | +### Optional |
| 121 | + |
| 122 | +- `description` (String) A description of the role. |
| 123 | +- `permissions` (Set of String) The complete set of permissions associated with the role. When configured, this set is authoritative. |
| 124 | +- `resource_type_slug` (String) The resource type slug this role is scoped to. Changing this value after creation is not supported because WorkOS does not currently expose a public delete API for environment roles. |
| 125 | + |
| 126 | +### Read-Only |
| 127 | + |
| 128 | +- `created_at` (String) The timestamp when the role was created (RFC3339 format). |
| 129 | +- `id` (String) The unique identifier of the environment role. |
| 130 | +- `type` (String) The type of the role. |
| 131 | +- `updated_at` (String) The timestamp when the role was last updated (RFC3339 format). |
0 commit comments