Bedrock GovCloud 設定
設定 AWS GovCloud 中使用 Amazon Bedrock 的本機 Codex 工作流程
本指南介紹如何設定 Codex,通過 GovCloud 中的 Amazon Bedrock 執行推理。內容涵蓋 AWS 存取權限、受管裝置設定和網路控制。
共同責任
請查閱 AWS 責任共擔模型及所選服務的文件,瞭解 AWS 提供哪些控制措施。你所在機構負責核准使用這些服務。
在受支援的部署中,Codex 使用 AWS 身份驗證向設定的 Bedrock 端點傳送推理請求。你的組織負責保障執行 Codex 的裝置安全,包括憑證、程式碼儲存庫、本機記錄以及已啟用的第三方服務。使用 GovCloud 進行推理並不意味著整個工作流程滿足你所在機構的要求。
開始之前
請使用 26.1002.51308 或更高版本 的桌面應用,版本號可在 關於 中檢視。
| 準備事項 | 所需條件 |
|---|---|
| AWS 存取權限 | 一個 AWS GovCloud 帳戶,具有存取將要使用的 Bedrock 模型的權限。 |
| 設定 | 經過稽核的 requirements.toml、獲批的網路目標地址和回滾說明。 |
| 裝置管理 | 系統設定或 MDM 存取權限,以及應用、裝置和智能體命令的網路策略。 |
1. 部署裝置要求
在啟動應用之前,通過系統設定或 MDM 部署 requirements.toml。有關檔案位置和 MDM 分發方式,請參閱託管設定。保護託管策略,並在第 3 步中,在執行 Codex 的電腦上驗證其設定。
建議的 requirements.toml
下面的預設 requirements.toml 有意採用嚴格限制。如果管理員接受額外功能帶來的風險,可以啟用這些功能。請參閱功能文件和網路控制文件。
requirements.toml
# Disable ChatGPT sign-in.
allowed_login_methods = ["api"]
# https://learn.chatgpt.com/docs/agent-approvals-security#common-sandbox-and-approval-combinations
allowed_sandbox_modes = ["read-only", "workspace-write"]
# Approval prompts are reviewed by the user.
allowed_approvals_reviewers = ["user"]
allowed_approval_policies = [
{ granular = { sandbox_approval = false, rules = true, mcp_elicitations = false, request_permissions = false, skill_approval = true } },
]
# Allow cached search only if your AWS GovCloud Region supports web search.
allowed_web_search_modes = ["disabled", "cached"]
# Block agent browser use and native-app control.
allow_browser_and_computer_use = false
# Appshots: https://learn.chatgpt.com/docs/appshots
allow_appshots = false
# Remote control: https://learn.chatgpt.com/docs/remote-connections#pick-up-work-from-another-device
allow_remote_control = false
# Managed hooks: https://learn.chatgpt.com/docs/enterprise/managed-configuration#enforce-managed-hooks-from-requirements
allow_managed_hooks_only = true
check_for_update_on_startup = false
# MCP servers, apps, and plugins are disabled by default.
# Admins can enable supported integrations after accepting the risks
# for their use case and configuring access and network controls.
# https://learn.chatgpt.com/docs/enterprise/managed-configuration
mcp_servers = {}
[features]
apps = false
enable_mcp_apps = false
plugins = false
# Enable the network proxy for sandboxed commands.
# https://learn.chatgpt.com/docs/agent-approvals-security#network-isolation
network_proxy = true
in_app_dictation = false
realtime_conversation = false
# Browser controls: https://learn.chatgpt.com/docs/enterprise/managed-configuration#disable-codex-feature-surfaces
# Note that both browser use and computer use are up to your organization's risk appetite.
# An agent using your browser or computer may navigate to any websites or applications that the
# computer has access to. OpenAI does not currently provide additional protections restricting
# the network paths that browser use and computer use may exercise.
in_app_browser = false
browser_use = false
browser_use_external = false
browser_use_full_cdp_access = false
# Computer Use: https://learn.chatgpt.com/docs/computer-use
# Enable after accepting the risks and configuring app and network access.
computer_use = false
# Set to true to let users update through the app.
# App-store, package-manager, and MDM updates are controlled separately.
# https://learn.chatgpt.com/docs/enterprise/manage-app-updates#turn-off-in-app-updates
in_app_updates = false
image_generation = false
# Memories: https://learn.chatgpt.com/docs/customization/memories
memories = false
# Computer History: https://learn.chatgpt.com/docs/customization/computer-history
chronicle = false
external_agent_memory_import = false
# We recommend that users review approval requests themselves.
# Admins can enable automatic review after accepting the risks for their use case.
# https://learn.chatgpt.com/docs/agent-approvals-security#automatic-approval-reviews
guardian_approval = false
guardianv2 = false
# Disable background skill-search experiments.
skill_search = false
# Hooks: https://learn.chatgpt.com/docs/hooks
hooks = false
# If you enable web search, use cached search through Bedrock Mantle
# where supported by your AWS GovCloud Region.
standalone_web_search = false
# Disable feedback submissions to OpenAI.
[feedback]
enabled = false
# Network controls for agent commands:
# https://learn.chatgpt.com/docs/enterprise/managed-configuration#configure-network-access-requirements
[experimental_network]
enabled = true
managed_allowed_domains_only = true
# No domains allowed by default. Add destinations approved for your use case.
domains = {}
# Add approved Unix socket paths here.
unix_sockets = {}
# Set to true when using an organization-approved upstream proxy.
allow_upstream_proxy = false
# Keep the command proxy bound to localhost.
dangerously_allow_non_loopback_proxy = false
dangerously_allow_all_unix_sockets = false
# Local/private networking: https://learn.chatgpt.com/docs/agent-approvals-security#local-and-private-destinations
allow_local_binding = false
# App network controls: https://learn.chatgpt.com/docs/enterprise/managed-configuration#control-desktop-app-network-destinations
[application.network]
enabled = true
# Example: Bedrock Mantle in us-gov-west-1.
# Replace this hostname with the Bedrock endpoint configured in config.toml.
[application.network.domains]
"bedrock-mantle.us-gov-west-1.api.aws" = "allow"
# OpenAI and ChatGPT endpoints.
# We recommend denying these endpoints to avoid any risk that user data is sent to commercial OpenAI infrastructure.
"api.openai.com" = "deny"
"chat.openai.com" = "deny"
"chatgpt.com" = "deny"
"ab.chatgpt.com" = "deny"
"platform.openai.com" = "deny"
"auth.openai.com" = "deny"
"gov.api.openai.com" = "deny"
"gov.chatgpt.com" = "deny"
"sdfedpreastus2.oaiusercontent.com" = "deny"
"o33249.ingest.us.sentry.io" = "deny"
"persistent.oaistatic.com" = "deny"
"oaisidekickupdates.blob.core.windows.net" = "deny"
# Windows only: https://learn.chatgpt.com/docs/config-file/config-reference#requirementstoml
[windows]
allowed_sandbox_implementations = ["elevated"]2. 設定供應商路由和網路控制
在 config.toml 或託管預設設定中設定供應商、模型、區域和端點。使用者可以在 requirements.toml 設定的限制範圍內更改這些預設設定。
建議的 config.toml
以下範例使用 us-gov-west-1 區域中的 Mantle。請將模型 ID 和 AWS 設定檔替換為你的部署所用的值。如果使用其他受支援的區域或端點,請同時更新 URL、區域和網路策略。
此範例關閉了可選的診斷和資料共享功能。請勿將 AWS 憑證存放在 TOML 檔案中。請將 AWS 設定檔、憑證和憑證輔助指令碼存放在 Codex 無法修改的資料夾中。
config.toml
# Replace with your approved Bedrock model ID.
model = "openai.gpt-5.6-terra"
model_provider = "amazon-bedrock"
approval_policy = { granular = { sandbox_approval = false, rules = true, mcp_elicitations = false, request_permissions = false, skill_approval = true } }
sandbox_mode = "workspace-write"
# Set to "cached" only when supported by your model and GovCloud Region
# and approved for your deployment.
# https://docs.aws.amazon.com/bedrock/latest/userguide/web-search.html
web_search = "disabled"
# Example: Bedrock Mantle in us-gov-west-1.
[model_providers.amazon-bedrock]
base_url = "https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1"
wire_api = "responses"
requires_openai_auth = false
[model_providers.amazon-bedrock.aws]
region = "us-gov-west-1"
# Replace with your AWS profile name.
profile = "codex-govcloud"
[sandbox_workspace_write]
# Command destinations are controlled by requirements.toml.
network_access = true
# Disable sending Codex usage analytics to OpenAI.
[analytics]
enabled = false
# OpenTelemetry exports are off by default.
# Admins can configure an approved collector for logs, traces, and metrics.
# https://learn.chatgpt.com/docs/config-file/config-advanced#observability-and-telemetry
[otel]
exporter = "none"
trace_exporter = "none"
metrics_exporter = "none"
log_user_prompt = false此範例使用 AWS 憑證存取 Bedrock Mantle。如果使用 Bedrock Runtime 或閘道器,請按照供應商設定說明操作。
應用網路控制
將獲批的應用目標地址(包括 Bedrock)新增到 application.network.domains。將獲批的命令目標地址新增到 experimental_network.domains。
Codex 的網路設定不能替代裝置防火牆。
3. 驗證部署
- 確認策略已生效,且 Codex 正在使用預期的 AWS 憑證和 Bedrock 設定。
- 使用範例資料執行獲批的工作流程。
- 確認使用者設定無法覆蓋託管限制。
- 測試憑證無效或過期以及路由失敗的情況。確認內容不會傳送到未經核准的目標地址。
常見問題排查
| 問題 | 檢查內容 |
|---|---|
| 不支援的端點 | 向 OpenAI 確認已安裝的桌面應用和 app-server 版本是否支援該端點和模型。 |
| AWS 帳戶或角色錯誤 | 檢查當前生效的憑證和所選的 AWS 設定檔。Bedrock API key 的優先順序可能高於設定檔。 |
| 限制未生效 | 確認執行 Codex 的電腦已載入預期的 requirements.toml。 |
| 功能仍不可用 | 檢視功能文件,瞭解所需設定和 Bedrock 支援情況,然後檢查網路控制。 |
功能設定
使用者無法覆蓋由 requirements.toml 強制實施的功能設定。
下表彙總了上述設定。開啟 表示在受支援的情況下允許使用;其他權限和網路控制仍然適用。
有關供應商支援情況,請參閱 Bedrock 功能可用性。
| 功能 | 預設狀態 | 備註 |
|---|---|---|
| 本機編碼、檔案、Git 和子智能體 | 開啟 | — |
| 本機定時任務 | 開啟 | — |
| 瀏覽器 | 關閉 | 包括內建瀏覽器、已連線的瀏覽器、智能體瀏覽器控制和開發者模式。 |
| 電腦使用和 Appshots | 關閉 | — |
| 記憶和電腦歷史記錄 | 關閉 | — |
| 影像生成 | 關閉 | 不會阻止影像輸入或讀取現有影像檔案。 |
| 網路搜尋 | 關閉 | 快取搜尋需要模型和 GovCloud 區域支援。命令網路規則不會限制託管搜尋。 |
| 應用和外掛 | 關閉 | — |
| 已設定的 MCP 伺服器 | 關閉 | 管理員接受其使用場景的相關風險並設定存取和網路控制後,可以啟用獲批的伺服器。 |
| 互動式 MCP 應用 | 關閉 | — |
| 聽寫 | 關閉 | — |
| 自動審批稽核 | 關閉 | — |
| 遠端控制 | 關閉 | SSH 連線單獨管理。 |
| 應用更新 | 關閉 | — |
啟用智能體瀏覽器使用或電腦使用功能還需要設定 allow_browser_and_computer_use = true。
設定 Codex CLI,使其通過 GovCloud 中的 Amazon Bedrock 執行推理。責任共擔指南也適用於 CLI 部署。
開始之前
安裝 Codex CLI,並檢查已安裝的版本:
codex --version使用 Codex CLI 0.162.0 或更高版本。
你需要一個 AWS GovCloud 帳戶,具有存取將要使用的 Bedrock 模型的權限,還需要管理員權限,以便在執行 Codex 的電腦上部署 requirements.toml。對於 WSL 或 SSH,請在 CLI 執行的環境內應用設定。
1. 部署裝置要求
在啟動 CLI 之前,通過系統設定或 MDM 部署 requirements.toml。有關檔案位置和 MDM 分發方式,請參閱託管設定。保護託管策略,並按照第 3 步在執行 Codex 的機器上驗證其設定。
推薦的 requirements.toml
下面的預設 requirements.toml 有意採用嚴格限制。管理員如果接受額外功能帶來的風險,可以啟用這些功能。請參閱功能文件和網路控制文件。
requirements.toml
# Disable ChatGPT sign-in.
allowed_login_methods = ["api"]
# https://learn.chatgpt.com/docs/agent-approvals-security#common-sandbox-and-approval-combinations
allowed_sandbox_modes = ["read-only", "workspace-write"]
# Approval prompts are reviewed by the user.
allowed_approvals_reviewers = ["user"]
allowed_approval_policies = [
{ granular = { sandbox_approval = false, rules = true, mcp_elicitations = false, request_permissions = false, skill_approval = true } },
]
# Allow cached search only if your AWS GovCloud Region supports web search.
allowed_web_search_modes = ["disabled", "cached"]
# Remote control: https://learn.chatgpt.com/docs/cli/reference#codex-remote-control
allow_remote_control = false
# Managed hooks: https://learn.chatgpt.com/docs/enterprise/managed-configuration#enforce-managed-hooks-from-requirements
allow_managed_hooks_only = true
check_for_update_on_startup = false
# MCP servers, apps, and plugins are disabled by default.
# Admins can enable supported integrations after accepting the risks
# for their use case and configuring access and network controls.
# https://learn.chatgpt.com/docs/enterprise/managed-configuration
mcp_servers = {}
[features]
apps = false
plugins = false
# Enable the network proxy for sandboxed commands.
# https://learn.chatgpt.com/docs/agent-approvals-security#network-isolation
network_proxy = true
realtime_conversation = false
image_generation = false
# Memories: https://learn.chatgpt.com/docs/customization/memories
memories = false
external_agent_memory_import = false
# We recommend that users review approval requests themselves.
# Admins can enable automatic review after accepting the risks for their use case.
# https://learn.chatgpt.com/docs/agent-approvals-security#automatic-approval-reviews
guardian_approval = false
guardianv2 = false
# Disable background skill-search experiments.
skill_search = false
# Hooks: https://learn.chatgpt.com/docs/hooks
hooks = false
# If you enable web search, use cached search through Bedrock Mantle
# where supported by your AWS GovCloud Region.
standalone_web_search = false
# Disable feedback submissions to OpenAI.
[feedback]
enabled = false
# Network controls for agent commands:
# https://learn.chatgpt.com/docs/enterprise/managed-configuration#configure-network-access-requirements
[experimental_network]
enabled = true
managed_allowed_domains_only = true
# No domains allowed by default. Add destinations approved for your use case.
domains = {}
# Add approved Unix socket paths here.
unix_sockets = {}
# Set to true when using an organization-approved upstream proxy.
allow_upstream_proxy = false
# Keep the command proxy bound to localhost.
dangerously_allow_non_loopback_proxy = false
dangerously_allow_all_unix_sockets = false
# Local/private networking: https://learn.chatgpt.com/docs/agent-approvals-security#local-and-private-destinations
allow_local_binding = false
# Application network controls: https://learn.chatgpt.com/docs/config-file/config-reference#requirementstoml
[application.network]
enabled = true
# Example: Bedrock Mantle in us-gov-west-1.
# Replace this hostname with the Bedrock endpoint configured in config.toml.
[application.network.domains]
"bedrock-mantle.us-gov-west-1.api.aws" = "allow"
# OpenAI and ChatGPT endpoints.
# We recommend denying these endpoints to avoid any risk that user data is sent to commercial OpenAI infrastructure.
"api.openai.com" = "deny"
"chat.openai.com" = "deny"
"chatgpt.com" = "deny"
"ab.chatgpt.com" = "deny"
"platform.openai.com" = "deny"
"auth.openai.com" = "deny"
"gov.api.openai.com" = "deny"
"gov.chatgpt.com" = "deny"
"sdfedpreastus2.oaiusercontent.com" = "deny"
"o33249.ingest.us.sentry.io" = "deny"
"persistent.oaistatic.com" = "deny"
"oaisidekickupdates.blob.core.windows.net" = "deny"
# Windows only: https://learn.chatgpt.com/docs/config-file/config-reference#requirementstoml
[windows]
allowed_sandbox_implementations = ["elevated"]2. 設定供應商路由和網路控制
在 Linux 或 macOS 上,將 config.toml 放在 ~/.codex/config.toml;在 Windows 上,則放在 %USERPROFILE%\.codex\config.toml。如果設定了 CODEX_HOME,請改用該目錄中的 config.toml。使用者可以在 requirements.toml 設定的限制範圍內更改這些預設設定。
推薦的 config.toml
此範例使用 us-gov-west-1 區域中的 Mantle。請將模型 ID 和 AWS 設定檔替換為實際部署使用的值。如果使用其他受支援的區域或端點,請同時更新 URL、區域和網路策略。
將 AWS 憑證儲存在 TOML 檔案之外。將 AWS 設定檔、憑證和憑證輔助指令碼儲存在 Codex 無法修改的資料夾中。CLI 使用 AWS 憑證存取此供應商,無需登入 ChatGPT,也無需 OpenAI API key。請參閱 Bedrock 身份驗證選項。
config.toml
# Replace with your approved Bedrock model ID.
model = "openai.gpt-5.6-terra"
model_provider = "amazon-bedrock"
approval_policy = { granular = { sandbox_approval = false, rules = true, mcp_elicitations = false, request_permissions = false, skill_approval = true } }
sandbox_mode = "workspace-write"
# Set to "cached" only when supported by your model and GovCloud Region
# and approved for your deployment.
# https://docs.aws.amazon.com/bedrock/latest/userguide/web-search.html
web_search = "disabled"
# Example: Bedrock Mantle in us-gov-west-1.
[model_providers.amazon-bedrock]
base_url = "https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1"
wire_api = "responses"
requires_openai_auth = false
[model_providers.amazon-bedrock.aws]
region = "us-gov-west-1"
# Replace with your AWS profile name.
profile = "codex-govcloud"
[sandbox_workspace_write]
# Command destinations are controlled by requirements.toml.
network_access = true
# Disable sending Codex usage analytics to OpenAI.
[analytics]
enabled = false
# OpenTelemetry exports are off by default.
# Admins can configure an approved collector for logs, traces, and metrics.
# https://learn.chatgpt.com/docs/config-file/config-advanced#observability-and-telemetry
[otel]
exporter = "none"
trace_exporter = "none"
metrics_exporter = "none"
log_user_prompt = false應用網路控制
將包括 Bedrock 在內的已核准 CLI 目標新增到 application.network.domains。將已核准的命令存取目標新增到 experimental_network.domains。這兩項控制相互獨立:允許模型請求存取 Bedrock,並不意味著允許智能體命令存取它。
在 CLI 0.162.0 中,互動式會話和 codex exec 會將 application.network 應用於 Codex 的模型和服務請求。它不涵蓋單獨執行的 codex login 或守護程序更新下載。Codex 的網路設定不能替代裝置防火牆。請使用防火牆限制這些目標以及憑證輔助程式的流量。
3. 驗證部署
更改設定後,啟動一個新的 CLI 程序。在儲存庫目錄中執行:
codex- 開啟
/status,確認模型和供應商。檢查所設定的 AWS 設定檔是否使用預期的憑證。 - 使用範例資料執行已核准的工作流程。
- 確認使用者設定和 CLI 標誌無法覆蓋託管限制。
- 測試無效或過期的憑證以及路由故障。確認內容不會傳送到未經核准的目標。
還應在儲存庫目錄中檢查非互動式使用:
codex exec --sandbox read-only "Reply with exactly: bedrock-ok"codex exec 不會提示使用者審批;需要審批的操作會失敗。
預期回覆為 bedrock-ok。請在 CLI 輸出中確認供應商和模型;僅憑回覆無法確定所用路由。隨後執行一個讀取範例檔案的已核准工作流程,並針對 codex exec 重複執行策略檢查。
排查常見問題
| 問題 | 檢查內容 |
|---|---|
| 不支援的端點 | 向 OpenAI 確認已安裝的 CLI 版本是否支援該端點和模型。 |
| AWS 帳戶或角色錯誤 | 檢查 model_providers.amazon-bedrock.aws 中的設定檔及其當前生效的憑證。 |
| 限制未生效 | 確認 requirements.toml 已安裝在執行 CLI 的機器上,然後啟動一個新程序。 |
| 命令無法存取網路 | 檢查當前生效的沙箱、sandbox_workspace_write.network_access 和託管的命令域名允許列表。此範例預設不允許命令存取任何目標。 |
| 功能仍不可用 | 查閱功能文件,瞭解所需設定和 Bedrock 支援情況,然後檢查網路控制。 |
功能設定
使用者無法覆蓋 requirements.toml 強制執行的功能設定。
下表彙總了上述設定。開啟 表示在受支援的情況下允許使用;其他權限和網路控制仍然適用。
有關供應商支援情況,請參閱 Bedrock 功能可用性。