Skip to content

Commit 9f330d2

Browse files
feat: add support for AWS Bedrock and Google Vertex AI in Claude Code module
1 parent 571f921 commit 9f330d2

File tree

2 files changed

+137
-61
lines changed

2 files changed

+137
-61
lines changed

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

Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -124,51 +124,26 @@ AWS account with Bedrock access, Claude models enabled in Bedrock console, appro
124124
Configure Claude Code to use AWS Bedrock for accessing Claude models through your AWS infrastructure.
125125

126126
```tf
127-
resource "coder_env" "bedrock_use" {
128-
agent_id = coder_agent.example.id
129-
name = "CLAUDE_CODE_USE_BEDROCK"
130-
value = "1"
131-
}
132-
133-
resource "coder_env" "aws_region" {
134-
agent_id = coder_agent.example.id
135-
name = "AWS_REGION"
136-
value = "us-east-1" # Choose your preferred region
137-
}
138-
139-
# Option 1: Using AWS credentials
140-
resource "coder_env" "aws_access_key" {
141-
agent_id = coder_agent.example.id
142-
name = "AWS_ACCESS_KEY_ID"
143-
value = "your-access-key-id"
144-
}
145-
146-
resource "coder_env" "aws_secret_key" {
147-
agent_id = coder_agent.example.id
148-
name = "AWS_SECRET_ACCESS_KEY"
149-
value = "your-secret-access-key"
150-
sensitive = true
151-
}
127+
module "claude-code" {
128+
source = "registry.coder.com/coder/claude-code/coder"
129+
version = "3.0.1"
130+
agent_id = coder_agent.example.id
131+
workdir = "/home/coder/project"
132+
model = "anthropic.claude-3-5-sonnet-20241022-v2:0" # Bedrock model ID
133+
use_bedrock = true
134+
aws_region = "us-west-2"
152135
153-
# Option 2: Using Bedrock API key (simpler)
154-
resource "coder_env" "bedrock_api_key" {
155-
agent_id = coder_agent.example.id
156-
name = "AWS_BEARER_TOKEN_BEDROCK"
157-
value = "your-bedrock-api-key"
158-
sensitive = true
159-
}
136+
# Option 1: Using AWS credentials
137+
aws_access_key_id = "AKIA..."
138+
aws_secret_access_key = "your-secret-key"
160139
161-
module "claude-code" {
162-
source = "registry.coder.com/coder/claude-code/coder"
163-
version = "3.0.1"
164-
agent_id = coder_agent.example.id
165-
workdir = "/home/coder/project"
166-
model = "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
140+
# Option 2: Using Bedrock API key (alternative to AWS credentials)
141+
# aws_bearer_token_bedrock = "your-bedrock-api-key"
167142
}
168143
```
169144

170145
> [!NOTE]
171-
> 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).
146+
> For model IDs and available models in your region, refer to the [AWS Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html). 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).
172147
173148
### Usage with Google Vertex AI
174149

@@ -179,32 +154,27 @@ GCP project with Vertex AI API enabled, Claude models enabled through Model Gard
179154
Configure Claude Code to use Google Vertex AI for accessing Claude models through Google Cloud Platform.
180155

181156
```tf
182-
resource "coder_env" "vertex_use" {
183-
agent_id = coder_agent.example.id
184-
name = "CLAUDE_CODE_USE_VERTEX"
185-
value = "1"
157+
module "claude-code" {
158+
source = "registry.coder.com/coder/claude-code/coder"
159+
version = "3.0.1"
160+
agent_id = coder_agent.example.id
161+
workdir = "/home/coder/project"
162+
model = "claude-3-5-sonnet@20241022" # Vertex AI model name
163+
use_vertex = true
164+
vertex_project_id = "your-gcp-project-id"
165+
vertex_region = "us-central1" # or "global"
186166
}
167+
```
187168

188-
resource "coder_env" "vertex_project_id" {
189-
agent_id = coder_agent.example.id
190-
name = "ANTHROPIC_VERTEX_PROJECT_ID"
191-
value = "your-gcp-project-id"
192-
}
169+
**Authentication**
193170

194-
resource "coder_env" "cloud_ml_region" {
195-
agent_id = coder_agent.example.id
196-
name = "CLOUD_ML_REGION"
197-
value = "global"
198-
}
171+
Vertex AI uses Google Cloud authentication. Ensure your workspace has access to Google Cloud credentials through one of these methods:
199172

