Skip to content

Commit 516b9ce

Browse files
authored
fix(coder/modules/claude-code): update resource count logic for claude_api_key (#814)
## Description - update resource count logic for claude_api_key <!-- Briefly describe what this PR does and why --> ## Type of Change - [ ] New module - [ ] New template - [x] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder/modules/claude-code` **New version:** `v4.8.2` **Breaking change:** [ ] Yes [ ] No ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun fmt`) - [x] Changes tested locally ## Related Issues Closes: #812
1 parent da8e296 commit 516b9ce

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
1313
```tf
1414
module "claude-code" {
1515
source = "registry.coder.com/coder/claude-code/coder"
16-
version = "4.8.1"
16+
version = "4.8.2"
1717
agent_id = coder_agent.main.id
1818
workdir = "/home/coder/project"
1919
claude_api_key = "xxxx-xxxxx-xxxx"
@@ -60,7 +60,7 @@ By default, when `enable_boundary = true`, the module uses `coder boundary` subc
6060
```tf
6161
module "claude-code" {
6262
source = "registry.coder.com/coder/claude-code/coder"
63-
version = "4.8.1"
63+
version = "4.8.2"
6464
agent_id = coder_agent.main.id
6565
workdir = "/home/coder/project"
6666
enable_boundary = true
@@ -81,7 +81,7 @@ For tasks integration with AI Bridge, add `enable_aibridge = true` to the [Usage
8181
```tf
8282
module "claude-code" {
8383
source = "registry.coder.com/coder/claude-code/coder"
84-
version = "4.8.1"
84+
version = "4.8.2"
8585
agent_id = coder_agent.main.id
8686
workdir = "/home/coder/project"
8787
enable_aibridge = true
@@ -110,7 +110,7 @@ data "coder_task" "me" {}
110110
111111
module "claude-code" {
112112
source = "registry.coder.com/coder/claude-code/coder"
113-
version = "4.8.1"
113+
version = "4.8.2"
114114
agent_id = coder_agent.main.id
115115
workdir = "/home/coder/project"
116116
ai_prompt = data.coder_task.me.prompt
@@ -133,7 +133,7 @@ This example shows additional configuration options for version pinning, custom
133133
```tf
134134
module "claude-code" {
135135
source = "registry.coder.com/coder/claude-code/coder"
136-
version = "4.8.1"
136+
version = "4.8.2"
137137
agent_id = coder_agent.main.id
138138
workdir = "/home/coder/project"
139139
@@ -189,7 +189,7 @@ Run and configure Claude Code as a standalone CLI in your workspace.
189189
```tf
190190
module "claude-code" {
191191
source = "registry.coder.com/coder/claude-code/coder"
192-
version = "4.8.1"
192+
version = "4.8.2"
193193
agent_id = coder_agent.main.id
194194
workdir = "/home/coder/project"
195195
install_claude_code = true
@@ -211,7 +211,7 @@ variable "claude_code_oauth_token" {
211211
212212
module "claude-code" {
213213
source = "registry.coder.com/coder/claude-code/coder"
214-
version = "4.8.1"
214+
version = "4.8.2"
215215
agent_id = coder_agent.main.id
216216
workdir = "/home/coder/project"
217217
claude_code_oauth_token = var.claude_code_oauth_token
@@ -284,7 +284,7 @@ resource "coder_env" "bedrock_api_key" {
284284
285285
module "claude-code" {
286286
source = "registry.coder.com/coder/claude-code/coder"
287-
version = "4.8.1"
287+
version = "4.8.2"
288288
agent_id = coder_agent.main.id
289289
workdir = "/home/coder/project"
290290
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
@@ -341,7 +341,7 @@ resource "coder_env" "google_application_credentials" {
341341
342342
module "claude-code" {
343343
source = "registry.coder.com/coder/claude-code/coder"
344-
version = "4.8.1"
344+
version = "4.8.2"
345345
agent_id = coder_agent.main.id
346346
workdir = "/home/coder/project"
347347
model = "claude-sonnet-4@20250514"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ resource "coder_env" "claude_code_oauth_token" {
287287
}
288288

289289
resource "coder_env" "claude_api_key" {
290-
count = local.claude_api_key != "" ? 1 : 0
290+
count = (var.enable_aibridge || (var.claude_api_key != "")) ? 1 : 0
291291

292292
agent_id = var.agent_id
293293
name = "CLAUDE_API_KEY"

registry/coder/modules/claude-code/main.tftest.hcl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ run "test_disable_state_persistence" {
416416
}
417417
}
418418

419-
420419
run "test_no_api_key_no_env" {
421420
command = plan
422421

@@ -431,3 +430,18 @@ run "test_no_api_key_no_env" {
431430
error_message = "CLAUDE_API_KEY should not be created when no API key is provided and aibridge is disabled"
432431
}
433432
}
433+
434+
run "test_api_key_count_with_aibridge_no_override" {
435+
command = plan
436+
437+
variables {
438+
agent_id = "test-agent-count"
439+
workdir = "/home/coder/test"
440+
enable_aibridge = true
441+
}
442+
443+
assert {
444+
condition = length(coder_env.claude_api_key) == 1
445+
error_message = "CLAUDE_API_KEY env should be created when aibridge is enabled, regardless of session_token value"
446+
}
447+
}

0 commit comments

Comments
 (0)