-
Notifications
You must be signed in to change notification settings - Fork 1
chore: update Terraform reference: sync service_account_api_key for v0.9.4 #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,17 +32,22 @@ resource "kosli_service_account" "ci" { | |||||
| privilege = "member" | ||||||
| } | ||||||
|
|
||||||
| # API key with the server-side maximum lifetime (365 days from creation) | ||||||
| # Omitting expires_at lets the server choose the expiry, which is the maximum | ||||||
| # it allows: 365 days from creation. No API key can be created that never | ||||||
| # expires. | ||||||
| resource "kosli_service_account_api_key" "ci_key" { | ||||||
| service_account_name = kosli_service_account.ci.name | ||||||
| description = "Production CI key" | ||||||
| } | ||||||
|
|
||||||
| # API key with an explicit expiry (RFC3339 timestamp) | ||||||
| # An API key with an explicit expiry (RFC3339 timestamp). It must be in the | ||||||
| # future and no more than 365 days out. The server silently shortens anything | ||||||
| # longer. | ||||||
| resource "kosli_service_account_api_key" "ci_key_expiring" { | ||||||
| service_account_name = kosli_service_account.ci.name | ||||||
| description = "Temporary CI key" | ||||||
| expires_at = "2026-12-31T00:00:00Z" | ||||||
| # Pick a date within 365 days of when you apply; update it as you rotate. | ||||||
| expires_at = "2027-01-01T00:00:00Z" | ||||||
| } | ||||||
|
|
||||||
| # The raw key is only available on creation and is sensitive | ||||||
|
|
@@ -54,21 +59,16 @@ output "ci_api_key" { | |||||
|
|
||||||
| ## Expiry | ||||||
|
|
||||||
| Every API key expires. The server caps each key's lifetime at **365 days from creation** and enforces the cap regardless of the client. | ||||||
| The `expires_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. | ||||||
|
|
||||||
| The `expires_at` attribute is an RFC3339 timestamp, e.g. `2026-12-31T00:00:00Z` (offsets such as `+01:00` are accepted and normalized to UTC). Behavior: | ||||||
|
|
||||||
| - **Omitted** → the server applies the maximum 365-day expiry. | ||||||
| - **Set within 365 days** → honored as-is. | ||||||
| - **Set beyond 365 days** → silently shortened to the 365-day cap. Terraform then reports the result as an inconsistent result after apply and marks the resource tainted so the next apply revokes and recreates it. Choose an `expires_at` within the 365-day window to avoid this. | ||||||
| - **In the past** → rejected server-side at apply time. | ||||||
|
|
||||||
| Keys that never expire can no longer be created. | ||||||
| <Warning> | ||||||
| Kosli caps the lifetime of every API key at **365 days**. An `expires_at` further out than that is silently shortened by the server, and Terraform then reports the mismatch as `Provider produced inconsistent result after apply`. Keys that never expire can no longer be created: omitting `expires_at` yields the maximum 365-day expiry rather than no expiry at all. | ||||||
| </Warning> | ||||||
|
|
||||||
| To derive dates dynamically, use Terraform's built-in functions, e.g. `timeadd("2026-01-01T00:00:00Z", "8760h")`. | ||||||
| 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improvement — the
Suggested change
Since this page is agent-synced from |
||||||
|
|
||||||
| <Note> | ||||||
| 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. | ||||||
| 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improvement — this reintroduces a null Two problems as written:
Either confirm the legacy state against the provider's read path and say what a reader should do with one, or drop the sentence. |
||||||
| </Note> | ||||||
|
|
||||||
| ## Import | ||||||
|
|
@@ -93,7 +93,7 @@ Because the raw key value is only returned at creation time, the `key` attribute | |||||
|
|
||||||
| ### Optional | ||||||
|
|
||||||
| - `expires_at` (String) RFC3339 timestamp at which the key expires, e.g. `2026-12-31T00: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. | ||||||
| - `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 | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvement — the rewrite names the error but drops what happens after it. The replaced bullet told the reader the resource is marked tainted and the next apply revokes and recreates the key; without that, someone who hits
Provider produced inconsistent result after applydoesn't know their key is about to be rotated out from under them. Also, "365 days" loses the anchor that the sibling pages carry ("365 days from creation" —administration/authentication/api_key_rotation.md:14,tutorials/rotating_api_keys.mdx:23).