Claude Platform Docs
SDKs, CLI, and librariesTerraform provider

How the Terraform provider behaves

Facts to look up about the Anthropic Terraform provider: where it finds credentials, what destroy does, and what state holds.

Credential lookup order

The provider uses 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.

Organization pin

On the Claude API, every provider block requires organization_id. The cloud platforms use other arguments, as Cloud platforms describes. Find the ID on the Organization settings page in the Claude Console, or in the output of ant auth status.

Before it plans or applies anything, the provider confirms that its credentials belong to that organization, and stops if they don’t:

the configured credentials belong to organization 11111111-..., but the
provider is pinned to organization_id = 00000000-...; refusing to plan or
apply. Use credentials for that organization or update organization_id

The provider reads its organization_id and workspace_id arguments only from the provider block. The ANTHROPIC_ORGANIZATION_ID and ANTHROPIC_WORKSPACE_ID federation environment variables, and a profile file’s settings of the same names, belong to the credential. A profile’s workspace_id, for example, names the workspace to sign in to.

Workspace pin

workspace_id is optional on the Claude API, and checks the workspace as well:

provider "anthropic" {
  organization_id = "00000000-0000-0000-0000-000000000000"
  workspace_id    = "wrkspc_00000000000000000000000"
}

Find the ID under Workspaces in the Claude Console.

The credential determines which workspace the provider acts in, and workspace_id only checks it. If the credential acts in a different workspace, the provider stops with an error.

Which workspace a credential acts in depends on its type and its OAuth scopes:

CredentialWorkspace that it acts in
Federation profile, unless its only scope is org:adminIts rule’s workspace. If the rule covers all workspaces or more than one, the workspace in the profile file’s own workspace_id setting, not the provider block’s.
Login, unless its only scope is org:adminThe workspace that you picked when you signed in. Otherwise, the organization’s default workspace. To use another workspace, see Switch between workspaces.
Workspace-scoped Developer API keyThe workspace it’s scoped to.
Federation or login token whose only scope is org:adminNone.
Admin API keyNone.

The last two rows are organization-level credentials. A block that uses one can’t set workspace_id. Some personal keys and service account keys are scoped to the organization, not to one workspace. The provider treats such a key as an organization-level credential.

A login with only org:admin isn’t tied to a workspace. A federation token with only that scope is tied to one, but you can’t pin it with workspace_id. For such a token to manage organization webhooks, that workspace must be your organization’s default workspace. The table’s first row says how a federation token gets its workspace.

Resources and what terraform destroy does

For each resource’s arguments and attributes, see its reference page on the Terraform Registry. The provider has more resource types than these docs cover, and the Registry lists them all. Some resources have deletion protection, which is on by default. While it’s on, terraform destroy stops with an error instead of doing what the following tables say.

Organization resources

The organization resources manage your organization’s workspaces and their members, its service accounts and federation rules, its encryption keys, and its OpenTelemetry destinations. They call the Admin API. For the rest of the Admin API, such as Developer API keys, invites, and usage reports, call it directly. For a full example, see Example: a team’s workspace and CI identity.

Resourceterraform destroy
anthropic_workspaceArchives the workspace and its Developer API keys permanently.
anthropic_workspace_memberRemoves the user from the workspace.
anthropic_service_accountArchives the service account permanently.
anthropic_workspace_service_accountRemoves the service account from the workspace. In the default workspace, destroy only sets the account’s role back to workspace_user.
anthropic_federation_issuerArchives the issuer permanently.
anthropic_federation_ruleArchives the rule permanently.
anthropic_federation_rule_workspaceDisables the rule in that workspace. A rule with applies_to_all_workspaces set to true stays enabled there, as Federation rules describes.
anthropic_external_keyDeletes the key configuration, but only while no workspace, archived or not, uses the key. Attaching the key to a workspace is one-way. To stop managing the key, use a removed block with lifecycle { destroy = false }.
anthropic_beta_telemetry_destinationDeletes the destination.

Use anthropic_workspace_member for people with an organization role such as user or developer. Organization admins and billing members already hold a role in every workspace. The API rejects adding them to a workspace or removing them from one.

Managed Agents resources

These resources set up Claude Managed Agents in the workspace that the provider acts in. You create them once, and they last across sessions. For the concepts, see the Claude Managed Agents overview.

