Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions templates/awshp-k8s-rag-with-claude-code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# AWS RAG Application Prototyping with Coder CDE

A Kubernetes-based Coder template that provides a complete development environment for AWS RAG (Retrieval-Augmented Generation) application prototyping with Claude Code integration.

## Architecture

This template creates:
- **Kubernetes workspace** with configurable CPU/memory resources
- **Aurora PostgreSQL Serverless v2** cluster with pgvector extension for vector storage
- **Claude Code integration** with AWS Bedrock for AI-assisted development
- **Pre-configured development environment** with AWS CLI, CDK, and Python tooling

## Key Components

### Infrastructure (`main.tf`)
- Kubernetes deployment with Coder agent
- Configurable compute resources (2-8 CPU cores, 2-8GB RAM)
- Git repository cloning (defaults to aws-rag-prototyping repo)
- Code-server and Claude Code modules
- Streamlit app preview on port 8501

### Database (`aws-aurora/aurora-pgvector.tf`)
- Aurora PostgreSQL 16.6 Serverless v2 cluster
- pgvector extension for vector embeddings
- Configurable scaling (0.5-1.0 ACU)
- Security group allowing PostgreSQL access

## Environment Variables

```bash
CLAUDE_CODE_USE_BEDROCK=1
ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0
PGVECTOR_HOST=<aurora-endpoint>
PGVECTOR_DATABASE=mydb1
PGVECTOR_USER=dbadmin
```

## Usage

1. Deploy template to Coder instance
2. Create workspace with desired CPU/memory configuration
3. Claude Code automatically sets up Python environment and installs dependencies
4. Access Streamlit preview at the provided URL
5. Use integrated development tools for RAG application prototyping

## Prerequisites

- Kubernetes cluster with Coder deployment
- AWS VPC with private subnets
- Appropriate IAM permissions for Aurora and Bedrock services
124 changes: 124 additions & 0 deletions templates/awshp-k8s-rag-with-claude-code/aws-aurora/aurora-pgvector.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# variables for Coder Workspace Reference
variable "workspace_name" {
type = string
default = "awsragproto"
}

variable "eks_cluster_name" {
description = "Name of the EKS cluster"
type = string
default = "coder-aws-cluster"
}

#Variables for Aurora PostgreSQL Serverless v2

variable "database_name" {
description = "Name of the database to be created"
type = string
default = "mydb"
}
variable "db_master_username" {
description = "Master username for the database"
type = string
default = "dbadmin"
}
variable "db_master_password" {
description = "Master password for the database"
type = string
default = "YourStrongPasswordHere1" # Consider using AWS Secrets Manager for production
}

# Get EKS cluster info
data "aws_eks_cluster" "current" {
name = var.eks_cluster_name # Add this variable
}

# Use EKS VPC
data "aws_vpc" "existing_vpc" {
id = data.aws_eks_cluster.current.vpc_config[0].vpc_id
}

# Get private subnets from EKS
data "aws_subnets" "private" {
filter {
name = "vpc-id"
values = [data.aws_vpc.existing_vpc.id]
}

tags = {
"kubernetes.io/role/internal-elb" = "1"
}
}

# Create a subnet group for Aurora instances using existing subnets
resource "aws_db_subnet_group" "awsrag_aurora_subnet_group" {
name = "${var.workspace_name}-sgrp"
subnet_ids = data.aws_subnets.private.ids

tags = {
Name = "${var.workspace_name}-sgrp"
}
}

# Create security group for Aurora instances
resource "aws_security_group" "awsrag_aurora_sg" {
name = "${var.workspace_name}-sg"
description = "Security group for Aurora PostgreSQL instances"
vpc_id = data.aws_vpc.existing_vpc.id

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Allow public access not restricted to the VPC
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "${var.workspace_name}-sg"
}
}

# First Aurora PostgreSQL Serverless v2 instance
resource "aws_rds_cluster" "awsrag_aurora_postgres_1" {
cluster_identifier = "${var.workspace_name}-pgvector01"
engine = "aurora-postgresql"
engine_mode = "provisioned"
engine_version = "16.6"
database_name = var.database_name
master_username = var.db_master_username
master_password = var.db_master_password # Use AWS Secrets Manager in production
db_subnet_group_name = aws_db_subnet_group.awsrag_aurora_subnet_group.name
vpc_security_group_ids = [aws_security_group.awsrag_aurora_sg.id]
skip_final_snapshot = true

serverlessv2_scaling_configuration {
min_capacity = 0.5
max_capacity = 1.0
}
}

# Primary DB instance for the Aurora PostgreSQL cluster
resource "aws_rds_cluster_instance" "awsrag_aurora_primary" {
cluster_identifier = aws_rds_cluster.awsrag_aurora_postgres_1.id
instance_class = "db.serverless"
engine = "aurora-postgresql"
engine_version = "16.6"
db_subnet_group_name = aws_db_subnet_group.awsrag_aurora_subnet_group.name
identifier = "${var.workspace_name}-primary"
}

# Outputs
output "aurora_postgres_1_endpoint" {
value = aws_rds_cluster.awsrag_aurora_postgres_1.endpoint
}

output "aurora_postgres_1_reader_endpoint" {
value = aws_rds_cluster.awsrag_aurora_postgres_1.reader_endpoint
}
Loading