Why IaC for auth
Auth config drifts in ways application code doesn’t. An agent spun up by hand in a dashboard has no peer review, no version history, and no automated rollback. When the production incident happens and you need to know why an agent had write access to the deploy tool, “someone added it last Tuesday” is not an audit trail. Treating agents and permissions as Terraform resources fixes this. Every grant goes through a pull request. Every change is versioned in git. Destroying a staging environment tears down the access alongside the infrastructure, no orphaned tokens floating around.Installation
The provider requires Go 1.21 to build.1
Clone the repository and build the binary:
2
Install into the local plugin cache:
3
Declare the provider in your Terraform configuration:
Provider setup
string
default:"KAVACHOS_BASE_URL env var"
Base URL of your KavachOS deployment.
string
default:"KAVACHOS_TOKEN env var"
API token for authenticating with KavachOS.
Resources
kavachos_agent
Manages an agent identity, the primary entity in KavachOS.token attribute is computed on creation and marked sensitive. Read it with:
string
required
ID of the user who owns this agent.
string
required
Human-readable name.
"autonomous" | "delegated" | "service"
required
Agent type: autonomous, delegated, or service.
block[]
One or more permission grant blocks.
string
RFC 3339 expiry timestamp.
string
required
Resource pattern, e.g. mcp:github:* or mcp:deploy:production.
string[]
required
Allowed actions, e.g. [“read”] or [“execute”].
block
Optional block limiting usage.
bool
default:"false"
Require human approval before the action executes.
number
Rate limit: maximum calls allowed per hour.
string[]
Glob patterns restricting allowed argument values.
string[]
CIDR blocks from which this permission may be used.
kavachos_permission
Grants a single permission to an existing agent from a separate module. If you control both the agent and all its permissions in one place, use inlinepermission blocks on kavachos_agent instead.
string
required
ID of the target agent.
string
required
Resource pattern.
string[]
required
Allowed actions.
bool
default:"false"
Require human approval.
number
Rate limit per hour.
string[]
Glob patterns for argument values.
string[]
CIDR blocks allowed to exercise the permission.
kavachos_api_key
Manages an API key for server-to-server requests.agents:read, agents:write, audit:read, delegation:read, delegation:write, organizations:read, organizations:write, admin.
The
key attribute is only populated immediately after creation. Read it with terraform output -raw ci_key and store it in your secret manager before the session ends.kavachos_organization
Manages an organization for multi-tenant isolation.slug is immutable after creation. Change it by deleting and recreating the organization.
Data sources
kavachos_agent
Reads an agent that was not created by this Terraform configuration.kavachos_agents
Lists agents, optionally filtered.owner_id, status (active | revoked | expired), type (autonomous | delegated | service).
Import existing state
Resources provisioned outside Terraform can be brought under management:terraform plan. Terraform will show a diff for any attributes that differ from your configuration. Update the HCL to match, or let Terraform converge.