User Lifecycle Rules

A UserLifecycleRule represents a rule that applies to users based on their inactivity, state and authentication method.

The rule either disable or delete users who have been inactive or disabled for a specified number of days.

The authentication_method property specifies the authentication method for the rule, which can be set to "all", "all_non_sso", or a specific authentication method.

The rule can also include or exclude site and folder admins from the action.

Resource Schema

Optional

PropertyDescription
authentication_method
String
User authentication method for which the rule will apply. Use all_non_sso to target every non-SSO authentication method with one rule.
Possible values: all, password, sso, none, email_signup, password_with_imported_hash, password_and_ssh_key, all_non_sso
group_ids
List
Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.
action
String
Action to take on inactive users (disable or delete)
Possible values: disable, delete
inactivity_days
Int64
Number of days of inactivity before the rule applies
include_folder_admins
Bool
If true, the rule will apply to folder admins.
include_site_admins
Bool
If true, the rule will apply to site admins.
apply_to_all_workspaces
Bool
If true, a default-workspace rule also applies to users in all workspaces.
name
String
User Lifecycle Rule name
notify_users
Bool
If true, users will be emailed before the rule disables or deletes them.
partner_tag
String
If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
workspace_id
Int64
Workspace ID. 0 means the default workspace.
user_state
String
State of the users to apply the rule to (inactive or disabled)
Possible values: inactive, disabled
user_tag
String
If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.

Read Only

PropertyDescription
id
Int64
User Lifecycle Rule ID
site_id
Int64
Site ID

Example Resource

resource "files_user_lifecycle_rule" "example_user_lifecycle_rule" {
  apply_to_all_workspaces = true
  authentication_method   = "all_non_sso"
  group_ids               = [1, 2, 3]
  inactivity_days         = 12
  include_site_admins     = true
  include_folder_admins   = true
  name                    = "password specific rules"
  notify_users            = true
  partner_tag             = "guest"
  user_state              = "inactive"
  user_tag                = "guest"
  workspace_id            = 12
}

Resource Import

This Resource supports importing using the following syntax:

Example Import Command

# User Lifecycle Rules can be imported by specifying the id.
terraform import files_user_lifecycle_rule.example_user_lifecycle_rule 1

Data Source Schema

Required

PropertyDescription
id
Int64
User Lifecycle Rule ID

Read Only

PropertyDescription
authentication_method
String
User authentication method for which the rule will apply. Use all_non_sso to target every non-SSO authentication method with one rule.
Possible values: all, password, sso, none, email_signup, password_with_imported_hash, password_and_ssh_key, all_non_sso
group_ids
List
Array of Group IDs to which the rule applies. If empty or not set, the rule applies to all users.
action
String
Action to take on inactive users (disable or delete)
Possible values: disable, delete
inactivity_days
Int64
Number of days of inactivity before the rule applies
include_folder_admins
Bool
If true, the rule will apply to folder admins.
include_site_admins
Bool
If true, the rule will apply to site admins.
apply_to_all_workspaces
Bool
If true, a default-workspace rule also applies to users in all workspaces.
name
String
User Lifecycle Rule name
notify_users
Bool
If true, users will be emailed before the rule disables or deletes them.
partner_tag
String
If provided, only users belonging to Partners with this tag at the Partner level will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.
site_id
Int64
Site ID
workspace_id
Int64
Workspace ID. 0 means the default workspace.
user_state
String
State of the users to apply the rule to (inactive or disabled)
Possible values: inactive, disabled
user_tag
String
If provided, only users with this tag will be affected by the rule. Tags must only contain lowercase letters, numbers, and hyphens.

Example Data Source

data "files_user_lifecycle_rule" "example_user_lifecycle_rule" {
  id = 1
}