Your Agent Needs a Diff
Anthropic's Terraform provider turns an agent's prompt, model, tools and permissions into a reviewable diff. What version 0.1.0 actually manages, the two-identity catch, what state knows about your agents, and where the beta stops.
An agent's system prompt is production code. So is the list of tools it can call without asking, the model it runs on and how hard that model thinks. Until now most of that lived in a console form or a script someone ran once. Change one line of the prompt and nobody reviewed it.
On December 3 Anthropic put its Terraform provider into public beta. I installed it the same evening and read its whole schema. I did not apply it to a real organization, so everything below about runtime behavior comes from Anthropic's documentation, and I say where. The agent becomes a resource with a version number, and every change to it goes through terraform plan like a firewall rule.
TL;DR
- It's much wider than agents and workspaces. Version 0.1.0 ships 33 resources and 69 data sources, from agents, vaults and scheduled deployments to federation, encryption keys, telemetry and spend limits.
- An agent change is now a reviewable diff. Model, effort, system prompt, tools and their permission policies are arguments. Every change publishes a new agent version, and a scheduled deployment moves to it only when you tell it to.
- You need two identities, and often two configurations. Agents need a workspace credential and refuse an Admin API key. One apply can't create a workspace and fill it with agents.
- Secrets stay out of state, prompts don't. Credentials go through write-only arguments. System prompts, tool schemas and memory content sit in state in plain text.
- It's a real beta. Arguments can change, deletion protection is on by default, destroy is mostly permanent, and there is still no resource for API keys or invites.
Start here
| 🧠| Your first agent under Terraform. You need an organization with access to Claude Managed Agents. 1. Install the tools. Terraform 1.11 or later (Anthropic's docs ask for it, and write-only secrets need it) and Anthropic's 2. Sign in to a workspace. Run 3. Pin the organization. Copy the organization ID from the Console's organization settings or from 4. Write 5. Plan, then apply. 6. Change one line of the prompt. Plan again. You get one in-place update to 7. Commit the right files. Commit 8. Clean up on purpose. Deletion protection is on, so |
The steps follow Anthropic's getting started page. I ran terraform init and terraform validate on Terraform 1.17.3. Steps 2, 3 and 5 to 8 need real credentials, and I describe them from the docs.
What's in the box
Anthropic's release note names workspaces, service accounts, federation, agents, environments, vaults and skills. The schema holds more. Version 0.1.0 has 33 resources, 21 of them prefixed anthropic_beta_, and 69 data sources:
It runs against four platforms: Anthropic's API (the default), Claude Platform on AWS, Claude Models on Google Cloud, and Amazon Bedrock, where only agents, memory stores and memories are available.
Anthropic isn't first to Terraform. OpenAI's own provider is on the Registry, described in its repository as "The official Terraform provider for OpenAI", at version 1.8.1 the day before Anthropic's beta. Anthropic's manages the agent runtime itself: the environment it runs in, what it can reach on the network, the credentials it may use, its memory, its schedule and its budget.
An agent, as code
This is the shape of it. It passes terraform validate against provider 0.1.0:
terraform {
required_version = ">= 1.11"
required_providers {
anthropic = {
source = "anthropics/anthropic"
version = "~> 0.1.0"
}
}
}
variable "organization_id" {
type = string
}
provider "anthropic" {
organization_id = var.organization_id
}
resource "anthropic_beta_environment" "box" {
name = "triage-box"
config = {
cloud = {
networking = {
limited = {
allow_package_managers = true
}
}
}
}
}
resource "anthropic_beta_agent" "triage" {
name = "issue-triage"
system = file("triage.md")
model = {
id = "claude-opus-5-5"
effort = "high"
}
tools = [{
agent_toolset_20260401 = {
default_config = {
permission_policy = "always_ask"
}
configs = [
{ read = {
permission_policy = "always_allow"
} },
{ web_search = { enabled = false } },
{ web_fetch = { enabled = false } },
]
}
}]
}Three things in there matter more than they look.
The prompt lives in a file. system = file("triage.md") puts the prompt next to the code that calls the agent. A prompt edit is now a pull request, with a reviewer and a history.
Permissions are explicit and reviewable. The built-in toolset covers bash, edit, glob, grep, read, write, web_fetch and web_search, and each one takes always_allow, always_ask or auto. Here every enabled tool asks except read. When someone flips bash to always_allow, the plan shows exactly that line. On a console form, that change is a click no one reviews.
The organization is pinned. organization_id is required on the Claude API, and per the docs "the provider stops if the credentials belong to another organization." With another organization's key in the wrong shell, the plan fails instead of applying there. I saw the check run: with no credentials at all, terraform plan stopped with "Organization check failed" and listed the places it had looked for a credential.
Every change is a version
The agent resource exports version. The provider's description: "Starts at 1 and increments when the agent is modified." The docs spell out the rule: "Every change to an agent publishes a new version." A session that names only the agent's ID gets the latest version, and one that names a version stays on it. The Managed Agents API skips the version bump when an update changes nothing.
Deployments are where this pays off. anthropic_beta_deployment "binds the agent to everything needed to run it autonomously: an environment, credentials, initial events, and an optional schedule." Here is a nightly run with a budget, shortened to the parts that matter:
resource "anthropic_beta_deployment" "nightly" {
name = "nightly-triage"
environment_id = anthropic_beta_environment.box.id
vault_ids = [anthropic_beta_vault.triage.id]
agent = {
agent = {
id = anthropic_beta_agent.triage.id
version = anthropic_beta_agent.triage.version
}
}
initial_events = [{
user_message = {
content = [{
text = { text = "Triage new issues." }
}]
}
}]
schedule = {
cron = {
expression = "0 6 * * 1-5"
timezone = "UTC"
}
}
budget = {
limit = {
max_list_cost = {
amount = "500"
currency = "USD"
}
}
}
}
The version line is a release decision. Per the docs, with it "an apply that changes the agent also moves the deployment to the new version. Without version, the deployment stays on its version when the agent gets a new one." So you choose: the scheduled run follows every prompt edit, or it stays pinned until someone bumps it on purpose. My example follows. For anything that touches real systems I'd pin, and promote in a separate pull request: a prompt that reads fine in review can still behave differently on the nightly run. Either way, the choice is now written down.
The budget is per session, in cents: "500" is five dollars, and USD is the only currency. The schema says the cap uses list price "regardless of any negotiated discount, so the cap fires at or before the actual charge." An agent that runs every weekday at six, unattended, with a hard ceiling per run, in code, is the setup I'd want before anything runs while I'm asleep. Organization and workspace spend limits have their own resource, anthropic_beta_spend_limit (through the API, an early-access preview).
Sessions themselves are not resources. The operations page is blunt: "Sessions aren't resources. To start sessions on a schedule, use a scheduled deployment instead." Terraform owns the definition. Your application, or a deployment, owns the runs.
Two identities, two configurations
This is the part that will trip people up first.
A workspace credential is a workspace API key, a login, or a federation rule with workspace:developer. An admin token is a login with --scope org:admin or a federation rule with org:admin. The table condenses Anthropic's credentials table. The authentication page draws the conclusion: "To manage organization resources and Managed Agents resources in one configuration, use two provider blocks." The default block uses the workspace login. The second gets an alias and an admin profile:
# ant auth login --profile admin
# --scope org:admin
provider "anthropic" {
alias = "admin"
organization_id = var.organization_id
profile = "admin"
}
resource "anthropic_workspace" "agents" {
provider = anthropic.admin
name = "agents"
}
resource "anthropic_workspace_member" "dev" {
provider = anthropic.admin
workspace_id = anthropic_workspace.agents.id
user_id = var.dev_user_id
workspace_role = "workspace_developer"
}
Then the catch: "One terraform apply can't both create the workspace and manage those resources, because the provider authenticates before it plans, and the credential determines the workspace." A new team space and its agents are two configurations: one, run by an admin, creates the workspace and a CI identity for it; a second, run with that identity, holds the agents. Anthropic recommends setting workspace_id in the second one's provider block so it stops if the credential points anywhere else.
I like this more than I expected. It is the same split most teams already have between whoever owns the cloud account and whoever owns the service. It just arrives as an error message instead of a design document.
For CI, the provider has a proper answer to long-lived keys: workload identity federation. The repository ships examples for GitHub Actions, GitLab and HCP Terraform. One detail from the docs is worth knowing before your first pipeline fails: on GitHub Actions, use a federation profile rather than the raw environment variables, or terraform apply fails. And at a terminal, "unless the provider block sets profile, a variable that's set wins over a profile, and the provider prints no warning." A forgotten export in your shell decides which identity you're applying as. Set profile in the provider block and that ambiguity goes away.
What state knows about your agents
Anthropic doesn't soften this: "Terraform stores everything you configure in plain text in its state, and plan output shows the same values, including in pull-request comments and CI logs." For Managed Agents that means system prompts, custom tool schemas, memory content and inline skill files. If your prompt is something you'd rather a contractor with read access to the state bucket didn't see, plan for it.
Secrets are handled better. Every secret-bearing resource argument ends in _wo, for write-only: vault credential tokens, OAuth refresh tokens and client secrets, the GitHub token a deployment uses to clone a private repository, telemetry headers. Write-only values never reach state. They need Terraform 1.11, and they need one more habit:
variable "linear_token" {
type = string
sensitive = true
ephemeral = true
}
resource "anthropic_beta_vault_credential" "linear" {
vault_id = anthropic_beta_vault.triage.id
auth = {
static_bearer = {
mcp_server_url = local.linear
token_wo = var.linear_token
token_wo_version = 1
}
}
}
ephemeral = true matters because "a saved plan records the value of every variable that isn't ephemeral." And since Terraform never stores the token, it can't tell when you rotate it. You bump token_wo_version to send the new one.
One more line from the provider's own docs changed how I'd write agents: state holds "the MCP server URLs of every agent that Terraform reads", so a token in a URL query string ends up there. Put it in a vault credential. The agent schema already marks mcp_servers[].url as sensitive, which keeps it out of plan output, but not out of state.
The rails, and where they end
Deletion protection is on by default for agents, environments, vaults, skills, memory stores, workspaces and service accounts. It's stricter than Terraform's own prevent_destroy: the provider reads the setting from state, so "one apply can't both turn protection off and destroy the resource", and protection survives deleting the resource block. Good. Destroy is mostly forever: a workspace destroy "archives the workspace and its Developer API keys permanently", an agent destroy archives it "and its deployments with it", a skill destroy deletes every published version.
Console edits get overwritten. That's what Terraform is for, but it surprises people the first week. A skill someone publishes by hand gets a "Skill changed outside Terraform" warning, and the next apply publishes your files again. Anthropic recommends running terraform plan on a schedule to catch drift. There is an odd exception: remove subagents, workflows or advisor from an agent's config and "the agent keeps the value that it has." Deleting a line does not turn the feature off. You write disabled = {} instead.
Imports work, minus the secrets. Import blocks and -generate-config-out are supported, but secrets, skill files and sensitive URLs don't come back, so an imported agent with an MCP server needs its URL typed in again.
Failures need a human. After a server error or a dropped connection, "the provider doesn't retry most creates, to avoid duplicates." You check whether the object exists and import it. Rate limits are retried after the wait the API asks for, and a comment in the provider's source warns that the wait "can be a minute", during which the run looks stuck.
What's missing. No resource for API keys: the Admin API FAQ says the Admin API "can only read, rename, and change the status of existing keys." No invites and no organization-member resource; organization users are data sources only, so you can grant workspace roles to people who already joined, but not invite them. A bootstrap from an empty organization still starts outside Terraform. And it's a beta in the plain sense: "Resource types and their arguments can change during the beta," and per the docs "some backward-incompatible changes can ship in a minor version." Pin ~> 0.1.0 and commit the lock file.
Two small oddities from the Registry. It labels the provider tier "community", while Anthropic's docs call anthropics/anthropic "the only official source address" and warn that a provider "installed from any other address could read" your credentials. And the Registry page says Terraform 1.0 works (1.11 for write-only secrets) while the docs list 1.11 as a requirement. Use 1.11.
My take
The provider is good, and the reason isn't Terraform. It's that an agent gets the property other production software has: you can see what changed, who changed it and what was running before.
The two-identity split will annoy people for a week and then save them, because the person who can create a workspace shouldn't also be the credential your nightly agent runs with. The weak spot is state. Prompts and memory content sitting in plain text in a bucket is a fine trade for most teams, but it needs a decision, not a default.
What I can't tell you yet is how it behaves against a live organization: how a plan reads when a long prompt changes, and how often those rate-limit waits show up. My first real test will be importing an existing agent and checking that the second plan comes back clean.
Three guesses, labelled as guesses:
- By June 30, 2027, the provider reaches 1.0 and the Managed Agents resources lose the
beta_prefix. - By the end of 2027, API key creation is still not a resource, and the one Console click stays in every bootstrap runbook. The Admin API can't create keys today, and that looks deliberate.
- Within a year, "the prompt changed and nobody reviewed it" becomes a named failure in incident write-ups, and the fix cited is moving the agent into code.
If you run Managed Agents in production today, import one agent and commit its definition, even before you automate the apply.