Skip to content

frostmoln_api_key (Resource) ​

Manages an API key in the Frostmoln platform.

~> Upgrade note (scopes retirement). Flat scopes no longer exist as a grant language an API key can be given: the API refuses every non-empty value on create and update with 400 API_KEY_SCOPES_RETIRED. Remove the attribute from your configuration and grant the key with an access policy attached using frostmoln_iam_policy_attachment instead. A migrated key's stored scopes stay while scopes is omitted (unchanged server-side); to retire them too, set scopes = [] once — the API's clear arm — after the replacement policy is attached and verified.

Authoritative scope — who owns what on this resource, declared in internal/scopedecl and machine-checked against the schema.

Enacted and reconciled — every configurable attribute not listed below: the platform applies it, and a refresh reads the truth back.

Create-immutable — expires_at: the key's expiry is fixed when it is minted.

Observed, not enacted — key: returned once at create and never again — only this configuration's copy survives; a refresh cannot recover it. tags_all: keys set outside Terraform — in the portal, by the fm CLI, or stamped by the platform — appear only here and are kept on every apply, never removed.

Example Usage ​

terraform
# An API key. Flat scopes are RETIRED: the API refuses every non-empty `scopes`
# value with 400 API_KEY_SCOPES_RETIRED, so the attribute is removed and the
# key's continuing authority is an access policy attached with
# frostmoln_iam_policy_attachment.
resource "frostmoln_api_key" "ci" {
  name        = "ci-deploy-key"
  description = "API key for CI/CD pipeline deployments"
  # expires_at is optional. A bare date means end of that day (UTC); RFC3339 is
  # also accepted. A date already in the past is accepted and yields an
  # immediately expired key, so set one that is still ahead of today:
  #   expires_at = "2030-01-01"
  rate_limit = 5000
}

output "api_key_prefix" {
  value = frostmoln_api_key.ci.key_prefix
}

Schema ​

Required ​

  • name (String) The name of the API key.

Optional ​

  • description (String) A description of the API key.
  • expires_at (String) The expiration for the API key. Accepts a bare date (YYYY-MM-DD, interpreted as the end of that day in UTC — e.g. 2027-01-01 becomes 2027-01-01T23:59:59Z) or a full RFC3339 timestamp. The expiry must be at most 2 years in the future — the server rejects a later value with API_KEY_LIFETIME_EXCEEDS_MAX. Note: the fm CLI's --expires uses the operator's local timezone for the end-of-day, so the same bare date may resolve to an instant up to a day apart between the two tools; this provider uses UTC so plans are reproducible across machines. Omit to use the server default (~1 year), which is then reflected in state. Once set, this cannot be changed (changing it replaces the key).
  • rate_limit (Number) The rate limit for the API key (requests per minute). Omit to use the server default, which is then reflected in state.
  • scopes (List of String, Deprecated) RETIRED — flat scopes are no longer a grant language an API key can be given. A create or update carrying any value is rejected by the API with 400 API_KEY_SCOPES_RETIRED and the apply fails; the deprecation warning in the plan already names the migration. Remove the attribute from your configuration to stop sending scopes — on a PATCH an omitted field is read server-side as UNCHANGED, so a migrated key's stored scopes persist until you clear them explicitly by setting scopes = [] once (the API's clear arm; zero-scope creates are legal). Grant the key with an access policy attached using frostmoln_iam_policy_attachment instead. Kept Optional (never Required) so a carrying configuration migrates by deletion, not by replacement, and pre-retirement state still reads.
  • tags (Map of String) Resource tags on the API key: your own key/value metadata for search and filtering (?tag=key=value in the API, --tag in the fm CLI). Labels only — they change no scope, expiry or rate limit, and a tags-only change is accepted even on a revoked or expired key. At most 32 keys including the tenant's default tags, which the platform merges in at create; a key is 1-64 bytes matching ^[a-zA-Z0-9]([a-zA-Z0-9._:/-]*[a-zA-Z0-9])?$, a value at most 256 bytes; keys beginning frostmoln_ or frostmoln- (any case) are reserved. Merged with the provider's default_tags on every write (a key set here wins). Holds only the keys this configuration sets; the full set is in tags_all.

Read-Only ​

  • created_at (String) The timestamp when the API key was created.
  • id (String) The unique identifier of the API key.
  • key (String, Sensitive) The API key value. Only available after creation; not returned on subsequent reads. Stored in Terraform state in plaintext — sensitive redacts CLI output, not the state file. See the Secrets in Terraform state guide.
  • key_prefix (String) The prefix of the API key for identification.
  • status (String) The current status of the API key.
  • tags_all (Map of String) Every tag the platform holds on this resource: the provider's default_tags, this resource's own tags (which win on a shared key), and any key set outside Terraform — in the portal, by the fm CLI, or stamped by the platform. Keys set outside Terraform appear only here and are kept on every apply, never removed.