Skip to content

Commit 512f3b0

Browse files
committed
docs(claude-code): add Bedrock and Vertex examples, tighten README
Review feedback on the README: - AI Gateway description drops 'MCP policy enforcement' because it is not shipping yet; keeps the auditing and token usage claims that are live. - Add a first-class AWS Bedrock example using the env map with either a bearer token (AWS_BEARER_TOKEN_BEDROCK) or access key pair. Mirrors what v4 had but composed via env, not dedicated variables. - Add a first-class Google Vertex AI example. Requires a pre_install_script to drop the SA JSON and point GOOGLE_APPLICATION_CREDENTIALS at it; keep gcloud installation as the template author's choice. - Clarify 'Using a pre-installed binary': claude_binary_path is only consulted when install_claude_code = false; the official installer drops the binary at $HOME/.local/bin and does not accept a destination override. - Drop the 'Scripts produced' section. It restated an implementation detail that duplicates the Outputs section and the pre/post-install extension docs. - Simplify the Unattended mode section: keep the example and runtime-flag alternative, drop the keys-verified table and the human-user note. Point at upstream Claude Code docs for canonical key definitions. - Drop the Outputs table; keep the composition example. The type and description already live in the module's output block.
1 parent 2669f30 commit 512f3b0

1 file changed

Lines changed: 76 additions & 32 deletions

File tree

