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. 2100-01-01T00:00:00Z (offsets such as +01:00 are accepted and normalized to UTC). Omit it for a key that never expires. The timestamp must not be in the past.
To derive dates dynamically, use Terraform’s built-in functions, e.g. timeadd("2026-01-01T00:00:00Z", "8760h").
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 for a key that never expires.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.2100-01-01T00:00:00Z(offsets allowed; whole seconds only). Omit for a key that never expires. Must not be in the past (validated server-side at apply time). Changing this forces creation of a new key. Removing a previously set value from configuration leaves the existing expiry unchanged; to get a non-expiring key again, the key must be recreated (e.g. viaterraform taintor by changing another argument).
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.