Skip to content

fix(coder/modules/claude-code): update resource count logic for claude_api_key#814

Merged
35C4n0r merged 4 commits intomainfrom
35C4n0r/fix-claude-depends-on-resources
Mar 26, 2026
Merged

fix(coder/modules/claude-code): update resource count logic for claude_api_key#814
35C4n0r merged 4 commits intomainfrom
35C4n0r/fix-claude-depends-on-resources

Conversation

@35C4n0r
Copy link
Copy Markdown
Collaborator

@35C4n0r 35C4n0r commented Mar 26, 2026

Description

  • update resource count logic for claude_api_key

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/claude-code
New version: v4.8.2
Breaking change: [ ] Yes [ ] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

Closes: #812

@35C4n0r 35C4n0r marked this pull request as ready for review March 26, 2026 05:09
@35C4n0r 35C4n0r requested a review from Copilot March 26, 2026 05:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the claude-code Coder module to avoid Terraform “Invalid count argument” failures when enable_aibridge is used and callers add depends_on to the module block, by ensuring the coder_env.claude_api_key resource count depends only on input variables.

Changes:

  • Adjust coder_env.claude_api_key.count to be plan-time deterministic (enable_aibridge or claude_api_key provided).
  • Bump README examples to reference module version 4.8.2.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
registry/coder/modules/claude-code/main.tf Makes claude_api_key env resource count independent of apply-time data source values.
registry/coder/modules/claude-code/README.md Updates all usage snippets to version = "4.8.2".
Comments suppressed due to low confidence (1)

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

  • CLAUDE_API_KEY is being set from local.claude_api_key, which is var.claude_api_key when AI Bridge is disabled. variable "claude_api_key" is not marked sensitive, so this value may be rendered in plaintext in plan output/state depending on propagation. Consider marking the claude_api_key input variable as sensitive (consistent with other secret inputs like vault_token).
resource "coder_env" "claude_api_key" {
  count = var.enable_aibridge || var.claude_api_key != "" ? 1 : 0

  agent_id = var.agent_id
  name     = "CLAUDE_API_KEY"
  value    = local.claude_api_key
}

Comment thread registry/coder/modules/claude-code/main.tf Outdated
@35C4n0r 35C4n0r requested a review from matifali March 26, 2026 05:18
Comment thread registry/coder/modules/claude-code/main.tf
@35C4n0r 35C4n0r requested a review from matifali March 26, 2026 11:12
@35C4n0r 35C4n0r merged commit 516b9ce into main Mar 26, 2026
4 checks passed
@35C4n0r 35C4n0r deleted the 35C4n0r/fix-claude-depends-on-resources branch March 26, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(claude-code): enable_aibridge causes "Invalid count argument" on workspace creation

3 participants