keenauth_role
The keenauth_role resource manages a role of the environment and its complete permission set. A role that belongs to one organization is a different resource, keenauth_organization_role. The keenauth_role data source reads a role by id or key.
resource "keenauth_permission" "invoices_read" {
api_id = "api_01j9zq3v8c5m2x7k4t6r1n0b3d"
value = "invoices:read"
}
resource "keenauth_role" "billing" {
key = "billing"
name = "Billing"
description = "Invoices and payment methods."
permission_ids = [keenauth_permission.invoices_read.id]
}
data "keenauth_role" "billing" {
key = "billing"
}
Lifecycle
keyis unique in the environment, appears in theorg_rolesclaim and cannot be changed: a new key replaces the role.namehas 1 to 128 characters anddescriptionat most 1024. Neither may start or end with whitespace, because the API trims them.permission_idsis the complete set (at most 500). It is written with a separate request after the role fields; if that request fails on create, the role stays in state as tainted and is replaced on the next apply. A permission added or removed elsewhere is reverted by the next apply.is_privilegedmarks a privileged role. In self-service only an administrator who holds the organization admin role can assign it, and an external group mapping to it needsroles:writeand an approval. Making an existing role privileged leaves its group mappings unapproved until they are approved. The default isfalse; when you import a privileged role, writeis_privileged = trueexplicitly, otherwise the next apply makes the role non-privileged.- Updates and deletes send
If-Matchwith the last read ETag. If the role changed after the plan was made, the API answers412and nothing changes; runplanagain. - With
force_destroy = truean assigned role is deleted too and its assignments are removed in the same request; otherwise deleting an assigned role fails with409 role_in_use. A role used as an organization's admin or default member role cannot be deleted at all. Changing onlyforce_destroysends no request. - Assignments of roles to users and memberships are not resources. They are personal data and never go into state; manage them with the API, the CLI or the dashboard.
Import
Import by key or by ID:
tofu import keenauth_role.billing billing
tofu import keenauth_role.billing rol_01j9zq3v8c5m2x7k4t6r1n0b3d