• 訊息
  • 託管代理
  • 管理
Search...
⌘K
組織
Admin API工作區
驗證
概覽工作負載身分聯合WIF 參考
監控
用量與成本 API速率限制 APIClaude Code 分析 API
資料與合規
資料駐留API 與資料保留
概覽AWS KMSGoogle Cloud KMSAzure Key Vault
合規 API
概覽取得存取權活動動態對話、檔案與專案組織、使用者、角色與群組設計您的整合錯誤常見問題
Log in
Google Cloud KMS
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Amazon Bedrock
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
管理/加密金鑰

為 CMEK 設定 Google Cloud KMS

使用 Google Cloud KMS 為您的組織提供加密金鑰。
Configure with the /claude-api skill in Claude Code
claude "/claude-api help me configure a customer-managed encryption key with Google Cloud KMS"

本指南將逐步說明如何設定 Google Cloud KMS 金鑰,作為您 Anthropic 組織的 customer-managed encryption key(客戶管理的加密金鑰,CMEK)。

啟用 CMEK 是永久性的。如果您的 KMS 金鑰被刪除或停用,Anthropic 將無法復原使用該金鑰加密的資料。開始之前,請先檢閱警告與限制。

先決條件

  • 已啟用計費功能的 Google Cloud 專案。
  • 已啟用 Cloud KMS API(cloudkms.googleapis.com)。
  • 具備建立 KMS 金鑰環和金鑰,以及在其上設定 IAM 政策的權限(roles/cloudkms.admin 或同等權限)。
  • 您組織的 Anthropic Admin API 金鑰。
  • 已安裝並完成驗證的 gcloud CLI。
  • 已為專案啟用 Cloud KMS 資料存取稽核記錄(IAM 與管理 > 稽核記錄 > Cloud Key Management Service,並啟用 DATA_READ 和 DATA_WRITE)。這些預設為關閉;若未啟用,Anthropic 的加密和解密操作將不會在 Cloud Logging 中產生任何記錄。

Anthropic 服務帳戶電子郵件

為了讓 Anthropic 使用您的加密金鑰,您必須授予 Anthropic 的服務帳戶一個可用於加密資料的金鑰。Anthropic CMEK 的服務帳戶電子郵件為:

anthropic-cmek-client-us@gcp-anthropic-cmek-clients.iam.gserviceaccount.com

請僅使用此公開發布的服務帳戶電子郵件。切勿信任透過電子郵件、聊天或任何導入管道提供的識別碼。

**網域限制共用:**如果您的專案隸屬於強制執行 constraints/iam.allowedPolicyMemberDomains 的 Google Cloud 組織,下方的 IAM 繫結將會被拒絕,因為 Anthropic 服務帳戶不屬於您的組織。您需要針對該限制設定專案層級的例外,或將 Anthropic 的 Cloud Identity 客戶 ID(格式為 C0xxxxxxxx)新增至允許清單。如有需要,請聯絡 Anthropic 取得客戶 ID。