200-
module "claude-code" {
201-
source = "registry.coder.com/coder/claude-code/coder"
202-
version = "3.0.1"
203-
agent_id = coder_agent.example.id
204-
workdir = "/home/coder/project"
205-
model = "claude-sonnet-4@20250514"
206-
}
207-
```
173+
1. **Application Default Credentials (ADC)**: Set up through `gcloud auth application-default login`
174+
2. **Service Account**: Configure `GOOGLE_APPLICATION_CREDENTIALS` environment variable
175+
3. **Workload Identity**: For GKE deployments
176+
177+
Refer to the [Google Cloud authentication documentation](https://cloud.google.com/docs/authentication/application-default-credentials) for detailed setup instructions.
208178

209179
> [!NOTE]
210180
> 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).

registry/coder/modules/claude-code/main.tf

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,57 @@ variable "claude_md_path" {
192192
default = "$HOME/.claude/CLAUDE.md"
193193
}
194194

195+
variable "use_bedrock" {
196+
type = bool
197+
description = "Whether to use AWS Bedrock for Claude Code."
198+
default = false
199+
}
200+
201+
variable "aws_region" {
202+
type = string
203+
description = "AWS region for Bedrock."
204+
default = ""
205+
}
206+
207+
variable "aws_access_key_id" {
208+
type = string
209+
description = "AWS access key ID for Bedrock authentication."
210+
default = ""
211+
sensitive = true
212+
}
213+
214+
variable "aws_secret_access_key" {
215+
type = string
216+
description = "AWS secret access key for Bedrock authentication."
217+
default = ""
218+
sensitive = true
219+
}
220+
221+
variable "aws_bearer_token_bedrock" {
222+
type = string
223+
description = "AWS Bedrock API key for simplified authentication."
224+
default = ""
225+
sensitive = true
226+
}
227+
228+
variable "use_vertex" {
229+
type = bool
230+
description = "Whether to use Google Vertex AI for Claude Code."
231+
default = false
232+
}
233+
234+
variable "vertex_project_id" {
235+
type = string
236+
description = "Google Cloud project ID for Vertex AI."
237+
default = ""
238+
}
239+
240+
variable "vertex_region" {
241+
type = string
242+
description = "Google Cloud region for Vertex AI."
243+
default = "global"
244+
}
245+
195246
resource "coder_env" "claude_code_md_path" {
196247
count = var.claude_md_path == "" ? 0 : 1
197248

@@ -221,6 +272,61 @@ resource "coder_env" "claude_api_key" {
221272
name = "CLAUDE_API_KEY"
222273
value = var.claude_api_key
223274
}
275+
resource "coder_env" "use_bedrock" {
276+
count = var.use_bedrock ? 1 : 0
277+
agent_id = var.agent_id
278+
name = "CLAUDE_CODE_USE_BEDROCK"
279+
value = "1"
280+
}
281+
282+
resource "coder_env" "aws_region" {
283+
count = var.use_bedrock && var.aws_region != "" ? 1 : 0
284+
agent_id = var.agent_id
285+
name = "AWS_REGION"
286+
value = var.aws_region
287+
}
288+
289+
resource "coder_env" "aws_access_key_id" {
290+
count = var.use_bedrock && var.aws_access_key_id != "" ? 1 : 0
291+
agent_id = var.agent_id
292+
name = "AWS_ACCESS_KEY_ID"
293+
value = var.aws_access_key_id
294+
}
295+
296+
resource "coder_env" "aws_secret_access_key" {
297+
count = var.use_bedrock && var.aws_secret_access_key != "" ? 1 : 0
298+
agent_id = var.agent_id
299+
name = "AWS_SECRET_ACCESS_KEY"
300+
value = var.aws_secret_access_key
301+
}
302+
303+
resource "coder_env" "aws_bearer_token_bedrock" {
304+
count = var.use_bedrock && var.aws_bearer_token_bedrock != "" ? 1 : 0
305+
agent_id = var.agent_id
306+
name = "AWS_BEARER_TOKEN_BEDROCK"
307+
value = var.aws_bearer_token_bedrock
308+
}
309+
310+
resource "coder_env" "use_vertex" {
311+
count = var.use_vertex ? 1 : 0
312+
agent_id = var.agent_id
313+
name = "CLAUDE_CODE_USE_VERTEX"
314+
value = "1"
315+
}
316+
317+
resource "coder_env" "vertex_project_id" {
318+
count = var.use_vertex && var.vertex_project_id != "" ? 1 : 0
319+
agent_id = var.agent_id
320+
name = "ANTHROPIC_VERTEX_PROJECT_ID"
321+
value = var.vertex_project_id
322+
}
323+
324+
resource "coder_env" "vertex_region" {
325+
count = var.use_vertex ? 1 : 0
326+
agent_id = var.agent_id
327+
name = "CLOUD_ML_REGION"
328+
value = var.vertex_region
329+
}
224330

225331
locals {
226332
# we have to trim the slash because otherwise coder exp mcp will

0 commit comments

Comments
 (0)