Resourceterraform destroyPages that show it in Terraform
anthropic_beta_agentArchives the agent permanently, and its deployments with it.Define your agent, Tools, MCP connector, Multiagent orchestration
anthropic_beta_environmentDeletes the environment.Cloud environment setup
anthropic_beta_vaultDeletes the vault.Authenticate with vaults
anthropic_beta_vault_credentialDeletes the credential.Authenticate with vaults
anthropic_skillDeletes the skill and all of its versions.Skills
anthropic_beta_memory_storeDeletes the store.Using agent memory
anthropic_beta_memoryDeletes the document.Using agent memory
anthropic_beta_deploymentArchives the deployment permanently, which ends its schedule.Scheduled deployments

Each beta_ type calls a beta API. The provider sends that API’s beta header on every call.

Credentials for each resource

This table shows which credentials the resources on this page accept on the Claude API.

ResourcesFederation profileLoginWorkspace-scoped Developer API keyAdmin API key
Managed Agents resourcesRule with workspace:developer. No other scope works.With the default scopes, as Run Terraform at a terminal describes.
--scope org:admin replaces them.
YesNo
Organization resources: workspaces, workspace members, external keys, OpenTelemetry destinations, and organization user data sourcesRule with org:admin--scope org:adminNoYes
Organization resources: service accounts, workspace service accounts, federation issuers, federation rules, and federation rule workspacesRule with org:admin--scope org:adminNoNo. These endpoints need an org:admin token.

In this table, a token from the federation environment variables counts as a federation profile. A token in ANTHROPIC_AUTH_TOKEN or the block’s auth_token counts as the credential that it came from.

A login acts with your own role. To create, change, or destroy agents, deployments, vaults, vault credentials, or environments, you need at least a developer role. That role can be in the organization or in the workspace that the login acts in, where Workspace Limited Developer also counts. With a lower role, such as user or billing, you can read these resources, but the API refuses those changes. A login needs no developer role for memory stores and memories. For skills, it needs at least a developer role, even to read them. A personal key scoped to a workspace is limited by your role too, including on skills and on reading environments.

Some changes need the Claude Console even with org:admin, such as managing a federation rule that grants that scope. For the list, see Permissions and constraints.

If your federation profile or login lacks org:admin, the API returns “not found” for service accounts, workspace service accounts, and federation resources. You get the same answer if your login holds org:admin but the person it belongs to is no longer an organization admin. An API key gets a clear refusal instead.

If Terraform already manages any of these resources, it can’t tell whether they still exist. terraform plan, terraform apply, and terraform destroy stop with an error such as “Cannot tell whether the resource exists” and keep the resources in state.

To fix the error, give the provider block that manages the resources a credential with org:admin, and then run the command again. The credential’s user or service account needs the admin organization role. For instructions, see Organization credentials.

A personal or service account key scoped to the organization can’t manage Managed Agents resources through the provider. It also can’t manage service accounts, workspace service accounts, or federation resources. To manage workspaces, workspace members, external keys, and OpenTelemetry destinations, its user or service account needs the admin organization role.

Resources on each cloud platform

On Claude Models on Google Cloud (Anthropic managed) and Claude Platform on AWS, the provider block’s workspace_id names the workspace that the provider acts in, in place of organization_id. That workspace must exist before you run terraform plan. Your cloud’s IAM, not workspace_id, determines what your cloud credentials can reach.

Claude Platform on AWS

Of the resources in the tables under Resources and what terraform destroy does, you can use these on this platform, and any data sources they have:

  • anthropic_workspace
  • anthropic_external_key
  • anthropic_beta_telemetry_destination
  • anthropic_beta_agent
  • anthropic_beta_environment
  • anthropic_beta_vault
  • anthropic_beta_vault_credential
  • anthropic_skill
  • anthropic_beta_memory_store
  • anthropic_beta_memory

You can also use these:

  • anthropic_beta_skill
  • anthropic_compliance_settings
  • The anthropic_models data source

Claude Models on Google Cloud (Anthropic managed)

Of the resources in the tables under Resources and what terraform destroy does, you can use these on this platform, and any data sources they have:

  • anthropic_external_key
  • anthropic_beta_agent
  • anthropic_beta_environment
  • anthropic_beta_vault
  • anthropic_beta_vault_credential
  • anthropic_skill
  • anthropic_beta_memory_store
  • anthropic_beta_memory
  • anthropic_beta_deployment

