◈AI Codex
Claude APIupdate

The Anthropic Terraform provider: workspaces, CI identities, and agents as code

In brief

On December 3, 2026 Anthropic released a Terraform provider in beta. It manages Claude Platform organization resources (workspaces, service accounts, federation rules) and Claude Managed Agents resources (agents, environments, vaults, skills). A first configuration, which credential each resource needs, what destroy really does, and when to use it instead of ant apply.

9 min read··Managed Agents

Contents

♡Sign in to save

On December 3, 2026, Anthropic released a Terraform provider in beta. Terraform is a tool that reads configuration files describing the infrastructure you want, compares them with what exists, and makes the changes. With this provider, your Claude Platform setup goes through the same plan, review, and apply steps as your cloud accounts and databases.

The provider manages two groups of resources:

  • Organization resources: workspaces and their members, service accounts, Workload Identity Federation issuers and rules, encryption keys, and OpenTelemetry destinations.
  • Claude Managed Agents resources: agents, environments, vaults and vault credentials, skills, memory stores, and scheduled deployments.

It is a beta. Anthropic says resource types and their arguments can change, so commit your Terraform lock file and upgrade on purpose.

What you need

A first configuration

Create main.tf in an empty directory:

terraform {
  required_providers {
    anthropic = {
      source = "anthropics/anthropic"
    }
  }
}

variable "organization_id" {
  type = string
}

# Pins this configuration to one organization. Every plan verifies
# that the credentials belong to it, and refuses to proceed otherwise.
provider "anthropic" {
  organization_id = var.organization_id
}

resource "anthropic_beta_environment" "sandbox" {
  name        = "quickstart"
  description = "Cloud sandbox for the quickstart agent."

  config = {
    cloud = {
      networking = {
        limited = {
          allow_package_managers = true
        }
      }
    }
  }
}

resource "anthropic_beta_agent" "assistant" {
  name        = "quickstart-assistant"
  description = "General-purpose assistant with the built-in toolset."

  model = {
    id = "claude-opus-5-5"
  }

  system = "You are a concise, careful assistant."

  tools = [
    {
      agent_toolset_20260401 = {
        configs = [
          { web_search = { enabled = false } },
          { web_fetch = { enabled = false } },
        ]
      }
    },
  ]
}

output "agent_id" {
  value = anthropic_beta_agent.assistant.id
}

output "environment_id" {
  value = anthropic_beta_environment.sandbox.id
}

Then sign in and apply:

ant auth login
export TF_VAR_organization_id="00000000-0000-0000-0000-000000000000"

terraform init
terraform plan
terraform apply

Your organization ID is on the Organization settings page in the Claude Console, and in the output of ant auth status.

Run terraform plan once more after the apply. It should say No changes. If it proposes changes you did not make, Anthropic asks you to report it as a bug.

One safety note on the source address. anthropics/anthropic is the only official address. A provider runs with access to your Anthropic credentials, so a provider installed from any other address could read them. Check the spelling in code review.

The credential that silently wins

The provider takes the first credential it finds, in this order:

  1. profile, api_key, or auth_token in the provider block
  2. The ANTHROPIC_API_KEY environment variable
  3. The ANTHROPIC_AUTH_TOKEN environment variable
  4. The profile named by ANTHROPIC_PROFILE
  5. The federation environment variables
  6. The active profile from ant auth login

If your shell or CI job exports ANTHROPIC_API_KEY, it beats your login, and the provider prints no warning. Unset it, or set profile in the provider block so the configuration always uses one named profile. Do not write a key or token in the provider block, because whatever you put there also lands in plan files.

The organization_id pin is the backstop. If the credential belongs to a different organization, the plan stops before anything changes.

Which credential each resource needs

This is where most first attempts fail. Agent resources and organization resources need different credentials.

You are managing What works What does not
Agents, environments, vaults, skills, memory stores, deployments A login with default scopes, a workspace-scoped Developer API key, or a federation rule with workspace:developer An Admin API key
Workspaces, workspace members, external keys, OpenTelemetry destinations An Admin API key, or a login or federation rule with org:admin A workspace-scoped API key
Service accounts and federation issuers and rules A login or federation rule with org:admin only Any API key, including an Admin API key

