Skip to content

Commit 4c36f0d

Browse files
Merge pull request #1 from coder/greg-the-coder-patch-2
Greg the coder patch 2 - Added GenAI RAG Prototyping template
2 parents 26f62f6 + 75fc998 commit 4c36f0d

File tree

4 files changed

+651
-0
lines changed

4 files changed

+651
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AWS RAG Application Prototyping with Coder CDE
2+
3+
A Kubernetes-based Coder template that provides a complete development environment for AWS RAG (Retrieval-Augmented Generation) application prototyping with Claude Code integration.
4+
5+
## Architecture
6+
7+
This template creates:
8+
- **Kubernetes workspace** with configurable CPU/memory resources
9+
- **Aurora PostgreSQL Serverless v2** cluster with pgvector extension for vector storage
10+
- **Claude Code integration** with AWS Bedrock for AI-assisted development
11+
- **Pre-configured development environment** with AWS CLI, CDK, and Python tooling
12+
13+
## Key Components
14+
15+
### Infrastructure (`main.tf`)
16+
- Kubernetes deployment with Coder agent
17+
- Configurable compute resources (2-8 CPU cores, 2-8GB RAM)
18+
- Git repository cloning (defaults to aws-rag-prototyping repo)
19+
- Code-server and Claude Code modules
20+
- Streamlit app preview on port 8501
21+
22+
### Database (`aws-aurora/aurora-pgvector.tf`)
23+
- Aurora PostgreSQL 16.6 Serverless v2 cluster
24+
- pgvector extension for vector embeddings
25+
- Configurable scaling (0.5-1.0 ACU)
26+
- Security group allowing PostgreSQL access
27+
28+
## Environment Variables
29+
30+
```bash
31+
CLAUDE_CODE_USE_BEDROCK=1
32+
ANTHROPIC_MODEL=us.anthropic.claude-3-7-sonnet-20250219-v1:0
33+
PGVECTOR_HOST=<aurora-endpoint>
34+
PGVECTOR_DATABASE=mydb1
35+
PGVECTOR_USER=dbadmin
36+
```
37+
38+
## Usage
39+
40+
1. Deploy template to Coder instance
41+
2. Create workspace with desired CPU/memory configuration
42+
3. Claude Code automatically sets up Python environment and installs dependencies
43+
4. Access Streamlit preview at the provided URL
44+
5. Use integrated development tools for RAG application prototyping
45+
46+
## Prerequisites
47+
48+
- Kubernetes cluster with Coder deployment
49+
- AWS VPC with private subnets
50+
- Appropriate IAM permissions for Aurora and Bedrock services
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# variables for Coder Workspace Reference
2+
variable "workspace_name" {
3+
type = string
4+
default = "awsragproto"
5+
}
6+
7+
variable "eks_cluster_name" {
8+
description = "Name of the EKS cluster"
9+
type = string
10+
default = "coder-aws-cluster"
11+
}
12+
13+
#Variables for Aurora PostgreSQL Serverless v2
14+
15+
variable "database_name" {
16+
description = "Name of the database to be created"
17+
type = string
18+
default = "mydb"
19+
}
20+
variable "db_master_username" {
21+
description = "Master username for the database"
22+
type = string
23+
default = "dbadmin"
24+
}
25+
variable "db_master_password" {
26+
description = "Master password for the database"
27+
type = string
28+
default = "YourStrongPasswordHere1" # Consider using AWS Secrets Manager for production
29+
}
30+
31+
# Get EKS cluster info
32+
data "aws_eks_cluster" "current" {
33+
name = var.eks_cluster_name # Add this variable
34+
}
35+
36+
# Use EKS VPC
37+
data "aws_vpc" "existing_vpc" {
38+
id = data.aws_eks_cluster.current.vpc_config[0].vpc_id
39+
}
40+
41+
# Get private subnets from EKS
42+
data "aws_subnets" "private" {
43+
filter {
44+
name = "vpc-id"
45+
values = [data.aws_vpc.existing_vpc.id]
46+
}
47+
48+
tags = {
49+
"kubernetes.io/role/internal-elb" = "1"
50+
}
51+
}
52+
53+
# Create a subnet group for Aurora instances using existing subnets
54+
resource "aws_db_subnet_group" "awsrag_aurora_subnet_group" {
55+
name = "${var.workspace_name}-sgrp"
56+
subnet_ids = data.aws_subnets.private.ids
57+
58+
tags = {
59+
Name = "${var.workspace_name}-sgrp"
60+
}
61+
}
62+
63+
# Create security group for Aurora instances
64+
resource "aws_security_group" "awsrag_aurora_sg" {
65+
name = "${var.workspace_name}-sg"
66+
description = "Security group for Aurora PostgreSQL instances"
67+
vpc_id = data.aws_vpc.existing_vpc.id
68+
69+
ingress {
70+
from_port = 5432
71+
to_port = 5432
72+
protocol = "tcp"
73+
cidr_blocks = ["0.0.0.0/0"] # Allow public access not restricted to the VPC
74+
}
75+
76+
egress {
77+
from_port = 0
78+
to_port = 0
79+
protocol = "-1"
80+
cidr_blocks = ["0.0.0.0/0"]
81+
}
82+
83+
tags = {
84+
Name = "${var.workspace_name}-sg"
85+
}
86+
}
87+
88+
# First Aurora PostgreSQL Serverless v2 instance
89+
resource "aws_rds_cluster" "awsrag_aurora_postgres_1" {
90+
cluster_identifier = "${var.workspace_name}-pgvector01"
91+
engine = "aurora-postgresql"
92+
engine_mode = "provisioned"
93+
engine_version = "16.6"
94+
database_name = var.database_name
95+
master_username = var.db_master_username
96+
master_password = var.db_master_password # Use AWS Secrets Manager in production
97+
db_subnet_group_name = aws_db_subnet_group.awsrag_aurora_subnet_group.name
98+
vpc_security_group_ids = [aws_security_group.awsrag_aurora_sg.id]
99+
skip_final_snapshot = true
100+
101+
serverlessv2_scaling_configuration {
102+
min_capacity = 0.5
103+
max_capacity = 1.0
104+
}
105+
}
106+
107+
# Primary DB instance for the Aurora PostgreSQL cluster
108+
resource "aws_rds_cluster_instance" "awsrag_aurora_primary" {
109+
cluster_identifier = aws_rds_cluster.awsrag_aurora_postgres_1.id
110+
instance_class = "db.serverless"
111+
engine = "aurora-postgresql"
112+
engine_version = "16.6"
113+
db_subnet_group_name = aws_db_subnet_group.awsrag_aurora_subnet_group.name
114+
identifier = "${var.workspace_name}-primary"
115+
}
116+
117+
# Outputs
118+
output "aurora_postgres_1_endpoint" {
119+
value = aws_rds_cluster.awsrag_aurora_postgres_1.endpoint
120+
}
121+
122+
output "aurora_postgres_1_reader_endpoint" {
123+
value = aws_rds_cluster.awsrag_aurora_postgres_1.reader_endpoint
124+
}

0 commit comments

Comments
 (0)