frostmoln_workload_identity_binding (Resource)
Manages a Workload Identity Federation binding, mapping a managed Kubernetes (namespace, service account) to a Frostmoln grant. A pod running as that service account can exchange its projected token for a short-lived, policy-scoped Frostmoln credential. The binding's grant is its access policies — attach one with frostmoln_iam_policy_attachment (directly, or through a group). Flat scopes are retired: a configuration that still sets them fails at apply with BINDING_SCOPES_RETIRED. The binding is owned by the provider's selected tenant (tenant_id, else the credential's default), and its cluster_id must belong to that same tenant.
~> Upgrade note. Before provider v0.37.9 this resource ignored tenant_id and always acted on the credential's home tenant — a binding for a non-home cluster failed at apply rather than landing in the wrong place. A configuration that sets a non-home tenant_id and previously applied has its bindings in the HOME tenant: the first plan after upgrading reads a 404, drops them from state and proposes a create in the selected tenant. terraform state rm + re-import against the selected tenant, or point tenant_id at the home tenant.
~> Upgrade note (scopes retirement, retire-scopes step 2). Flat scopes no longer exist as a grant language. Remove the attribute from your configuration and grant the binding with an access policy instead; the state normalizes to null (the server always answers scopes: []). A carrying configuration fails at apply — see the scopes attribute. To migrate an existing pre-retirement binding: attach a policy carrying the same operations, verify the workload still passes, then apply the configuration with scopes removed (that drop is the migration landing the server guards).
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 — cluster_id, namespace, service_account: the binding is identified by its cluster, namespace and service account; changing one is a different binding.
Observed, not enacted — 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
# A Workload Identity Federation binding: a pod running as the given
# Kubernetes service account can exchange its projected token for a short-lived,
# policy-scoped Frostmoln credential — no long-lived secret in the pod.
#
# Flat scopes are RETIRED (retire-scopes step 2, ADR-0102): a binding's grant is
# its access policies, and a configuration that still sets `scopes` fails at
# apply with 400 BINDING_SCOPES_RETIRED. Remove the attribute; grant with a
# policy below.
resource "frostmoln_workload_identity_binding" "app" {
cluster_id = frostmoln_kubernetes_cluster.prod.id
namespace = "default"
service_account = "my-app"
}
# A policy-granted binding: the attachment below is the workload's authority.
# A policy names individual targets, adds constraints and can deny explicitly —
# flat scopes never could grant a verb across every resource of a service.
#
# The binding is INERT until the attachment exists: with no grant at all the
# token exchange refuses it rather than minting a credential that grants nothing.
#
# TEARDOWN — read before you destroy. A granted binding is never left with zero
# grants, so detaching its ONLY policy is refused. `terraform destroy` removes
# the attachment first (it depends on the binding) and therefore fails. Destroy
# the BINDING first; that removes its attachments with it:
#
# terraform destroy -target=frostmoln_workload_identity_binding.reaper
# terraform destroy
#
# The same applies to any change that REPLACES the binding (cluster_id, namespace
# and service_account all force replacement).
resource "frostmoln_workload_identity_binding" "reaper" {
cluster_id = frostmoln_kubernetes_cluster.prod.id
namespace = "ops"
service_account = "instance-reaper"
}
data "frostmoln_iam_policy_document" "reaper" {
rule {
name = "read-and-delete-instances-only"
access = "allow"
operations = ["compute:instances:read", "compute:instances:list", "compute:instances:delete"]
targets = ["frn:compute:*:*:instances/*"]
}
}
resource "frostmoln_iam_policy" "reaper" {
name = "instance-reaper"
document = data.frostmoln_iam_policy_document.reaper.json
}
resource "frostmoln_iam_policy_attachment" "reaper" {
policy_id = frostmoln_iam_policy.reaper.id
attachee_type = "workload_identity"
attachee_id = frostmoln_workload_identity_binding.reaper.id
}Schema
Required
cluster_id(String) The managed cluster the binding applies to. The cluster must belong to the selected tenant (the provider's tenant_id).namespace(String) The Kubernetes namespace (DNS-1123 label).service_account(String) The Kubernetes service account name (DNS-1123 subdomain).
Optional
scopes(List of String, Deprecated) RETIRED — flat scopes are no longer a grant language a binding can be given. A create or update carrying any value is rejected by the API with 400 BINDING_SCOPES_RETIRED and the apply fails; the deprecation warning in the plan already names the migration. A binding's grant is its access policies: attach one withfrostmoln_iam_policy_attachment(directly, or through a group). Remove the attribute from your configuration — state normalizes to null (the server always answersscopes: []). An empty list remains an invalid spelling: omit the attribute 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 binding: your own key/value metadata for search and filtering (?tag=key=valuein the API,--tagin the fm CLI). Labels only — the token exchange never reads them, and a tags change (its own tags-only update) never touches the binding's scopes. 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 beginningfrostmoln_orfrostmoln-(any case) are reserved. Merged with the provider'sdefault_tagson every write (a key set here wins). Holds only the keys this configuration sets; the full set is intags_all.
Read-Only
created_at(String) The timestamp when the binding was created.id(String) The unique identifier of the binding.tags_all(Map of String) Every tag the platform holds on this resource: the provider'sdefault_tags, this resource's owntags(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.tenant_id(String) The owning tenant (server-set; the provider's tenant_id selects it).updated_at(String) The timestamp when the binding was last updated.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
# Workload identity bindings are imported by their id.
terraform import frostmoln_workload_identity_binding.app <binding-id>