Skip to content

Commit 1e8ab2a

Browse files
authored
Merge pull request awslabs#58 from awslabs/feat/tf-claude-agent-sdk-patterns
Add claude-agent-sdk patterns to Terraform
2 parents 1996763 + ec33efd commit 1e8ab2a

File tree

7 files changed

+28
-17
lines changed

7 files changed

+28
-17
lines changed

infra-cdk/lib/backend-stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class BackendStack extends cdk.NestedStack {
102102
// Parameters
103103
this.agentName = new cdk.CfnParameter(this, "AgentName", {
104104
type: "String",
105-
default: "StrandsAgent",
105+
default: "FASTAgent",
106106
description: "Name for the agent runtime",
107107
})
108108

infra-terraform/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Terraform uses flat variables with a `backend_` prefix to mirror the CDK's neste
6666
| `backend.vpc.subnet_ids` | `backend_vpc_subnet_ids` |
6767
| `backend.vpc.security_group_ids` | `backend_vpc_security_group_ids` |
6868

69-
Values that are hardcoded in CDK (not in `config.yaml`) are defined as module-internal locals in Terraform: agent name (`StrandsAgent`), memory event expiry (30 days), callback URLs, and password minimum length.
69+
Values that are hardcoded in CDK (not in `config.yaml`) are defined as module-internal locals in Terraform: agent name (`FASTAgent`), memory event expiry (30 days), callback URLs, and password minimum length.
7070

7171
## Module Structure
7272

infra-terraform/modules/backend/locals.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ locals {
2222
# Stack name for resource naming (underscores for some AWS resources)
2323
stack_name_underscore = replace(var.stack_name_base, "-", "_")
2424

25-
# Agent name (matches CDK CfnParameter default in backend-stack.ts)
26-
agent_name = "StrandsAgent"
25+
# Agent name used in runtime naming
26+
agent_name = "FASTAgent"
2727

2828
# Runtime name (underscores required by AgentCore)
2929
runtime_name = "${local.stack_name_underscore}_${local.agent_name}"
@@ -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: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ resource "terraform_data" "docker_image_hash" {
6363
input = local.is_docker && var.container_uri == null ? sha256(join("", concat(
6464
[filesha256("${local.pattern_dir}/Dockerfile")],
6565
[filesha256("${local.pattern_dir}/requirements.txt")],
66-
[for f in fileset(local.pattern_dir, "*.py") : filesha256("${local.pattern_dir}/${f}")],
66+
[for f in fileset(local.pattern_dir, "**/*.py") : filesha256("${local.pattern_dir}/${f}")],
6767
[for f in fileset("${local.project_root}/patterns/utils", "**/*.py") : filesha256("${local.project_root}/patterns/utils/${f}")],
6868
[for f in fileset("${local.project_root}/gateway", "**/*.py") : filesha256("${local.project_root}/gateway/${f}")],
6969
[for f in fileset("${local.project_root}/tools", "**/*.py") : filesha256("${local.project_root}/tools/${f}")],
@@ -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
}

infra-terraform/terraform.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ admin_user_email = null # Example: "admin@example.com"
3030
# -----------------------------------------------------------------------------
3131

3232
# Agent pattern to deploy
33-
# Available patterns: strands-single-agent, langgraph-single-agent
33+
# Available patterns: strands-single-agent, langgraph-single-agent, claude-agent-sdk-single-agent, claude-agent-sdk-multi-agent
3434
backend_pattern = "strands-single-agent"
3535

3636
# Deployment type for AgentCore Runtime

infra-terraform/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ variable "admin_user_email" {
3535
# =============================================================================
3636

3737
variable "backend_pattern" {
38-
description = "Agent pattern to deploy. Available patterns: strands-single-agent, langgraph-single-agent"
38+
description = "Agent pattern to deploy. Available patterns: strands-single-agent, langgraph-single-agent, claude-agent-sdk-single-agent, claude-agent-sdk-multi-agent"
3939
type = string
4040
default = "strands-single-agent"
4141

4242
validation {
43-
condition = contains(["strands-single-agent", "langgraph-single-agent"], var.backend_pattern)
44-
error_message = "Backend pattern must be one of: strands-single-agent, langgraph-single-agent."
43+
condition = contains(["strands-single-agent", "langgraph-single-agent", "claude-agent-sdk-single-agent", "claude-agent-sdk-multi-agent"], var.backend_pattern)
44+
error_message = "Backend pattern must be one of: strands-single-agent, langgraph-single-agent, claude-agent-sdk-single-agent, claude-agent-sdk-multi-agent."
4545
}
4646
}
4747

0 commit comments

Comments
 (0)