You can also use these:

  • anthropic_beta_skill
  • anthropic_compliance_settings
  • The anthropic_models data source
  • The anthropic_rate_limits data source
  • The anthropic_workspace_rate_limits data source
  • The anthropic_workspaces data source

Claude Managed Agents on Amazon Bedrock

On this platform, you can use these resources and their data sources:

  • anthropic_beta_bedrock_agent
  • anthropic_beta_bedrock_memory_store
  • anthropic_beta_bedrock_memory

Here, workspace_id names an Amazon Bedrock project, as Claude Managed Agents on Amazon Bedrock describes. terraform destroy archives an agent permanently and deletes a memory store or a memory. Agents and memory stores have deletion protection.

Deletion protection

While deletion_protection is on, the provider stops with an error instead of destroying or replacing a resource. If terraform destroy or a deleted resource block would destroy a protected resource, the plan fails and nothing is destroyed. Resources such as anthropic_workspace, anthropic_service_account, anthropic_federation_rule, and anthropic_skill have this argument, and each one’s page on the Terraform Registry shows it. It defaults to true, including for a resource that you import or that an earlier provider build created.

The provider reads the setting from state, so one apply can’t both turn protection off and destroy the resource. For the same reason, and unlike lifecycle { prevent_destroy = true }, protection still holds after you delete the resource block. For the steps, see Destroy or replace a protected resource.

Forced replacements

Some changes to your configuration replace a resource. While protection is on, a plan that includes such a change fails.

Terraform doesn’t tell the provider when it forces a replacement through -replace, replace_triggered_by, or a tainted resource. While protection is on, the apply fails even if the plan ran without errors. Before the apply stops, it can destroy resources that depend on the protected resource. To turn protection off first, see Destroy or replace a protected resource.

Service account name clash

In a forced replacement of a service account that has create_before_destroy, Terraform creates the new account before it archives the old one. Two service accounts that aren’t archived can’t share a name, so creating the new account fails. Give the new account a different name in the apply that replaces the old one. To rename an account, see Rename a service account.

Agent versions

Every change to an agent publishes a new version. The version attribute starts at 1 and increases with each apply that changes the agent. A session that names only the agent’s ID uses the latest version. A session that also names a version stays on that version.

Multiagent settings

An agent’s multiagent argument takes an object whose one key is a dated type name: multiagent = { multiagent_20261001 = { ... } }. With the multiagent_20261001 type, an agent can hand work to subagents, start workflow runs, and consult an advisor model. The type’s settings, subagents, workflows, and advisor, go inside the multiagent_20261001 object. See Multiagent orchestration for what each setting does.

subagents.enabled.predefined_agents lists the agents that the agent can delegate to, and workflows.enabled.predefined_agents lists the agents that a workflow can use. Both settings take the same shape: subagents = { enabled = { predefined_agents = [...] } }.

To turn a setting off, write disabled = {} inside it, as in workflows = { disabled = {} }. If you remove subagents, workflows, or advisor from your Terraform configuration, the agent keeps the value that it has.

Entries that name an agent

An entry that names an agent takes the shape { agent = { id = ..., version = ... } }. Each entry in either list determines which version of its agent runs:

  • An entry such as { agent = { id = anthropic_beta_agent.researcher.id, version = anthropic_beta_agent.researcher.version } } tracks the researcher, so an apply that changes the researcher also updates the list.
  • An entry with only an id gets the agent’s latest version when you first apply the entry. It gets the latest version again whenever the entry’s position in the list changes, as when you add or remove an entry above it. It stays on its version when the agent gets a new one.
  • An entry with a literal version stays pinned to that version.

A { self = {} } entry lets the agent delegate to copies of itself.

Skill files

anthropic_skill publishes a folder of files as a skill. Each file block sets path, the file’s path in the skill, and exactly one of these:

  • source, the path of a file on disk. Binary files work.
  • content, text written in the configuration.

Every file block’s path starts with the same top-level folder, and SKILL.md sits directly inside it, as in my-skill/SKILL.md. The folder’s name must match the name in the SKILL.md frontmatter.

Changing display_name or the name in SKILL.md replaces the skill, which deletes all of its versions. Turn off deletion protection before you make either change.

Skill versions

Each apply that changes a file publishes a new version, and latest_version_id shows the newest one. An agent that lists the skill in its skills argument without a version uses the latest version.

Deployments

Deployment versions