加密金鑰設定

  1. 1

    建立或選擇金鑰環

    如果您已有可重複使用的金鑰環,請略過此步驟。金鑰環具有區域性。請選擇與您正在設定的 Anthropic 地理位置相符的單一區域美國位置,例如 us-east5。不支援 us 和 global 等多區域位置。

    gcloud kms keyrings create <your-keyring-name> \
      --project=<your-project-id> \
      --location=<region>
  2. 2

    建立加密金鑰

    建立一個用途為 ENCRYPT_DECRYPT 的對稱金鑰。強烈建議使用 HSM 保護:Cloud KMS HSM 金鑰已通過 FIPS 140-2 Level 3 驗證,且與軟體金鑰相比的成本差異很小。

    gcloud kms keys create <your-key-name> \
      --project=<your-project-id> \
      --location=<region> \
      --keyring=<your-keyring-name> \
      --purpose=encryption \
      --protection-level=hsm

    若要改用軟體保護,請省略 --protection-level=hsm。本指南中的其他內容均不變。

    您也可以從 Google Cloud Console 建立金鑰。開啟金鑰環,點選 Create key(建立金鑰),選取 Generated key(產生的金鑰),將用途和演算法設定為對稱加密和解密,並在保護層級下選擇 HSM。

    Google Cloud KMS 建立金鑰頁面,顯示 HSM 保護層級和對稱加密/解密用途。
    建立受 HSM 保護的對稱加密/解密金鑰。
  3. 3

    授予 Anthropic 服務帳戶存取金鑰的權限

    需要兩個金鑰層級的 IAM 繫結。兩者的範圍都限定於單一加密金鑰,而非整個專案或整個金鑰環。

    加密和解密,Anthropic 用於加密和解密保護您工作區資料的資料金鑰(信封加密):

    gcloud kms keys add-iam-policy-binding <your-key-name> \
      --project=<your-project-id> \
      --location=<region> \
      --keyring=<your-keyring-name> \
      --member="serviceAccount:anthropic-cmek-client-us@gcp-anthropic-cmek-clients.iam.gserviceaccount.com" \
      --role=roles/cloudkms.cryptoKeyEncrypterDecrypter

    檢視者,用於 Anthropic 在啟動時執行的中繼資料讀取(),以驗證金鑰的用途和演算法:

  4. 4

    記下完整的金鑰資源名稱

    您在向 Anthropic 註冊金鑰時需要傳遞此名稱。格式為:

    projects/<your-project-id>/locations/<region>/keyRings/<your-keyring-name>/cryptoKeys/<your-key-name>

    使用以下指令取得:

    gcloud kms keys describe <your-key-name> \
      --project=<your-project-id> \
      --location=<region> \
      --keyring=<your-keyring-name> \
      --format="value(name)"

    從 Console 中,開啟金鑰的詳細資料頁面,然後點選 Copy resource name(複製資源名稱)。

    Google Cloud 金鑰環詳細資料,金鑰的動作選單中醒目顯示「複製資源名稱」動作。
    從動作選單複製金鑰的完整資源名稱。
  5. 5

    向 Anthropic 註冊金鑰

    使用上一步驟中的資源名稱,透過 Admin API 建立外部金鑰設定。

    curl -sS https://api.anthropic.com/v1/organizations/external_keys \
      -H "x-api-key: <anthropic-admin-api-key>" \
      -H "anthropic-version: 2023-06-01" \
      -H "content-type: application/json" \
      -d '{
        "display_name": "<friendly-name>",
        "geo": "us",
        "provider_config": {
          "type": "gcp",
          "key_name": "projects/<your-project-id>/locations/<region>/keyRings/<your-keyring-name>/cryptoKeys/<your-key-name>"
        }
      }'

    回應中包含外部金鑰 ID:

    {
      "type": "external_key",
      "id": "ekey_<id>",
      "display_name": "<friendly-name>"
    }
  6. 6

    驗證金鑰

    對您的金鑰觸發一次加密和解密的往返測試。

    curl -sS -X POST https://api.anthropic.com/v1/organizations/external_keys/ekey_<id>/validate \
      -H "x-api-key: <anthropic-admin-api-key>" \
      -H "anthropic-version: 2023-06-01" \
      -H "content-type: application/json" -d '{}'

    成功的回應如下所示:

    { "type": "external_key_validation", "status": "success", "error": null }
  7. 7

    將金鑰附加至工作區

    curl -sS -X POST https://api.anthropic.com/v1/organizations/workspaces/<workspace-id> \
      -H "x-api-key: <anthropic-admin-api-key>" \
      -H "anthropic-version: 2023-06-01" \
      -H "content-type: application/json" \
      -d '{
        "external_key_id": "ekey_<id>"
      }'

Terraform

對於基礎架構即程式碼(infrastructure-as-code)的部署,相同的步驟對應至 google 提供者的 google_kms_key_ring、google_kms_crypto_key 和 google_kms_crypto_key_iam_member 資源。

Was this page helpful?

  • 先決條件
  • Anthropic 服務帳戶電子郵件
  • 加密金鑰設定
  • Terraform
cryptoKeys.get
gcloud kms keys add-iam-policy-binding <your-key-name> \
  --project=<your-project-id> \
  --location=<region> \
  --keyring=<your-keyring-name> \
  --member="serviceAccount:anthropic-cmek-client-us@gcp-anthropic-cmek-clients.iam.gserviceaccount.com" \
  --role=roles/cloudkms.viewer

從 Console 中,選取金鑰,開啟 Permissions(權限)面板,點選 Grant access(授予存取權),並為服務帳戶新增 Cloud KMS CryptoKey Encrypter/Decrypter 和 Cloud KMS Viewer 兩個角色。請確認您位於金鑰的權限頁面,而非金鑰環或專案的權限頁面,以確保授權範圍僅限於此金鑰。

Google Cloud 授予存取權對話方塊,正在為 Anthropic 服務帳戶新增 Cloud KMS CryptoKey Encrypter/Decrypter 和 Cloud KMS Viewer 角色。
授予 Anthropic 服務帳戶兩個角色,範圍限定於該金鑰。

如果驗證失敗,常見原因包括:

  • **VPC Service Controls:**如果您的專案中有服務範圍保護 Cloud KMS,請將 Anthropic 新增至該範圍的存取層級(或排除金鑰所在的專案),以便 Anthropic 能夠存取該金鑰。
  • 網域限制共用:constraints/iam.allowedPolicyMemberDomains 組織政策可能會移除 Anthropic 服務帳戶的繫結(請參閱上方的注意事項)。請使用 gcloud kms keys get-iam-policy <your-key-name> --project=<your-project-id> --location=<region> --keyring=<your-keyring-name> 確認繫結是否存在。
  • **已停用或已銷毀的金鑰版本:**確認金鑰的主要版本已啟用,且未被停用、排定銷毀或已銷毀。