Skip to Content

Terraform

Terraform configures supported Keel control-plane resources as code. It is not used to execute, proxy, stream, or inspect AI requests.

Current provider surface

The public Terraform provider (keelapi/keel 1.1) manages two resources and reads permits. It does not manage Keel policies and is not a policy-as-code surface.

TypeNamePurpose
Resourcekeel_api_keyManage API keys in the project of the provider’s API key.
Resourcekeel_organization_memberManage a user’s role in a Keel organization.
Data sourcekeel_permitRead recent permit decisions in the project of the provider’s API key.

Workspaces, policies, policy attachments, audit export configuration, provider-key management, budgets, and routing configuration are not part of the current public Terraform surface.

Install

terraform { required_providers { keel = { source = "keelapi/keel" version = "~> 1.1" } } } provider "keel" { base_url = "https://api.keelapi.com" api_key = var.keel_api_key # keel_organization_member needs a user token instead of the API key. # Set KEEL_USER_TOKEN for each run; dashboard session tokens are short-lived. }

You can also set KEEL_API_KEY, KEEL_USER_TOKEN, and KEEL_BASE_URL in the environment. keel_api_key needs an admin-scope API key; keel_permit accepts an admin- or client-scope key; keel_organization_member accepts only a user token for an organization owner or admin.

API key resource

resource "keel_api_key" "backend" { name = "backend-service" description = "Key for the backend service" scope = "client" # admin, client, or approval }

Keys are created in the project of the provider’s API key; project_id is read-only. Keys are immutable, so any change replaces the key, and deleting the resource revokes it. The secret is returned only at creation. Provider credentials remain managed in Keel and are not exposed through this resource.

Organization member resource

resource "keel_organization_member" "reviewer" { org_id = var.org_id user_id = var.user_id role = "member" # owner, admin, member, or viewer }

An organization admin can grant only member and viewer.

Permit data source

data "keel_permit" "recent_denials" { decision = "deny" # allow, deny, review, or throttle limit = 50 # 1-200 }

Each returned permit exposes its decision, reason_code, message, and created_at. Use it when a pipeline needs to read recent decisions; it does not create or change policy.

OPA plan gate example

The provider repository includes an example (examples/opa-policy-gate) that evaluates a Terraform plan with Open Policy Agent before apply:

terraform show -json tfplan > plan.json opa eval -d policy.rego -i plan.json 'data.policy.deny'

The example policy refuses a plan that grants the organization owner role without an approval annotation. The check runs in your pipeline; Keel does not evaluate it.

Runtime integrations

For governed execution, use the runtime API or SDKs instead:

Last updated on Edit this page on GitHub