agent names the agent and, optionally, its version, as in agent = { agent = { id = anthropic_beta_agent.reporter.id, version = anthropic_beta_agent.reporter.version } }. With version set this way, 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.

Paused deployments

A run of an anthropic_beta_deployment can fail in a way that retrying won’t fix, such as when its environment or vault was archived or deleted. The API then pauses the deployment, and Terraform doesn’t resume it. The read-only status shows paused, with the reason in paused_reason. Fix the cause, and then unpause the deployment, as Managing deployment lifecycle describes.

Changes made outside Terraform

Federation rules

A rule’s own workspace_id enables the rule in one workspace. Each anthropic_federation_rule_workspace enables the rule in one more workspace.

While applies_to_all_workspaces is true, a rule is enabled in every workspace, whatever its workspace_ids list holds. Creating or destroying an anthropic_federation_rule_workspace then only edits that list, and so do the changes in the following table.

To limit the rule to specific workspaces, set applies_to_all_workspaces to false and set the rule’s own workspace_id in the same apply. The rule is then enabled only in the workspaces on its workspace_ids list, which can hold more than the one that you set.

Change that someone makes outside TerraformWhat Terraform does
Someone disables the rule in the workspace that an anthropic_federation_rule_workspace names.The next terraform plan shows the change. The next terraform apply enables the rule in that workspace again.
Someone enables the rule in another workspace.Terraform does nothing, so the rule stays enabled in that workspace. A plain terraform plan reports no changes. terraform plan -refresh-only shows the added workspace in the rule’s workspace_ids attribute. The next terraform apply saves the new list in state, so no later plan shows the change.

The Compliance API records each of these changes and who made it.

Skill versions published elsewhere

If someone publishes a version of the skill outside Terraform, the next plan shows a “Skill changed outside Terraform” warning. The plan can’t show what changed in the skill’s files. Terraform proposes to publish your declared files as a new version, and the next apply does that. See Skills.

Memory documents that agents edit

Because agents edit documents during sessions, a configuration that also manages a document’s content can overwrite their edits. For documents that agents own, add lifecycle { ignore_changes = [content] } to their anthropic_beta_memory resources. See Using agent memory.

Deleted or archived objects

If someone deletes or archives an object outside Terraform, the next plan warns that the object is gone and proposes to create it again. For service accounts, workspace service accounts, and federation resources, a federation profile or login without org:admin gets an error instead. See Credentials for each resource.

State and plan output

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. Marking a value as sensitive hides it from plan output, but Terraform still stores it in state.

For organization resources, state holds:

  • The layout of your workspaces and service accounts
  • Your federation issuers and rules
  • The identifiers of your encryption keys
  • Your OpenTelemetry destinations’ endpoint URLs and header names
  • Members’ names, emails, and roles, if you use the anthropic_organization_user or anthropic_organization_users data source

It holds no secrets, but it shows which people and which service accounts can act in your organization.

For Managed Agents resources, state holds agent system prompts, custom tool schemas, memory content, and skill files written as content. For a skill file given as source, state stores only its hash. Vault credential secrets and a deployment’s GitHub repository token are the exceptions: they’re write-only arguments.

Write-only arguments

The secret arguments of an anthropic_beta_vault_credential, such as token_wo and secret_value_wo, are write-only. Terraform sends a write-only value to the API but never stores it in state or plans. Declare the variables that supply these arguments with ephemeral = true, as Keep state and plans safe explains.

Terraform can’t detect when a write-only value changes, and the API never returns secrets.

Each write-only argument has a companion _wo_version argument, such as token_wo_version. To send a new value, for example after you rotate a secret, change its _wo_version.

Vault credentials

The API matches a vault credential to an agent’s MCP server by URL alone, so the credential’s mcp_server_url must be the same URL as the agent’s mcp_servers entry. Where a service supports OAuth, prefer an mcp_oauth credential with a refresh token over a long-lived static token.

Error messages

When the API returns an error, the provider reports its message, its type, the endpoint, and the request ID. To report a problem, open an issue in the provider’s GitHub repository, and include the request ID.

Semantic versioning

The provider generally follows Semantic Versioning 2.0.0 conventions. Some backward-incompatible changes can ship in a minor version. Because the provider is in beta, resource types and their arguments can also change in ways that require updates to your configuration. Commit your lock file, so that you choose when to take a new release.

Was this page helpful?