{
  "id": "terraform-8",
  "title": "Audit Signing configuration",
  "description": "Declare which key signs a project's tamper-proof audit records: the platform-managed key, or your own key in Google Cloud KMS, AWS KMS or Azure Key Vault, with the indykite_audit_signing resource and the indykite_audit_signings data source. Only the platform-managed key signs today; customer-managed configurations are stored for the upcoming support.",
  "category": "Audit Signing",
  "tags": [
    "Audit Signing",
    "Audit Log",
    "KMS",
    "Key Vault",
    "BYOK",
    "Tamper-proof"
  ],
  "lastUpdated": "2026-10-20",
  "terraformProviderDocs": [
    "https://registry.terraform.io/providers/indykite/indykite/latest/docs/resources/audit_signing",
    "https://registry.terraform.io/providers/indykite/indykite/latest/docs/data-sources/audit_signings"
  ],
  "relatedGuides": [
    "/guides/guide-audit-signing",
    "/guides/guide-audit-log",
    "/guides/guide-terraform"
  ],
  "commonErrors": [
    {
      "code": "INVALID_ARGUMENT",
      "message": "key_resource is required for customer-managed providers / kid is required for customer-managed providers",
      "solution": "Every CUSTOMER_* provider needs both key_resource and kid. Only PLATFORM_MANAGED may leave them out."
    },
    {
      "code": "INVALID_ARGUMENT",
      "message": "invalid AuditSigningConfig.AuthParams: value must contain no more than 32 pair(s)",
      "solution": "auth_params takes at most 32 entries, each key and value between 1 and 256 characters. Pass only the material the provider needs."
    },
    {
      "code": "ALREADY_EXISTS",
      "message": "audit signing config already exists in project",
      "solution": "A project holds exactly one Audit Signing configuration. Keep a single indykite_audit_signing resource per project and change its arguments to switch provider or key; to take over one created outside Terraform, import it by GID instead of declaring a new one."
    },
    {
      "code": "UNSUPPORTED",
      "message": "Unsupported argument: key_provider / Resource type not found: indykite_audit_signing",
      "solution": "Upgrade the provider to 0.43.0 or later; earlier versions do not know the indykite_audit_signing resource or its key_provider argument."
    }
  ],
  "summary": "An Audit Signing configuration declares who manages the key that signs a project's audit records: every batch, manifest and checkpoint the Audit Log API serves carries a signature and the kid of the key that made it. Only the platform-managed key signs today; customer-managed configurations are stored for the upcoming support.\nThis Terraform configuration shows the four forms of the indykite_audit_signing resource:\n1. PLATFORM_MANAGED: the platform holds the key; only name, project_id and key_provider are needed.\n2. CUSTOMER_GCP_KMS: a crypto key version in Google Cloud KMS, identified by its full version resource name.\n3. CUSTOMER_AWS_KMS: an asymmetric signing key in AWS KMS, identified by its key ARN.\n4. CUSTOMER_AZURE_KEY_VAULT: a key in Azure Key Vault, identified by its key identifier URI.\nIt closes with the indykite_audit_signings data source, which reads configurations back by exact name.",
  "usecase": "Scenario: a compliance team wants the audit trail of a production project signed with a key the company controls, and wants that choice versioned with the rest of the project's infrastructure.\n- The team creates an EC P-256 signing key in its own KMS and grants the platform permission to sign with it.\n- The Terraform module declares the indykite_audit_signing resource with the key's identifier in key_resource, a kid the verifiers will look for, and the access material in auth_params. The platform does not prescribe the auth_params key names; the example follows each cloud's own guidance for third-party access (an IAM role with an external ID on AWS, a service account on Google Cloud) and keeps every value under the 256-character limit.\n- Rotating the key is a change to key_resource and kid; verifiers tell old signatures from new ones by the kid on each record.\n- auth_params values are write-only: the API never returns them, so Terraform keeps them in state and reconciles only the set of keys. Keep them in sensitive variables.",
  "requirements": "- ServiceAccount credentials created in the IndyKite Hub for your organization (the provider reads them from the credentials file).\n- The project GID for project_id (and app_space_id on the data source).\n- For a customer-managed provider: an asymmetric EC P-256 signing key (ECDSA with SHA-256) in Google Cloud KMS, AWS KMS or Azure Key Vault, and credentials that allow the platform to sign with it and read its public key. The key is never exported.\n- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers. The indykite_audit_signing resource and the indykite_audit_signings data source exist since 0.42.0, with key_provider required since 0.43.0; the Audit value of api_permissions on indykite_application_agent since 0.46.0.",
  "steps": "1. Pick the resource example for your provider and delete the other resource blocks: a project holds exactly one Audit Signing configuration, so the example's three resources point at three different projects and a second one in the same project is refused with 409. Retarget the data source's filter and depends_on to the resource you kept, or remove the data source and its output, and drop the input variables your example no longer uses.\n2. For a customer-managed key, create the key in your KMS and put its identifier in key_resource, choose a kid, and pass the access material through sensitive variables into auth_params.\n3. Apply the configuration. The read-only attributes id, app_space_id, customer_id and the timestamps are filled by the platform.\n4. Confirm with the data source, or with GET /configs/v1/audit-signings/{name}?project_id=<gid>: key_resource and kid come back, auth_params values come back empty.\n5. Read the project's trail with the Audit Log API: the kid on every batch, manifest and checkpoint names the key that signed it, and GET /audit/.well-known/jwks.json publishes the matching public keys.",
  "code": [
    {
      "description": "Four forms of the Audit Signing configuration (platform-managed, Google Cloud KMS, AWS KMS, Azure Key Vault), the sensitive variables that carry the access material, and the data source that reads a configuration back by name.",
      "filename": "main.tf",
      "code": "\nterraform {\n  required_providers {\n    indykite = {\n      source  = \"indykite/indykite\"\n      version = \">= 0.49.0\" # or a later release; indykite_audit_signing needs 0.43.0 or later\n    }\n  }\n}\n\n# indykite provider integrates IndyKite platform with Terraform scripting.\n# Provider for now does not support any parameters and all is set within service account credential file.\nprovider \"indykite\" {}\n\n# A project holds exactly one Audit Signing configuration: a second one in the\n# same project is refused with 409 \"audit signing config already exists in project\".\n# The three examples below therefore target three different projects; in your own\n# module keep one indykite_audit_signing block per project and edit it to change\n# provider or key.\n\n# Example 1: platform-managed signing key.\n# Only PLATFORM_MANAGED is used for signing today; CUSTOMER_* configurations are\n# stored for the upcoming customer-managed key support.\n# key_provider is always required; key_resource, kid and auth_params are only\n# needed for the CUSTOMER_* providers.\nresource \"indykite_audit_signing\" \"platform_managed\" {\n  name         = \"terraform-audit-signing\"\n  display_name = \"Audit signing, platform-managed key\"\n  project_id   = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n  key_provider = \"PLATFORM_MANAGED\"\n}\n\n# Example 2: customer-managed key in Google Cloud KMS.\n# key_resource is the full crypto key VERSION resource name (ending in\n# /cryptoKeyVersions/<n>), and the key version must use the EC_SIGN_P256_SHA256\n# algorithm. kid is the name a record signed with this key carries.\n# The service account named in auth_params needs cloudkms.cryptoKeyVersions.useToSign\n# and cloudkms.cryptoKeyVersions.viewPublicKey on that key, and the platform's identity\n# (IndyKite provides it) must be allowed to act as that account, for example through\n# roles/iam.serviceAccountTokenCreator on it. Each auth_params value is\n# capped at 256 characters, so a key file or a PEM private key cannot be passed here;\n# the provider's own example uses credentials_json = file(...), which exceeds that limit.\nresource \"indykite_audit_signing\" \"gcp_kms\" {\n  name         = \"terraform-audit-signing-gcp\"\n  display_name = \"Audit signing with Cloud KMS\"\n  description  = \"Audit records are signed with a key hosted in the customer's Cloud KMS\"\n  project_id   = \"gid:AAAAAmluZHlraURlgAABDwAAAAE\" # a second project: one configuration per project\n  key_provider = \"CUSTOMER_GCP_KMS\"\n  key_resource = \"projects/my-project/locations/europe-west1/keyRings/audit/cryptoKeys/signing/cryptoKeyVersions/1\"\n  kid          = \"audit-signing-2026\"\n  auth_params = {\n    client_email = \"audit-signer@my-project.iam.gserviceaccount.com\"\n  }\n}\n\n# Example 3: customer-managed key in AWS KMS.\n# key_resource is the key ARN: the region segment of the ARN selects the KMS\n# region. The key must be an ECC_NIST_P256 asymmetric signing key (ECDSA_SHA_256),\n# and the principal used needs kms:Sign and kms:GetPublicKey on it.\n# Prefer the key ARN over an alias so that kid always names one fixed key.\n# The platform does not prescribe the auth_params key names. This example uses\n# the IAM role pattern AWS recommends for third-party access: a role that trusts\n# the platform's account, with an external ID in its trust policy. The provider's\n# published example shows access_key_id / secret_access_key instead; both forms\n# fit the 256-character limit on each value.\nresource \"indykite_audit_signing\" \"aws_kms\" {\n  name         = \"terraform-audit-signing-aws\"\n  display_name = \"Audit signing with AWS KMS\"\n  project_id   = \"gid:AAAAAmluZHlraURlgAABDwAAAAI\" # a third project: one configuration per project\n  key_provider = \"CUSTOMER_AWS_KMS\"\n  key_resource = \"arn:aws:kms:eu-west-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab\"\n  kid          = \"audit-signing-aws\"\n  auth_params = {\n    role_arn    = var.audit_signer_role_arn\n    external_id = var.audit_signer_external_id\n  }\n}\n\n# CUSTOMER_AZURE_KEY_VAULT follows the same shape: key_resource is the Key Vault\n# key identifier URI of an EC P-256 key (https://<vault>.vault.azure.net/keys/<key>),\n# kid names it on every signed record, and auth_params carries the access material\n# your tenant requires.\n\n# auth_params values are write-only: the API never returns them, so Terraform\n# keeps the configured values in state and only reconciles the set of keys.\n# Keep the secrets in variables or a secret store, never in the module itself.\nvariable \"audit_signer_role_arn\" {\n  type = string\n}\nvariable \"audit_signer_external_id\" {\n  type      = string\n  sensitive = true\n}\n\n# Read a configuration back by exact name. key_resource and kid are returned\n# in clear; auth_params comes back with its keys only.\ndata \"indykite_audit_signings\" \"platform_managed\" {\n  app_space_id = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n  filter       = [indykite_audit_signing.platform_managed.name]\n  depends_on   = [indykite_audit_signing.platform_managed]\n}\n\noutput \"audit_signing_provider\" {\n  value = data.indykite_audit_signings.platform_managed.audit_signings[0].key_provider\n}\n"
    }
  ],
  "links": {
    "html": "/terraform/terraform-8",
    "markdown": "/terraform/terraform-8.md",
    "terraformRegistry": "https://registry.terraform.io/providers/indykite/indykite/latest/docs"
  }
}