registry/coder/modules/claude-code/README.md

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module "claude-code" {
7272

7373
### Coder AI Gateway
7474

75-
Route Claude Code through [Coder AI Gateway](https://coder.com/docs/ai-coder/ai-gateway) for centralized auditing, token usage tracking, and MCP policy enforcement. Requires Coder Premium with the AI Governance add-on and `CODER_AIBRIDGE_ENABLED=true` on the server.
75+
Route Claude Code through [Coder AI Gateway](https://coder.com/docs/ai-coder/ai-gateway) for centralized auditing and token usage tracking. Requires Coder Premium with the AI Governance add-on and `CODER_AIBRIDGE_ENABLED=true` on the server.
7676

7777
Point `ANTHROPIC_BASE_URL` at your deployment's `/api/v2/aibridge/anthropic` endpoint and authenticate with the workspace owner's session token via `ANTHROPIC_AUTH_TOKEN`. Claude Code reads both variables natively; no API key is required.
7878

@@ -96,7 +96,75 @@ module "claude-code" {
9696
> [!NOTE]
9797
> AI Gateway was previously named AI Bridge. The server-side endpoints and environment variables still use the `aibridge` prefix; only the product name changed.
9898
99-
### Other custom endpoints (Bedrock, Vertex, LiteLLM, a private proxy)
99+
### AWS Bedrock
100+
101+
Route Claude Code through [AWS Bedrock](https://docs.claude.com/en/docs/claude-code/amazon-bedrock) to access Claude models via your AWS account. Requires an AWS account with Bedrock access, the target Claude models enabled in the Bedrock console, and IAM permissions that allow `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream`.
102+
103+
Pick either an access key pair or a Bedrock bearer token for auth; do not set both.
104+
105+
```tf
106+
variable "aws_bearer_token_bedrock" {
107+
type = string
108+
sensitive = true
109+
}
110+
111+
module "claude-code" {
112+
source = "registry.coder.com/coder/claude-code/coder"
113+
version = "5.0.0"
114+
agent_id = coder_agent.main.id
115+
116+
env = {
117+
CLAUDE_CODE_USE_BEDROCK = "1"
118+
AWS_REGION = "us-east-1"
119+
ANTHROPIC_MODEL = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
120+
AWS_BEARER_TOKEN_BEDROCK = var.aws_bearer_token_bedrock
121+
# Or, with access keys instead of the bearer token:
122+
# AWS_ACCESS_KEY_ID = var.aws_access_key_id
123+
# AWS_SECRET_ACCESS_KEY = var.aws_secret_access_key
124+
}
125+
}
126+
```
127+
128+
### Google Vertex AI
129+
130+
Route Claude Code through [Google Vertex AI](https://docs.claude.com/en/docs/claude-code/google-vertex-ai). Requires a GCP project with Vertex AI enabled, Claude models enabled via Model Garden, and a service account with the Vertex AI User role.
131+
132+
The service account JSON has to land on the workspace filesystem where Claude can read it, so authenticating gcloud happens in `pre_install_script`:
133+
134+
```tf
135+
variable "vertex_sa_json" {
136+
type = string
137+
description = "Full JSON body of a GCP service account key with Vertex AI User."
138+
sensitive = true
139+
}
140+
141+
module "claude-code" {
142+
source = "registry.coder.com/coder/claude-code/coder"
143+
version = "5.0.0"
144+
agent_id = coder_agent.main.id
145+
146+
env = {
147+
CLAUDE_CODE_USE_VERTEX = "1"
148+
ANTHROPIC_VERTEX_PROJECT_ID = "your-gcp-project-id"
149+
CLOUD_ML_REGION = "global"
150+
ANTHROPIC_MODEL = "claude-sonnet-4@20250514"
151+
GOOGLE_APPLICATION_CREDENTIALS = "$HOME/.config/gcloud/sa.json"
152+
VERTEX_SA_JSON = var.vertex_sa_json
153+
}
154+
155+
pre_install_script = <<-EOT
156+
#!/bin/bash
157+
set -euo pipefail
158+
mkdir -p "$HOME/.config/gcloud"
159+
printf '%s' "$VERTEX_SA_JSON" > "$HOME/.config/gcloud/sa.json"
160+
chmod 600 "$HOME/.config/gcloud/sa.json"
161+
EOT
162+
}
163+
```
164+
165+
Install `gcloud` itself in the workspace image, in `pre_install_script`, or via a separate Coder module; this example leaves that choice to the template author.
166+
167+
### Other custom endpoints (LiteLLM, a private proxy)
100168

101169
Same pattern with your own endpoint and token. The [Claude Code env-vars reference](https://docs.claude.com/en/docs/claude-code/env-vars) lists every supported name.
102170

@@ -173,7 +241,9 @@ module "claude-code" {
173241

174242
## Using a pre-installed binary
175243

176-
Set `install_claude_code = false` and point `claude_binary_path` at the directory containing the binary.
244+
`claude_binary_path` is only consulted when `install_claude_code = false`. The official installer always drops the binary at `$HOME/.local/bin/claude` and does not accept a custom destination, so combining `install_claude_code = true` with a custom `claude_binary_path` is rejected at plan time.
245+
246+
To use a binary you bake into the image (or install via a separate module), set `install_claude_code = false` and point `claude_binary_path` at the directory containing it:
177247

178248
```tf
179249
module "claude-code" {
@@ -185,18 +255,6 @@ module "claude-code" {
185255
}
186256
```
187257

188-
## Scripts produced
189-
190-
By default this module creates exactly one `coder_script` on the agent: `Claude Code: Install Script`. Additional scripts appear only when you opt in:
191-
192-
| Script | Created when |
193-
| ---------------------------------- | ----------------------------- |
194-
| `Claude Code: Install Script` | Always. |
195-
| `Claude Code: Pre-Install Script` | `pre_install_script` is set. |
196-
| `Claude Code: Post-Install Script` | `post_install_script` is set. |
197-
198-
No start script is produced in any configuration. Compose with a dedicated module (e.g. a future Tasks module) if you need one.
199-
200258
## Extending with pre/post install scripts
201259

202260
Use `pre_install_script` and `post_install_script` for custom setup (e.g. writing `~/.claude/settings.json` permission rules, installing cloud SDKs, pulling secrets).
@@ -272,31 +330,17 @@ module "claude-code" {
272330
}
273331
```
274332

275-
Keys verified live against Claude Code CLI v2.1.117:
276-
277-
| File | Key | Effect |
278-
| ------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------- |
279-
| `~/.claude/settings.json` | `permissions.defaultMode` | `"bypassPermissions"`, `"acceptEdits"`, `"plan"`, `"auto"`, `"default"`, `"dontAsk"`. |
280-
| `~/.claude/settings.json` | `permissions.allow` / `deny` | Per-tool allowlist / denylist (e.g. `"Bash(git *)"`, `"Read(./secrets/**)"`). |
281-
| `~/.claude/settings.json` | `skipDangerousModePermissionPrompt` | Silences the one-time "enable bypassPermissions mode" consent banner. |
282-
| `~/.claude.json` | `hasCompletedOnboarding` | Skips the first-run theme picker and welcome screens. |
333+
Key reference: [`permissions`](https://docs.claude.com/en/docs/claude-code/settings) in `~/.claude/settings.json`, [`hasCompletedOnboarding`](https://docs.claude.com/en/docs/claude-code/settings) in `~/.claude.json`.
283334

284-
> [!NOTE]
285-
> Pre-writing these files makes sense for automation and agents. Human users who expect the usual onboarding and per-project trust dialog should not use this pattern.
286-
287-
For one-off non-interactive runs, prefer the runtime flag instead of pre-writing config:
335+
For one-off non-interactive runs, prefer a runtime flag over pre-writing config:
288336

289337
```bash
290338
claude -p "$PROMPT" --dangerously-skip-permissions --permission-mode bypassPermissions
291339
```
292340

293341
## Outputs
294342

295-
| Output | Type | Description |
296-
| --------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
297-
| `scripts` | `list(string)` | `coder exp sync` names for every `coder_script` this module actually creates, in the run order `coder-utils` enforces (pre-install, install, post-install). Absent scripts are not in the list. |
298-
299-
Use `scripts` to gate a downstream module behind Claude Code's install:
343+
`scripts` is a list of `coder exp sync` names for every `coder_script` this module creates, in the order `coder-utils` runs them. Use it to gate a downstream `coder_script` behind Claude Code's install:
300344

301345
```tf
302346
module "claude-code" {

0 commit comments

Comments
 (0)