You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rebased onto post-#861 main.
- New use_bedrock and use_vertex bool inputs that set
CLAUDE_CODE_USE_BEDROCK=1 / CLAUDE_CODE_USE_VERTEX=1 via coder_env.
Mutually exclusive with each other and with enable_ai_gateway.
- New anthropic_base_url string input. The existing
coder_env.anthropic_base_url resource (previously AI Gateway only)
is widened to also fire when this is set; AI Gateway keeps
precedence for the value. Mutually exclusive with enable_ai_gateway.
- configure_standalone_mode now recognizes use_bedrock / use_vertex /
anthropic_base_url as valid auth paths: prints a clear backend
message and proceeds to write the onboarding-bypass keys instead of
printing the misleading 'No authentication configured' note and
returning early.
- README: Bedrock and Vertex sections rewritten around the new inputs,
leading with attached IAM role / Workload Identity over static
credentials. New custom-API-gateway section. Prerequisites and
mutual-exclusion caution updated.
- Tests: 7 new terraform-test runs (env assertions + 4 expect_failures
for mutual exclusion); 3 new bun tests.
Closescoder/coder#17402Closescoder/coder#21835
@@ -29,6 +29,9 @@ Provide exactly one authentication method:
29
29
-**Anthropic API key**: get one from the [Anthropic Console](https://console.anthropic.com/dashboard) and pass it as `anthropic_api_key`.
30
30
-**Claude.ai OAuth token** (Pro, Max, or Enterprise accounts): generate one by running `claude setup-token` locally and pass it as `claude_code_oauth_token`.
31
31
-**Coder AI Gateway** (Coder Premium, Coder >= 2.30.0): set `enable_ai_gateway = true`. The module authenticates against the gateway using the workspace owner's session token. Do not combine with `anthropic_api_key` or `claude_code_oauth_token`.
32
+
-**Amazon Bedrock**: set `use_bedrock = true`. Authentication uses the workspace's AWS credential chain. See [Usage with AWS Bedrock](#usage-with-aws-bedrock).
33
+
-**Google Vertex AI**: set `use_vertex = true`. Authentication uses Google Application Default Credentials inside the workspace. See [Usage with Google Vertex AI](#usage-with-google-vertex-ai).
34
+
-**Custom API gateway**: set `anthropic_base_url` to a self-hosted gateway that speaks the Anthropic Messages API. See [Usage with a custom API gateway](#usage-with-a-custom-api-gateway).
AWS account with Bedrock access, Claude models enabled in Bedrock console, and appropriate IAM permissions.
224
-
225
-
Configure Claude Code to use AWS Bedrock for accessing Claude models through your AWS infrastructure.
224
+
Set `use_bedrock = true` to route Claude Code through Amazon Bedrock. The module sets `CLAUDE_CODE_USE_BEDROCK=1` and skips Anthropic API key setup; authentication is handled by the AWS SDK [credential chain](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html) inside the workspace.
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
232
234
}
233
235
234
236
resource "coder_env" "aws_region" {
235
237
agent_id = coder_agent.main.id
236
238
name = "AWS_REGION"
237
-
value = "us-east-1" # Choose your preferred region
239
+
value = "us-east-1"
238
240
}
241
+
```
239
242
240
-
# Option 1: Using AWS credentials
241
-
242
-
variable "aws_access_key_id" {
243
-
type = string
244
-
description = "Your AWS access key ID. Create this in the AWS IAM console under 'Security credentials'."
245
-
sensitive = true
246
-
}
243
+
> [!TIP]
244
+
> Prefer attaching an IAM role to the workspace (EKS [IRSA](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html), EC2 instance profile, or ECS task role) over passing static `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` through Terraform variables. Claude Code picks up the role via the standard AWS credential chain with no additional configuration.
247
245
248
-
variable "aws_secret_access_key" {
249
-
type = string
250
-
description = "Your AWS secret access key. This is shown once when you create an access key in the AWS IAM console."
251
-
sensitive = true
252
-
}
246
+
If you cannot use an attached role, set static credentials via `coder_env` resources:
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
286
-
}
287
270
```
288
271
289
272
> [!NOTE]
290
-
> For additional Bedrock configuration options (model selection, token limits, region overrides, etc.), see the [Claude Code Bedrock documentation](https://docs.claude.com/en/docs/claude-code/amazon-bedrock).
273
+
> Prerequisites: AWS account with Bedrock access, Claude models enabled in the Bedrock console, and IAM permission `bedrock:InvokeModelWithResponseStream`. For additional configuration (token limits, region overrides), see the [Claude Code Bedrock documentation](https://docs.claude.com/en/docs/claude-code/amazon-bedrock).
291
274
292
275
### Usage with Google Vertex AI
293
276
294
-
#### Prerequisites
295
-
296
-
GCP project with Vertex AI API enabled, Claude models enabled through Model Garden, service account with Vertex AI permissions, and appropriate IAM permissions (Vertex AI User role).
297
-
298
-
Configure Claude Code to use Google Vertex AI for accessing Claude models through Google Cloud Platform.
277
+
Set `use_vertex = true` to route Claude Code through Google Vertex AI. The module sets `CLAUDE_CODE_USE_VERTEX=1` and skips Anthropic API key setup; authentication uses [Google Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials) inside the workspace.
299
278
300
279
```tf
301
-
variable "vertex_sa_json" {
302
-
type = string
303
-
description = "The complete JSON content of your Google Cloud service account key file. Create a service account in the GCP Console under 'IAM & Admin > Service Accounts', then create and download a JSON key. Copy the entire JSON content into this variable."
> Prefer GKE [Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) or an attached service account over shipping a service-account JSON key through Terraform. Claude Code picks up Application Default Credentials automatically. If you must use a key file, mount it and set `GOOGLE_APPLICATION_CREDENTIALS` via a `coder_env` resource.
> Prerequisites: GCP project with Vertex AI API enabled, Claude models enabled through Model Garden, and the `Vertex AI User` role on the workspace identity. For additional configuration, see the [Claude Code Vertex AI documentation](https://docs.claude.com/en/docs/claude-code/google-vertex-ai).
355
307
356
-
# Add Google Cloud SDK repo to apt sources
357
-
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
Set `anthropic_base_url` to point Claude Code at a self-hosted gateway or proxy that speaks the Anthropic Messages API. The module sets `ANTHROPIC_BASE_URL` and skips its built-in Anthropic authentication setup; provide whatever credentials your gateway requires via separate `coder_env` resources.
> For additional Vertex AI configuration options (model selection, token limits, region overrides, etc.), see the [Claude Code Vertex AI documentation](https://docs.claude.com/en/docs/claude-code/google-vertex-ai).
322
+
> [!CAUTION]
323
+
> `anthropic_base_url` is mutually exclusive with `enable_ai_gateway`, which sets `ANTHROPIC_BASE_URL` to the Coder AI Gateway endpoint. `use_bedrock` and `use_vertex` are likewise mutually exclusive with `enable_ai_gateway` and with each other.
370
324
371
325
### Telemetry export (OpenTelemetry)
372
326
@@ -377,7 +331,7 @@ The module automatically tags every span and metric with `coder.workspace_id`, `
0 commit comments