kosli_service_account resource.
API keys are immutable. Changing
description, expires_at, or service_account_name revokes the existing key and creates a new one. On terraform import, the key attribute cannot be populated because the raw value is not retrievable.Example usage
Expiry
Theexpires_at attribute is an RFC3339 timestamp, e.g. 2027-01-01T00:00:00Z (offsets such as +01:00 are accepted and normalized to UTC). The timestamp must not be in the past.
To derive dates from a fixed anchor, use Terraform’s built-in functions, e.g. timeadd("2027-01-01T00:00:00Z", "720h"). Avoid deriving expires_at from timestamp(). It changes on every plan, and because expires_at forces replacement that would revoke and recreate the key on each apply.
All timestamps (
expires_at, created_at, last_used_at) are RFC3339 UTC strings. last_used_at is null for a key that has never been used. expires_at is null only for keys minted before the 365-day cap was introduced.Import
API keys can be imported using the<service_account_name>/<key_id> format:
key attribute is empty after an import.
Schema
Required
description(String) Description of the API key (at least one character). Changing this forces creation of a new key.service_account_name(String) Name of the service account this API key belongs to. Changing this forces creation of a new key.
Optional
expires_at(String) RFC3339 timestamp at which the key expires, e.g.2027-01-01T00:00:00Z(offsets allowed; whole seconds only). Must not be in the past (validated server-side at apply time) and must be no more than 365 days out: the server caps every key’s lifetime and silently shortens a longer expiry, which Terraform then reports as an inconsistent result after apply. Omit to let the server apply the maximum 365-day expiry; keys that never expire can no longer be created. Changing this forces creation of a new key. Removing a previously set value from configuration leaves the existing expiry unchanged.
Read-only
created_at(String) RFC3339 UTC timestamp of when the API key was created.id(String) Server-assigned identifier of the API key.key(String, Sensitive) The raw API key value. Only available at creation time and stored as a sensitive value. Empty when the resource is imported.last_used_at(String) RFC3339 UTC timestamp of when the API key was last used. Null if the key has never been used.