Key Lifecycle Rules

A KeyLifecycleRule represents a rule that applies to API keys, GPG keys, and SSH keys (also called User Public Keys) based on their inactivity or age.

Keys that have been unused for the specified number of days will be deleted. SSH keys can also be configured to expire after a specified number of days. SSH key expiration applies only to User Public Keys used for inbound SFTP/SSH login, not Remote Server outbound SSH keys.

Resource Schema

Optional

PropertyDescription
key_type
String
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
Int64
Number of days of inactivity before the rule applies.
expiration_days
Int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
apply_to_all_workspaces
Bool
If true, a default-workspace rule also applies to keys in all workspaces.
name
String
Key Lifecycle Rule name
workspace_id
Int64
Workspace ID. 0 means the default workspace.

Read Only

PropertyDescription
id
Int64
Key Lifecycle Rule ID

Example Resource

resource "files_key_lifecycle_rule" "example_key_lifecycle_rule" {
  apply_to_all_workspaces = true
  expiration_days         = 365
  key_type                = "gpg"
  inactivity_days         = 12
  name                    = "inactive gpg keys"
  workspace_id            = 12
}

Resource Import

This Resource supports importing using the following syntax:

Example Import Command

# Key Lifecycle Rules can be imported by specifying the id.
terraform import files_key_lifecycle_rule.example_key_lifecycle_rule 1

Data Source Schema

Required

PropertyDescription
id
Int64
Key Lifecycle Rule ID

Read Only

PropertyDescription
key_type
String
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
Int64
Number of days of inactivity before the rule applies.
expiration_days
Int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
apply_to_all_workspaces
Bool
If true, a default-workspace rule also applies to keys in all workspaces.
name
String
Key Lifecycle Rule name
workspace_id
Int64
Workspace ID. 0 means the default workspace.

Example Data Source

data "files_key_lifecycle_rule" "example_key_lifecycle_rule" {
  id = 1
}