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 功能可用性。