Skip to content

Commit 06cc0d0

Browse files
committed
feat(terraform): add claude-agent-sdk input validation and CLAUDE_CODE_USE_BEDROCK env var
- Add precondition to prevent zip deployment with claude-agent-sdk patterns - Add conditional CLAUDE_CODE_USE_BEDROCK=1 environment variable - Add is_claude_agent_sdk local flag Mirrors CDK backend-stack.ts changes from PR awslabs#45.
1 parent 8379efe commit 06cc0d0

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

infra-terraform/modules/backend/locals.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ locals {
4242
is_docker = var.backend_deployment_type == "docker"
4343
is_zip = var.backend_deployment_type == "zip"
4444

45+
# Pattern flags
46+
is_claude_agent_sdk = contains(["claude-agent-sdk-single-agent", "claude-agent-sdk-multi-agent"], var.backend_pattern)
47+
4548
# Project paths (for zip packaging)
4649
project_root = "${path.module}/../../.."
4750
pattern_dir = "${local.project_root}/patterns/${var.backend_pattern}"

infra-terraform/modules/backend/runtime.tf

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,24 @@ resource "aws_bedrockagentcore_agent_runtime" "main" {
471471
}
472472

473473
# Environment variables for the runtime
474-
environment_variables = {
475-
AWS_REGION = local.region
476-
AWS_DEFAULT_REGION = local.region
477-
MEMORY_ID = aws_bedrockagentcore_memory.main.id
478-
STACK_NAME = var.stack_name_base
479-
GATEWAY_CREDENTIAL_PROVIDER_NAME = "${var.stack_name_base}-runtime-gateway-auth"
480-
}
474+
environment_variables = merge(
475+
{
476+
AWS_REGION = local.region
477+
AWS_DEFAULT_REGION = local.region
478+
MEMORY_ID = aws_bedrockagentcore_memory.main.id
479+
STACK_NAME = var.stack_name_base
480+
GATEWAY_CREDENTIAL_PROVIDER_NAME = "${var.stack_name_base}-runtime-gateway-auth"
481+
},
482+
# claude-agent-sdk patterns require CLAUDE_CODE_USE_BEDROCK=1
483+
local.is_claude_agent_sdk ? { CLAUDE_CODE_USE_BEDROCK = "1" } : {}
484+
)
481485

482486
# Force runtime replacement when agent code changes (zip or docker)
483487
lifecycle {
488+
precondition {
489+
condition = !local.is_claude_agent_sdk || local.is_docker
490+
error_message = "claude-agent-sdk patterns require Docker deployment (backend_deployment_type = \"docker\") because they need Node.js and the claude-code CLI installed at build time."
491+
}
484492
precondition {
485493
condition = var.backend_network_mode != "VPC" || (var.backend_vpc_id != null && var.backend_vpc_id != "")
486494
error_message = "backend_vpc_id is required when backend_network_mode is 'VPC'."

infra-terraform/modules/backend/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "backend_pattern" {
1717
}
1818

1919
variable "backend_deployment_type" {
20-
description = "Deployment type: 'docker' (container via ECR) or 'zip' (Python package via S3)."
20+
description = "Deployment type: 'docker' (container via ECR) or 'zip' (Python package via S3). Note: claude-agent-sdk patterns require 'docker'."
2121
type = string
2222
default = "docker"
2323
}

0 commit comments

Comments
 (0)