For organization resources at a terminal, an organization admin signs in with:

ant auth login --profile admin --scope org:admin

A confusing failure to know about: without org:admin, the API answers "not found" for service accounts and federation resources. If Terraform already manages them, plan and apply stop with "Cannot tell whether the resource exists" and keep the resources in state. The fix is the credential, not the configuration.

Running it from CI

Anthropic recommends Workload Identity Federation for pipelines: the CI job proves who it is with its own identity token and gets a short-lived access token, so no long-lived key sits in your CI secrets.

One detail matters on GitHub Actions. Use a federation profile file, not the federation environment variables. terraform apply connects twice, once to plan and once to apply, and by default the API accepts a GitHub Actions identity token only one time. The profile saves the access token so the second connection works.

You can create the CI identity itself in Terraform. This is the start of Anthropic's organization/federated-ci example:

resource "anthropic_workspace" "research" {
  name = "research"
}

resource "anthropic_service_account" "ci" {
  name        = "research-ci"
  description = "Deploys the research team's agents from CI."

  lifecycle {
    create_before_destroy = true
  }
}

resource "anthropic_workspace_service_account" "ci" {
  workspace_id       = anthropic_workspace.research.id
  service_account_id = anthropic_service_account.ci.id
  workspace_role     = "workspace_developer"
}

resource "anthropic_federation_issuer" "github" {
  name       = "github-actions"
  issuer_url = "https://token.actions.githubusercontent.com"
}

The full example adds an anthropic_federation_rule that matches pushes to one repository's main branch. It is in the provider repository.

Do not keep a long-lived organization admin credential on a shared runner. Other providers and provisioners in the same configuration can read credentials from the environment.

What destroy really does

Several of these resources cannot be brought back, so read this table before you run terraform destroy on anything real.

Resource What destroy does
anthropic_workspace Archives the workspace and its Developer API keys permanently
anthropic_service_account Archives it permanently
anthropic_federation_issuer, anthropic_federation_rule Archived permanently
anthropic_beta_agent Archives the agent permanently, and its deployments with it
anthropic_beta_environment, anthropic_beta_vault Deleted
anthropic_skill Deletes the skill and all of its versions
anthropic_beta_memory_store Deletes the store

Deletion protection is on by default for resources that have it. terraform destroy stops with an error until you add deletion_protection = false to the resource and apply that change first. Leave it on in production.

Terraform or ant apply?

Anthropic already ships ant apply, which syncs agent definitions from YAML files (see Agents as files with ant apply). The two overlap on agent resources. A reasonable split:

  • Use Terraform if your company already runs Terraform, if you want workspaces and CI identities under the same review process as the rest of your infrastructure, or if a platform team owns the setup. It is the only one of the two that manages organization resources.
  • Use ant apply if the people changing agents are the application team, there is no Terraform state to host, and you only need agents, environments, and skills.

Pick one tool per resource. If both manage the same agent, each will try to undo the other's changes.

On AWS and Google Cloud

The provider also works on Claude Platform on AWS and Claude Models on Google Cloud (Anthropic managed), with a subset of resources. There, workspace_id in the provider block takes the place of organization_id, and your cloud's IAM decides what the credentials can reach. On Claude Managed Agents on Amazon Bedrock, it manages agents, memory stores, and memories. The behavior reference lists the resources for each platform.

A first week with it

  1. Apply the quickstart above in a test workspace and confirm the second plan shows no changes.
  2. Import one existing agent instead of recreating it, so you learn the import flow on something low-risk.
  3. Move one team's workspace and CI identity into Terraform with the federated-ci example.
  4. Commit the lock file. Read the provider's release notes before each upgrade while it is in beta.

Sources: Terraform provider, How the Terraform provider behaves, Authenticate the Terraform provider, and the Claude Platform release notes, December 3, 2026.

Related tools

Weekly brief

For people actually using Claude at work.

Each week: one thing Claude can do in your work that most people haven't figured out yet — plus the failure modes to avoid. No tutorials. No hype.

No spam. Unsubscribe anytime.

What to read next

Picked for where you are now

All articles →