Skip to content

Commit 85d7983

Browse files
committed
Enhance AWS RDS SSL configuration for database connections
- Update buildspec.yml to set PGSSLMODE and NODE_TLS_REJECT_UNAUTHORIZED for SSL handling - Modify drizzle.config.ts to include SSL options directly in dbCredentials - Remove aws-ssl-profiles dependency and adjust db connection settings to disable certificate verification while maintaining SSL encryption
1 parent 475db5c commit 85d7983

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

apps/web/buildspec.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ phases:
1717
- echo "DATABASE_URL length:" ${#DATABASE_URL}
1818
- echo "DATABASE_URL (masked):" $(echo "$DATABASE_URL" | sed 's/:[^@]*@/:***@/')
1919
- echo "NODE_ENV:" $NODE_ENV
20+
21+
# === FIX FOR AWS RDS SSL CERTIFICATE ===
22+
# AWS RDS uses self-signed certificates, we need to configure SSL properly
23+
- export PGSSLMODE=require
24+
- export NODE_TLS_REJECT_UNAUTHORIZED=0
25+
- echo "PGSSLMODE set to:" $PGSSLMODE
26+
- echo "NODE_TLS_REJECT_UNAUTHORIZED set to:" $NODE_TLS_REJECT_UNAUTHORIZED
27+
2028
- cd apps/web
2129

2230
- echo "=== INSTALLING DEPENDENCIES ==="

apps/web/drizzle.config.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ export default defineConfig({
66
out: "./src/db/migrations",
77
dbCredentials: {
88
url: process.env.DATABASE_URL!,
9+
ssl: {
10+
rejectUnauthorized: false,
11+
},
912
},
1013
verbose: true,
1114
strict: true,
12-
driverOptions: {
13-
connection: {
14-
ssl: {
15-
rejectUnauthorized: false,
16-
},
17-
},
18-
},
1915
});

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
},
2121
"dependencies": {
2222
"@t3-oss/env-nextjs": "^0.13.8",
23-
"aws-ssl-profiles": "^1.1.2",
2423
"axios": "^1.10.0",
2524
"dotenv": "^17.1.0",
2625
"drizzle-orm": "^0.44.2",
@@ -41,6 +40,7 @@
4140
"drizzle-kit": "^0.31.4",
4241
"eslint": "^9",
4342
"eslint-config-next": "15.3.5",
43+
"postcss": "^8.4.39",
4444
"tailwindcss": "^4",
4545
"typescript": "^5"
4646
}

apps/web/src/db/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import awsCaBundle from "aws-ssl-profiles";
21
import { drizzle } from "drizzle-orm/node-postgres";
32
import { Pool } from "pg";
43
import { env } from "../env";
@@ -7,8 +6,11 @@ import * as schema from "./schema";
76
// Create a connection pool using validated environment variables
87
const pool = new Pool({
98
connectionString: env.DATABASE_URL,
10-
// Use AWS CA bundle for SSL verification
11-
ssl: awsCaBundle,
9+
// AWS RDS uses self-signed certificates
10+
// We need to disable certificate verification but keep SSL encryption
11+
ssl: {
12+
rejectUnauthorized: false,
13+
},
1214
});
1315

1416
// Create the database instance

0 commit comments

Comments
 (0)