Skip to content

Commit 30bbe85

Browse files
authored
chore: lower rds resources (#113)
* chore: lower resources for rds * chore: minimal resources * chore: make it a var
1 parent fe9e095 commit 30bbe85

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

backend/src/prisma.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ const DB_PWD = encodeURIComponent(process.env.POSTGRES_PASSWORD || "default"); /
77
const DB_PORT = process.env.POSTGRES_PORT || 5432;
88
const DB_NAME = process.env.POSTGRES_DATABASE || "postgres";
99
const DB_SCHEMA = process.env.POSTGRES_SCHEMA || "app";
10+
const DB_POOL_SIZE = parseInt(process.env.POSTGRES_POOL_SIZE || "5", 10);
1011
// SSL settings for PostgreSQL 17+ which requires SSL by default
1112
const SSL_MODE = (process.env.NODE_ENV === 'local' || 'unittest') ? 'prefer' : 'require'; // 'require' for aws deployments, 'prefer' for local development or ut in gha
12-
const dataSourceURL = `postgresql://${DB_USER}:${DB_PWD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=${DB_SCHEMA}&connection_limit=5&sslmode=${SSL_MODE}`;
13+
const dataSourceURL = `postgresql://${DB_USER}:${DB_PWD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=${DB_SCHEMA}&connection_limit=${DB_POOL_SIZE}&sslmode=${SSL_MODE}`;
1314

1415
@Injectable({ scope: Scope.DEFAULT})
1516
class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, 'query'> implements OnModuleInit, OnModuleDestroy {

infrastructure/api/ecs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ resource "aws_ecs_task_definition" "node_api_task" {
200200
name = "POSTGRES_SCHEMA"
201201
value = "${var.db_schema}"
202202
},
203+
{
204+
name = "POSTGRES_POOL_SIZE"
205+
value = "${var.postgres_pool_size}"
206+
},
203207
{
204208
name = "PORT"
205209
value = "3000"

infrastructure/api/vars.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,9 @@ variable "is_public_api" {
168168
description = "Flag to indicate if the API is public or private"
169169
type = bool
170170
default = true
171+
}
172+
variable "postgres_pool_size" {
173+
description = "The size of the connection pool for the API"
174+
type = string
175+
default = "1"
171176
}

infrastructure/database/vars.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ variable "app_env" {
3838
variable "min_capacity" {
3939
description = "Minimum capacity for Aurora Serverless v2"
4040
type = number
41-
default = 0.5
41+
default = 0
4242
}
4343

4444
variable "max_capacity" {

0 commit comments

Comments
 (0)