diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index 3c334e745..223056246 100644 --- a/registry/coder/modules/claude-code/README.md +++ b/registry/coder/modules/claude-code/README.md @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.0.1" + version = "3.1.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_api_key = "xxxx-xxxxx-xxxx" @@ -49,7 +49,7 @@ data "coder_parameter" "ai_prompt" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.0.1" + version = "3.1.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" @@ -85,7 +85,7 @@ Run and configure Claude Code as a standalone CLI in your workspace. ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.0.1" + version = "3.1.0" agent_id = coder_agent.example.id workdir = "/home/coder" install_claude_code = true @@ -108,13 +108,77 @@ variable "claude_code_oauth_token" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "3.0.1" + version = "3.1.0" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_code_oauth_token = var.claude_code_oauth_token } ``` +### Usage with AWS Bedrock + +#### Prerequisites + +AWS account with Bedrock access, Claude models enabled in Bedrock console, appropriate IAM permissions. + +Configure Claude Code to use AWS Bedrock for accessing Claude models through your AWS infrastructure. + +```tf +module "claude-code" { + source = "registry.coder.com/coder/claude-code/coder" + version = "3.1.0" + agent_id = coder_agent.example.id + workdir = "/home/coder/project" + model = "anthropic.claude-3-5-sonnet-20241022-v2:0" # Bedrock model ID + use_bedrock = true + aws_region = "us-west-2" + + # Option 1: Using AWS credentials + aws_access_key_id = "AKIA..." + aws_secret_access_key = "your-secret-key" + + # Option 2: Using Bedrock API key (alternative to AWS credentials) + # aws_bearer_token_bedrock = "your-bedrock-api-key" +} +``` + +> [!NOTE] +> 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). + +### Usage with Google Vertex AI + +#### Prerequisites + +GCP project with Vertex AI API enabled, Claude models enabled through Model Garden, Google Cloud authentication configured, appropriate IAM permissions. + +Configure Claude Code to use Google Vertex AI for accessing Claude models through Google Cloud Platform. + +```tf +module "claude-code" { + source = "registry.coder.com/coder/claude-code/coder" + version = "3.1.0" + agent_id = coder_agent.example.id + workdir = "/home/coder/project" + model = "claude-3-5-sonnet@20241022" # Vertex AI model name + use_vertex = true + vertex_project_id = "your-gcp-project-id" + vertex_region = "us-central1" # or "global" +} +``` + +**Authentication** + +Vertex AI uses Google Cloud authentication. Ensure your workspace has access to Google Cloud credentials through one of these methods: + +1. **Application Default Credentials (ADC)**: Set up through `gcloud auth application-default login` +2. **Service Account**: Configure `GOOGLE_APPLICATION_CREDENTIALS` environment variable +3. **Workload Identity**: For GKE deployments + +Refer to the [Google Cloud authentication documentation](https://cloud.google.com/docs/authentication/application-default-credentials) for detailed setup instructions. + +> [!NOTE] +> 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). + ## Troubleshooting If you encounter any issues, check the log files in the `~/.claude-module` directory within your workspace for detailed information. diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 4836347b7..3cdc7288f 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -192,6 +192,57 @@ variable "claude_md_path" { default = "$HOME/.claude/CLAUDE.md" } +variable "use_bedrock" { + type = bool + description = "Whether to use AWS Bedrock for Claude Code." + default = false +} + +variable "aws_region" { + type = string + description = "AWS region for Bedrock." + default = "" +} + +variable "aws_access_key_id" { + type = string + description = "AWS access key ID for Bedrock authentication." + default = "" + sensitive = true +} + +variable "aws_secret_access_key" { + type = string + description = "AWS secret access key for Bedrock authentication." + default = "" + sensitive = true +} + +variable "aws_bearer_token_bedrock" { + type = string + description = "AWS Bedrock API key for simplified authentication." + default = "" + sensitive = true +} + +variable "use_vertex" { + type = bool + description = "Whether to use Google Vertex AI for Claude Code." + default = false +} + +variable "vertex_project_id" { + type = string + description = "Google Cloud project ID for Vertex AI." + default = "" +} + +variable "vertex_region" { + type = string + description = "Google Cloud region for Vertex AI." + default = "global" +} + resource "coder_env" "claude_code_md_path" { count = var.claude_md_path == "" ? 0 : 1 @@ -221,6 +272,61 @@ resource "coder_env" "claude_api_key" { name = "CLAUDE_API_KEY" value = var.claude_api_key } +resource "coder_env" "use_bedrock" { + count = var.use_bedrock ? 1 : 0 + agent_id = var.agent_id + name = "CLAUDE_CODE_USE_BEDROCK" + value = "1" +} + +resource "coder_env" "aws_region" { + count = var.use_bedrock && var.aws_region != "" ? 1 : 0 + agent_id = var.agent_id + name = "AWS_REGION" + value = var.aws_region +} + +resource "coder_env" "aws_access_key_id" { + count = var.use_bedrock && var.aws_access_key_id != "" ? 1 : 0 + agent_id = var.agent_id + name = "AWS_ACCESS_KEY_ID" + value = var.aws_access_key_id +} + +resource "coder_env" "aws_secret_access_key" { + count = var.use_bedrock && var.aws_secret_access_key != "" ? 1 : 0 + agent_id = var.agent_id + name = "AWS_SECRET_ACCESS_KEY" + value = var.aws_secret_access_key +} + +resource "coder_env" "aws_bearer_token_bedrock" { + count = var.use_bedrock && var.aws_bearer_token_bedrock != "" ? 1 : 0 + agent_id = var.agent_id + name = "AWS_BEARER_TOKEN_BEDROCK" + value = var.aws_bearer_token_bedrock +} + +resource "coder_env" "use_vertex" { + count = var.use_vertex ? 1 : 0 + agent_id = var.agent_id + name = "CLAUDE_CODE_USE_VERTEX" + value = "1" +} + +resource "coder_env" "vertex_project_id" { + count = var.use_vertex && var.vertex_project_id != "" ? 1 : 0 + agent_id = var.agent_id + name = "ANTHROPIC_VERTEX_PROJECT_ID" + value = var.vertex_project_id +} + +resource "coder_env" "vertex_region" { + count = var.use_vertex ? 1 : 0 + agent_id = var.agent_id + name = "CLOUD_ML_REGION" + value = var.vertex_region +} locals { # we have to trim the slash because otherwise coder exp mcp will