---
title: Terraform provider 的行為方式
url: https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior
description: 關於 Anthropic Terraform provider 的查閱資訊：它在哪裡尋找憑證、destroy 會做什麼，以及 state 中保存了什麼。
---

## 憑證查找順序

provider 會依下列順序，使用它找到的第一個憑證：

1. provider 區塊中的 `profile`、`api_key` 或 `auth_token`。
2. `ANTHROPIC_API_KEY` 環境變數。
3. `ANTHROPIC_AUTH_TOKEN` 環境變數。
4. 由 `ANTHROPIC_PROFILE` 指定的 profile。
5. [聯合環境變數](https://platform.claude.com/docs/zh-TW/manage-claude/wif-reference#environment-variables)。
6. 作用中的 profile。

## 組織固定

在 Claude API 上，每個 provider 區塊都需要 `organization_id`。雲端平台使用其他引數，如[雲端平台](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#cloud-platforms)所述。您可以在 Claude Console 的[組織設定](https://platform.claude.com/settings/organization)頁面上，或在 `ant auth status` 的輸出中找到此 ID。

在規劃或套用任何內容之前，provider 會確認其憑證屬於該組織，若不屬於則會停止：

```text wrap
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
```

provider 只會從 provider 區塊讀取其 `organization_id` 和 `workspace_id` 引數。`ANTHROPIC_ORGANIZATION_ID` 和 `ANTHROPIC_WORKSPACE_ID` [聯合環境變數](https://platform.claude.com/docs/zh-TW/manage-claude/wif-reference#environment-variables)，以及 profile 檔案中同名的設定，屬於憑證。例如，profile 的 `workspace_id` 會指定要登入的工作區。

## 工作區固定

`workspace_id` 是選用的（在 Claude API 上），它也會檢查工作區：

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

請在 [Claude Console 中的工作區](https://platform.claude.com/settings/workspaces)下找到此 ID。

憑證決定 provider 在哪個工作區中執行操作，而 `workspace_id` 只負責檢查。如果憑證在不同的工作區中執行操作，provider 會以錯誤停止。

憑證在哪個工作區中執行操作，取決於其類型及其 [OAuth 範圍](https://platform.claude.com/docs/zh-TW/manage-claude/wif-reference#oauth-scopes)：

| 憑證 | 其執行操作的工作區 |
| ----- | ----- |
| 聯合 profile，除非其唯一範圍是 `org:admin` | 其規則的工作區。如果規則涵蓋所有工作區或多個工作區，則為 profile 檔案本身 `workspace_id` 設定中的工作區，而非 provider 區塊中的。 |
| 登入，除非其唯一範圍是 `org:admin` | 您登入時所選的工作區，否則為組織的預設工作區。若要使用其他工作區，請參閱[在工作區之間切換](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/cli/authentication#switch-between-workspaces)。 |
| 工作區範圍的[開發者 API 金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/api-keys#key-types) | 其所限定的工作區。 |
| 唯一範圍是 `org:admin` 的聯合或登入權杖 | 無。 |
| Admin API 金鑰 | 無。 |

最後兩列是組織層級的憑證。使用這類憑證的區塊無法設定 `workspace_id`。某些[個人金鑰和服務帳戶金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/api-keys#key-types)限定於組織，而非單一工作區。provider 會將這類金鑰視為組織層級的憑證。

僅具有 `org:admin` 的登入不會綁定到任何工作區。僅具有該範圍的聯合權杖會綁定到一個工作區，但您無法使用 `workspace_id` 固定它。若要讓這類權杖管理[組織 webhook](https://platform.claude.com/docs/zh-TW/manage-claude/organization-webhooks#before-you-begin)，該工作區必須是您組織的[預設工作區](https://platform.claude.com/docs/zh-TW/manage-claude/workspaces#how-workspaces-work)。表格的第一列說明了聯合權杖如何取得其工作區。

## 資源以及 `terraform destroy` 的作用

如需每個資源的引數和屬性，請參閱其參考頁面（位於 [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs)）。provider 擁有的資源類型比這些文件涵蓋的更多，Registry 會列出全部類型。某些資源具有[刪除保護](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection)，且預設為啟用。在其啟用時，`terraform destroy` 會以錯誤停止，而不會執行下列表格所述的動作。

### 組織資源

組織資源管理您組織的[工作區](https://platform.claude.com/docs/zh-TW/manage-claude/workspaces)及其成員、其[服務帳戶和聯合規則](https://platform.claude.com/docs/zh-TW/manage-claude/workload-identity-federation)、其[加密金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/cmek)，以及其 [OpenTelemetry 目的地](https://platform.claude.com/docs/zh-TW/manage-claude/opentelemetry/api)。它們會呼叫 [Admin API](https://platform.claude.com/docs/zh-TW/manage-claude/admin-api)。對於 Admin API 的其餘部分，例如開發者 API 金鑰、邀請和用量報告，請直接呼叫它。如需完整範例，請參閱[範例：團隊的工作區與 CI 身分](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#example-a-teams-workspace-and-ci-identity)。

| 資源 | `terraform destroy` |
| ----- | ----- |
| `anthropic_workspace` | 永久封存工作區及其開發者 API 金鑰。 |
| `anthropic_workspace_member` | 將使用者從工作區中移除。 |
| `anthropic_service_account` | 永久封存服務帳戶。 |
| `anthropic_workspace_service_account` | 將服務帳戶從工作區中移除。在[預設工作區](https://platform.claude.com/docs/zh-TW/manage-claude/workspaces#how-workspaces-work)中，destroy 只會將帳戶的角色設回 `workspace_user`。 |
| `anthropic_federation_issuer` | 永久封存簽發者。 |
| `anthropic_federation_rule` | 永久封存規則。 |
| `anthropic_federation_rule_workspace` | 在該工作區中停用規則。`applies_to_all_workspaces` 設為 `true` 的規則會在該處保持啟用，如[聯合規則](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#federation-rules)所述。 |
| `anthropic_external_key` | 刪除金鑰設定，但僅在沒有任何工作區（無論是否已封存）使用該金鑰時。將金鑰附加到工作區是單向的。若要停止管理該金鑰，請使用搭配 `lifecycle { destroy = false }` 的 `removed` 區塊。 |
| `anthropic_beta_telemetry_destination` | 刪除目的地。 |

對於具有使用者或開發者等組織角色的人員，請使用 `anthropic_workspace_member`。組織管理員和帳單成員已在每個工作區中擁有角色。API 會拒絕將他們新增到工作區或從工作區中移除。

### Managed Agents 資源

這些資源會在 provider 執行操作的工作區中設定 Claude Managed Agents。您只需建立一次，它們會跨工作階段持續存在。如需相關概念，請參閱 [Claude Managed Agents 概覽](https://platform.claude.com/docs/zh-TW/managed-agents/overview)。

| 資源 | `terraform destroy` | 以 Terraform 示範的頁面 |
| ----- | ----- | ----- |
| `anthropic_beta_agent` | 永久封存代理程式，並一併封存其部署。 | [定義您的代理](https://platform.claude.com/docs/zh-TW/managed-agents/agent-setup)、[工具](https://platform.claude.com/docs/zh-TW/managed-agents/tools)、[MCP 連接器](https://platform.claude.com/docs/zh-TW/managed-agents/mcp-connector)、[多代理協調](https://platform.claude.com/docs/zh-TW/managed-agents/multiagent-orchestration) |
| `anthropic_beta_environment` | 刪除環境。 | [雲端環境設定](https://platform.claude.com/docs/zh-TW/managed-agents/environments) |
| `anthropic_beta_vault` | 刪除保存庫。 | [使用 vault 進行驗證](https://platform.claude.com/docs/zh-TW/managed-agents/vaults) |
| `anthropic_beta_vault_credential` | 刪除憑證。 | [使用 vault 進行驗證](https://platform.claude.com/docs/zh-TW/managed-agents/vaults) |
| `anthropic_skill` | 刪除技能及其所有版本。 | [技能](https://platform.claude.com/docs/zh-TW/managed-agents/skills) |
| `anthropic_beta_memory_store` | 刪除儲存區。 | [使用代理記憶](https://platform.claude.com/docs/zh-TW/managed-agents/memory) |
| `anthropic_beta_memory` | 刪除文件。 | [使用代理記憶](https://platform.claude.com/docs/zh-TW/managed-agents/memory) |
| `anthropic_beta_deployment` | 永久封存部署，並因此結束其排程。 | [排程部署](https://platform.claude.com/docs/zh-TW/managed-agents/scheduled-deployments) |

每個 `beta_` 類型都會呼叫一個 beta API。provider 在每次呼叫時都會傳送該 API 的 [beta 標頭](https://platform.claude.com/docs/zh-TW/api/beta-headers)。

## 各資源所需的憑證

此表格顯示本頁的資源接受哪些憑證（在 Claude API 上）。

| 資源 | 聯合 profile | 登入 | 工作區範圍的[開發者 API 金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/api-keys#key-types) | [Admin API 金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/admin-api-keys) |
| ----- | ----- | ----- | ----- | ----- |
| [Managed Agents 資源](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#managed-agents-resources) | [具有 `workspace:developer` 的規則](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#run-terraform-from-a-pipeline)。其他範圍皆無效。 | 使用預設範圍，如[在終端機中執行 Terraform](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#run-terraform-at-a-terminal) 所述。<br />`--scope org:admin` 會取代它們。 | 是 | 否 |
| [組織資源](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#organization-resources)：工作區、工作區成員、外部金鑰、OpenTelemetry 目的地，以及組織使用者資料來源 | [具有 `org:admin` 的規則](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | [`--scope org:admin`](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | 否 | 是 |
| [組織資源](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#organization-resources)：服務帳戶、工作區服務帳戶、聯合簽發者、聯合規則，以及聯合規則工作區 | [具有 `org:admin` 的規則](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | [`--scope org:admin`](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials) | 否 | 否。這些端點需要 `org:admin` 權杖。 |

在此表格中，來自[聯合環境變數](https://platform.claude.com/docs/zh-TW/manage-claude/wif-reference#environment-variables)的權杖視為聯合 profile。`ANTHROPIC_AUTH_TOKEN` 或區塊的 `auth_token` 中的權杖，則視為其來源的憑證。

登入會以您自己的角色執行操作。若要建立、變更或銷毀代理程式、部署、保存庫、保存庫憑證或環境，您至少需要開發者角色。該角色可以位於組織中，也可以位於登入執行操作的工作區中，其中 Workspace Limited Developer 也算在內。使用較低的角色（例如使用者或帳單）時，您可以讀取這些資源，但 API 會拒絕這些變更。對於記憶儲存區和記憶，登入不需要開發者角色。對於技能，登入至少需要開發者角色，即使只是讀取也一樣。限定於工作區的[個人金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/api-keys#key-types)同樣受您的角色限制，包括在技能和讀取環境方面。

某些變更即使擁有 `org:admin` 仍需要使用 Claude Console，例如管理授予該範圍的聯合規則。如需完整清單，請參閱[權限與限制](https://platform.claude.com/docs/zh-TW/manage-claude/wif-admin-api#permissions-and-constraints)。

如果您的聯合 profile 或登入缺少 `org:admin`，API 會對服務帳戶、工作區服務帳戶和聯合資源傳回「not found」。如果您的登入持有 `org:admin`，但其所屬的人員已不再是組織管理員，您也會得到相同的回應。API 金鑰則會收到明確的拒絕。

如果 Terraform 已在管理其中任何一項資源，它無法判斷這些資源是否仍然存在。`terraform plan`、`terraform apply` 和 `terraform destroy` 會以「Cannot tell whether the resource exists」之類的錯誤停止，並將這些資源保留在 state 中。

若要修正此錯誤，請為管理這些資源的 provider 區塊提供具有 `org:admin` 的憑證，然後再次執行該命令。該憑證的使用者或服務帳戶需要管理員組織角色。如需相關說明，請參閱[組織憑證](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#organization-credentials)。

限定於組織的[個人金鑰或服務帳戶金鑰](https://platform.claude.com/docs/zh-TW/manage-claude/api-keys#key-types)無法透過 provider 管理 Managed Agents 資源。它也無法管理服務帳戶、工作區服務帳戶或聯合資源。若要管理工作區、工作區成員、外部金鑰和 OpenTelemetry 目的地，其使用者或服務帳戶需要管理員組織角色。

## 各雲端平台上的資源

在 Claude Models on Google Cloud (Anthropic managed) 和 Claude Platform on AWS 上，provider 區塊的 `workspace_id` 取代 `organization_id`，用來指定 provider 執行操作的工作區。在執行 `terraform plan` 之前，該工作區必須已存在。決定您的雲端憑證可存取哪些內容的是您雲端的 IAM，而非 `workspace_id`。

### Claude Platform on AWS

在[資源以及 `terraform destroy` 的作用](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#resources-and-what-terraform-destroy-does)下各表格中的資源裡，您可以在此平台上使用下列資源，以及它們所具有的任何資料來源：

* `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`

您也可以使用下列項目：

* `anthropic_beta_skill`
* `anthropic_compliance_settings`
* `anthropic_models` 資料來源

### Claude Models on Google Cloud (Anthropic managed)

在[資源以及 `terraform destroy` 的作用](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#resources-and-what-terraform-destroy-does)下各表格中的資源裡，您可以在此平台上使用下列資源，以及它們所具有的任何資料來源：

* `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`

您也可以使用下列項目：

* `anthropic_beta_skill`
* `anthropic_compliance_settings`
* `anthropic_models` 資料來源
* `anthropic_rate_limits` 資料來源
* `anthropic_workspace_rate_limits` 資料來源
* `anthropic_workspaces` 資料來源

### Claude Managed Agents on Amazon Bedrock

在此平台上，您可以使用下列資源及其資料來源：

* `anthropic_beta_bedrock_agent`
* `anthropic_beta_bedrock_memory_store`
* `anthropic_beta_bedrock_memory`

在此，`workspace_id` 指定的是 Amazon Bedrock 專案，如 [Claude Managed Agents on Amazon Bedrock](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/authentication#claude-managed-agents-on-amazon-bedrock) 所述。`terraform destroy` 會永久封存代理程式，並刪除記憶儲存區或記憶。代理程式和記憶儲存區具有[刪除保護](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection)。

## 刪除保護

當 `deletion_protection` 啟用時，provider 會以錯誤停止，而不會銷毀或替換資源。如果 `terraform destroy` 或已刪除的資源區塊會銷毀受保護的資源，規劃會失敗，且不會銷毀任何內容。`anthropic_workspace`、`anthropic_service_account`、`anthropic_federation_rule` 和 `anthropic_skill` 等資源具有此引數，且每個資源在 [Terraform Registry](https://registry.terraform.io/providers/anthropics/anthropic/latest/docs) 上的頁面都會列出它。其預設值為 `true`，包括您匯入的資源或由較早的 provider 版本建立的資源。

provider 從 state 讀取此設定，因此單次 apply 無法同時關閉保護並銷毀資源。基於同樣的原因，且與 `lifecycle { prevent_destroy = true }` 不同，在您刪除資源區塊後，保護仍然有效。如需相關步驟，請參閱[銷毀或取代受保護的資源](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/operations#destroy-or-replace-a-protected-resource)。

### 強制替換

對設定的某些變更會替換資源。在保護啟用時，包含這類變更的規劃會失敗。

當 Terraform 透過 `-replace`、`replace_triggered_by` 或受污染（tainted）的資源強制替換時，並不會通知 provider。在保護啟用時，即使規劃正常執行而不出錯，apply 仍會失敗。在 apply 停止之前，它可能會銷毀依賴於受保護資源的資源。若要先關閉保護，請參閱[銷毀或取代受保護的資源](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/operations#destroy-or-replace-a-protected-resource)。

### 服務帳戶名稱衝突

在對具有 `create_before_destroy` 的服務帳戶進行強制替換時，Terraform 會先建立新帳戶，再封存舊帳戶。兩個未封存的服務帳戶不能使用相同名稱，因此建立新帳戶會失敗。請在替換舊帳戶的 apply 中為新帳戶指定不同的 `name`。若要重新命名帳戶，請參閱[重新命名服務帳戶](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/operations#rename-a-service-account)。

## 代理程式版本

對代理程式的每次變更都會發布新版本。`version` 屬性從 1 開始，每次變更代理程式的 apply 都會使其遞增。只指定代理程式 ID 的工作階段會使用最新版本。同時指定版本的工作階段會停留在該版本。

## 多代理程式設定

代理程式的 `multiagent` 引數接受一個物件，其唯一的鍵是帶日期的類型名稱：`multiagent = { multiagent_20261001 = { ... } }`。使用 `multiagent_20261001` 類型時，代理程式可以將工作交給子代理程式、啟動工作流程執行，以及諮詢顧問模型。該類型的設定 `subagents`、`workflows` 和 `advisor` 放在 `multiagent_20261001` 物件內。如需了解每項設定的作用，請參閱[多代理協調](https://platform.claude.com/docs/zh-TW/managed-agents/multiagent-orchestration)。

`subagents.enabled.predefined_agents` 列出代理程式可以委派的代理程式，而 `workflows.enabled.predefined_agents` 列出工作流程可以使用的代理程式。這兩項設定採用相同的形式：`subagents = { enabled = { predefined_agents = [...] } }`。

若要關閉某項設定，請在其中寫入 `disabled = {}`，例如 `workflows = { disabled = {} }`。如果您從 Terraform 設定中移除 `subagents`、`workflows` 或 `advisor`，代理程式會保留其現有的值。

### 指定代理程式的項目

指定代理程式的項目採用 `{ agent = { id = ..., version = ... } }` 的形式。任一清單中的每個項目，決定其代理程式執行哪個版本：

* 像 `{ agent = { id = anthropic_beta_agent.researcher.id, version = anthropic_beta_agent.researcher.version } }` 這樣的項目會追蹤 researcher，因此變更 researcher 的 apply 也會更新清單。
* 只有 `id` 的項目會在您首次套用該項目時取得代理程式的最新版本。每當該項目在清單中的位置改變時（例如您在其上方新增或移除項目），它會再次取得最新版本。當代理程式有新版本時，該項目會停留在其原有版本。
* 具有字面 `version` 值的項目會固定在該版本。

`{ self = {} }` 項目讓代理程式可以委派給自身的副本。

## 技能檔案

`anthropic_skill` 會將一個資料夾的檔案發布為技能。每個 `file` 區塊會設定 `path`（檔案在技能中的路徑），以及下列其中一項且僅限一項：

* `source`，磁碟上檔案的路徑。二進位檔案也可以使用。
* `content`，寫在設定中的文字。

每個 `file` 區塊的 `path` 都以相同的頂層資料夾開頭，且 `SKILL.md` 直接位於其中，例如 `my-skill/SKILL.md`。資料夾名稱必須與 `SKILL.md` frontmatter 中的 `name` 相符。

變更 `display_name` 或 `SKILL.md` 中的 `name` 會替換技能，這會刪除其所有版本。在進行任一變更之前，請先關閉[刪除保護](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#deletion-protection)。

### 技能版本

每次變更檔案的 apply 都會發布新版本，而 `latest_version_id` 會顯示最新的版本。在其 `skills` 引數中列出該技能但未指定 `version` 的代理程式，會使用最新版本。

## 部署

### 部署版本

`agent` 指定代理程式，並可選擇性地指定其版本，例如 `agent = { agent = { id = anthropic_beta_agent.reporter.id, version = anthropic_beta_agent.reporter.version } }`。以這種方式設定 `version` 時，變更代理程式的 apply 也會將部署移至新版本。未設定 `version` 時，當代理程式有新版本，部署會停留在其原有版本。

### 已暫停的部署

`anthropic_beta_deployment` 的某次執行可能以重試也無法修正的方式失敗，例如其環境或保存庫已被封存或刪除時。API 接著會暫停該部署，而 Terraform 不會恢復它。唯讀的 `status` 會顯示 `paused`，原因則列在 `paused_reason` 中。請修正原因，然後依照[管理部署生命週期](https://platform.claude.com/docs/zh-TW/managed-agents/scheduled-deployments#managing-deployment-lifecycle)所述取消暫停部署。

## 在 Terraform 外部所做的變更

### 聯合規則

規則本身的 `workspace_id` 會在一個工作區中啟用該規則。每個 `anthropic_federation_rule_workspace` 會在另一個工作區中啟用該規則。

當 `applies_to_all_workspaces` 為 `true` 時，無論規則的 `workspace_ids` 清單包含什麼，規則都會在每個工作區中啟用。此時建立或銷毀 `anthropic_federation_rule_workspace` 只會編輯該清單，下列表格中的變更也是如此。

若要將規則限制於特定工作區，請將 `applies_to_all_workspaces` 設為 `false`，並在同一次 apply 中設定規則本身的 `workspace_id`。之後規則只會在其 `workspace_ids` 清單上的工作區中啟用，而該清單可能包含比您設定的那一個更多的工作區。

| 有人在 Terraform 外部所做的變更 | Terraform 的作為 |
| ----- | ----- |
| 有人在 `anthropic_federation_rule_workspace` 指定的工作區中停用了規則。 | 下一次 `terraform plan` 會顯示此變更。下一次 `terraform apply` 會在該工作區中重新啟用規則。 |
| 有人在另一個工作區中啟用了規則。 | Terraform 不做任何事，因此規則在該工作區中保持啟用。一般的 `terraform plan` 會回報沒有變更。`terraform plan -refresh-only` 會在規則的 `workspace_ids` 屬性中顯示新增的工作區。下一次 `terraform apply` 會將新清單儲存到 state，因此之後的規劃都不會再顯示此變更。 |

[Compliance API](https://platform.claude.com/docs/zh-TW/manage-claude/compliance-api) 會記錄每一項這類變更以及進行變更的人。

### 在其他地方發布的技能版本

如果有人在 Terraform 外部發布了技能的版本，下一次規劃會顯示「Skill changed outside Terraform」警告。規劃無法顯示技能檔案中變更了什麼。Terraform 會提議將您宣告的檔案發布為新版本，下一次 apply 就會執行此動作。請參閱[技能](https://platform.claude.com/docs/zh-TW/managed-agents/skills)。

### 代理程式編輯的記憶文件

由於代理程式會在工作階段中編輯文件，同時管理文件內容的設定可能會覆寫它們的編輯。對於由代理程式擁有的文件，請將 `lifecycle { ignore_changes = [content] }` 加入其 `anthropic_beta_memory` 資源。請參閱[使用代理記憶](https://platform.claude.com/docs/zh-TW/managed-agents/memory)。

### 已刪除或已封存的物件

如果有人在 Terraform 外部刪除或封存了某個物件，下一次規劃會警告該物件已不存在，並提議重新建立它。對於服務帳戶、工作區服務帳戶和聯合資源，缺少 `org:admin` 的聯合 profile 或登入則會收到錯誤。請參閱[各資源所需的憑證](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/behavior#credentials-for-each-resource)。

## State 與規劃輸出

Terraform 會以純文字將您設定的所有內容儲存在其 state 中，而規劃輸出也會顯示相同的值，包括在 pull request 留言和 CI 日誌中。將值標記為敏感會使其不顯示在規劃輸出中，但 Terraform 仍會將其儲存在 state 中。

對於組織資源，state 保存了：

* 您的工作區和服務帳戶的配置
* 您的聯合簽發者和規則
* 您的加密金鑰識別碼
* 您的 OpenTelemetry 目的地的端點 URL 和標頭名稱
* 成員的姓名、電子郵件和角色（如果您使用 `anthropic_organization_user` 或 `anthropic_organization_users` 資料來源）

它不保存任何機密，但會顯示哪些人和哪些服務帳戶可以在您的組織中執行操作。

對於 Managed Agents 資源，state 保存了代理程式的系統提示、自訂工具結構描述、記憶內容，以及以 `content` 撰寫的技能檔案。對於以 `source` 提供的技能檔案，state 只儲存其雜湊值。保存庫憑證機密和部署的 GitHub 儲存庫權杖是例外：它們是 write-only（唯寫）引數。

### 唯寫引數

`anthropic_beta_vault_credential` 的機密引數（例如 `token_wo` 和 `secret_value_wo`）是唯寫的。Terraform 會將唯寫值傳送給 API，但永遠不會將其儲存在 state 或規劃中。請以 `ephemeral = true` 宣告提供這些引數的變數，如[保護 state 與 plan 的安全](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/operations#keep-state-and-plans-safe)所述。

Terraform 無法偵測唯寫值何時變更，而 API 永遠不會傳回機密。

每個唯寫引數都有一個對應的 `_wo_version` 引數，例如 `token_wo_version`。若要傳送新值（例如在您輪替機密之後），請變更其 `_wo_version`。

### 保存庫憑證

API 僅依據 URL 將保存庫憑證與代理程式的 MCP 伺服器配對，因此憑證的 `mcp_server_url` 必須與代理程式的 `mcp_servers` 項目使用相同的 URL。在服務支援 OAuth 的情況下，建議使用具有重新整理權杖（refresh token）的 `mcp_oauth` 憑證，而非長期有效的靜態權杖。

## 錯誤訊息

當 API 傳回錯誤時，provider 會回報其訊息、類型、端點和請求 ID。若要回報問題，請[在 provider 的 GitHub 儲存庫中建立 issue](https://github.com/anthropics/terraform-provider-anthropic/issues)，並附上請求 ID。

## 語意化版本

provider 大致遵循 [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html)（語意化版本）慣例。某些不向後相容的變更可能會在次要版本中發布。由於 provider 處於 beta 階段，資源類型及其引數也可能以需要您更新設定的方式變更。請[提交您的 lock 檔案](https://platform.claude.com/docs/zh-TW/cli-sdks-libraries/sdks/terraform/operations#pin-the-providers-release)，以便由您決定何時採用新版本。
