You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to deploy Aerie to K8S (AWS EKS) and use Aurora Serverless as the databsae. I've got the pods running but It looks like by default PostgreSQL connections do not use SSL. Which is required by default in RDS.
For example the use of pg.Pool in aerie-action does not provide an option to pass in the ssl: true. Is this consistent across all Aerie services? :sadtrombones:
import type { Pool } from "pg";
import pg from "pg";
import { configuration } from "./config";
import logger from "./utils/logger";
const { AERIE_DB, AERIE_DB_HOST, AERIE_DB_PORT, ACTION_DB_USER, ACTION_DB_PASSWORD } = configuration();
export class ActionsDbManager {
private static pool: Pool;
static getDb(): Pool {
// singleton DB pool, shared by the process
// saved as a static to prevent accidental re-initialization
if (ActionsDbManager.pool) return ActionsDbManager.pool;
try {
logger.info(`Creating PG pool`);
ActionsDbManager.pool = new pg.Pool({
host: AERIE_DB_HOST,
port: parseInt(AERIE_DB_PORT, 5432),
database: AERIE_DB,
user: ACTION_DB_USER,
password: ACTION_DB_PASSWORD,
max: 3,
min: 3,
});
return ActionsDbManager.pool;
} catch (error) {
logger.error(error);
throw error;
}
}
}
Describe the feature request
Please make the use of SSL in Postgres configurable. This will open up options for it's use typical cloud based deployments in which postgres is managed externally to Aerie itself.
Hi @mkochco , I'd be interested in contributing to this issue. I can investigate PostgreSQL connection handling across the affected services and propose configurable TLS support with backward compatibility and regression tests. Is this available for an external contribution, and is there a preferred configuration approach?
@nikhilred2619 - the original post under-scoped the changes required. Here's what I think is involved with enabling SSL/TLS to Postgres in plandev.
Goal
Add one set of environment variables that all services use to turn on TLS for Postgres, with a choice of whether to verify the server certificate. When
the variables are unset, behaviour stays exactly as it is today, so existing docker-compose deployments are unaffected.
Add sslMode and sslRootCert fields to the three PostgresStore records (merlin-server, scheduler-server, workspace-server, each under .../server/config/PostgresStore.java). The two workers import their server module's record, so they pick the fields up for free. Populate them from the
environment in each loadConfiguration().
In each driver, set the extra data source properties only when the values are present:
pgjdbc reads PEM bundles directly, so you don't need to convert the bundle to a JKS truststore.
Optional: move the duplicated Hikari setup into a small shared helper so the five drivers can't drift apart.
Node services (node-postgres)
These files create a pg.Pool:
action-server/src/db.ts
action-server/src/threads/worker.ts
sequencing-server/src/db.ts
node-postgres doesn't use sslmode and takes an ssl object instead, so add a shared helper that converts the env vars (the action server would read
them through configuration() in action-server/src/config.ts, the sequencing server through getEnv() in sequencing-server/src/env.ts):
Hasura connects using PLANDEV_DATABASE_URL and HASURA_GRAPHQL_METADATA_DATABASE_URL. Both are libpq-style URLs, so TLS should work by adding query
parameters (the compose file already appends ?options=... to PLANDEV_DATABASE_URL, so the SSL parameters go on with &):
This most likely needs documentation and deployment manifest changes rather than code changes, but it should be tested with Hasura OSS. If Hasura OSS
doesn't honour sslrootcert in the URL, Hasura would need its ssl_configuration metadata block, which may be limited to Hasura Cloud/EE. deployment/plandev_db_migration.py runs migrations through the Hasura CLI, so it inherits whatever Hasura is configured with.
Out of this repo
plandev-gateway also connects to Postgres directly and will need the same Node change.
Docs and deployment
Add the two variables to deployment/Environment.md
Add commented-out examples to docker-compose.yml, deployment/docker-compose.yml and deployment/kubernetes/*, including mounting the CA bundle
(a ConfigMap or Secret in Kubernetes)
Note that on RDS/Aurora, the server side is controlled by rds.force_ssl in the cluster parameter group
Testing
Existing tests pass unchanged with the variables unset
For a manual or CI check, run Postgres with ssl=on and a self-signed CA. Confirm each mode connects, and that verify-full fails when the
hostname doesn't match
On a live connection, SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid(); returns t when TLS is in use
Thank you for the detailed breakdown. This is very helpful.
I'd be happy to work on the implementation following the proposed configuration and compatibility requirements.
Given the changes across Java services, Node services, Hasura, and deployment configuration, would you prefer the work to be submitted as a series of focused PRs or as a single implementation?
If this issue is available for me to take on, I can start with the shared TLS configuration and service-level changes, followed by the deployment updates and regression tests.
Hi @nikhilred2619, I'm not the code owner in this case. I would guess a single PR to avoid inconsistencies in runtime, or having blocking PRs.
@dandelany could you weigh in on preferred process here? @nikhilred2619 has offered to implement this against the plan above. Is a single PR against develop fine, or would you prefer it split (Java drivers, Node services, docs/deployment)? Any objection to the PLANDEV_DB_SSL_MODE / PLANDEV_DB_SSL_ROOT_CERT naming?
Hi @nikhilred2619 and @mkochco - apologies for slow responses, we're a small team & have been busy with review & testing activities around our latest release. A few thoughts:
Overall I agree with @mkochco 's outlined approach above, including the variable names. We'd welcome a good, well-tested PR from @nikhilred2619 for this feature.
One PR for most of this work is fine - although the changes to plandev-gateway and plandev-docs will need to be separate PRs since they are in other repos.
The implementation should be opt-in as described and prioritize backwards-compatibility for existing users.
For easiest review it should also minimize any architectural changes and stay as limited in scope as possible. Eg. above you mention adding a shared helper for action-server and sequencing-server - I'm not sure we have a good package for sharing code between them today, so it may be simpler to just add the same function in both places.
Separately - we currently have some CI issues with tests & code scanning not running correctly on fork PRs. I will work on resolving that issue on Monday, but just FYI tests may not initially pass on the PR.
Activity
nikhilred2619 commentedon Nov 7, 2026
Hi @mkochco , I'd be interested in contributing to this issue. I can investigate PostgreSQL connection handling across the affected services and propose configurable TLS support with backward compatibility and regression tests. Is this available for an external contribution, and is there a preferred configuration approach?
mkochco commentedon Nov 7, 2026
@nikhilred2619 - the original post under-scoped the changes required. Here's what I think is involved with enabling SSL/TLS to Postgres in plandev.
Goal
Add one set of environment variables that all services use to turn on TLS for Postgres, with a choice of whether to verify the server certificate. When
the variables are unset, behaviour stays exactly as it is today, so existing docker-compose deployments are unaffected.
Proposed configuration
PLANDEV_DB_SSL_MODEdisable,require,verify-ca,verify-fullPLANDEV_DB_SSL_ROOT_CERTrequire: the connection is encrypted, but the server certificate is not verified.verify-ca: the connection is encrypted and the certificate chain is checked againstPLANDEV_DB_SSL_ROOT_CERT.verify-full: same asverify-ca, plus the hostname is checked. This is the recommended setting for production.verify-*is set butPLANDEV_DB_SSL_ROOT_CERTis missing or unreadable.The mode names match libpq and pgjdbc, so they mean the same thing in every service.
Java services (pgjdbc via HikariCP)
These files create a
HikariConfigwithPGSimpleDataSource:merlin-server/src/main/java/gov/nasa/ammos/plandev/merlin/server/AerieAppDriver.javamerlin-worker/src/main/java/gov/nasa/ammos/plandev/merlin/worker/MerlinWorkerAppDriver.javascheduler-server/src/main/java/gov/nasa/ammos/plandev/scheduler/server/SchedulerAppDriver.javascheduler-worker/src/main/java/gov/nasa/ammos/plandev/scheduler/worker/SchedulerWorkerAppDriver.javaworkspace-server/src/main/java/gov/nasa/ammos/plandev/workspace/server/WorkspaceAppDriver.javaChanges:
Add
sslModeandsslRootCertfields to the threePostgresStorerecords (merlin-server,scheduler-server,workspace-server, each under.../server/config/PostgresStore.java). The two workers import their server module's record, so they pick the fields up for free. Populate them from theenvironment in each
loadConfiguration().In each driver, set the extra data source properties only when the values are present:
pgjdbc reads PEM bundles directly, so you don't need to convert the bundle to a JKS truststore.
Optional: move the duplicated Hikari setup into a small shared helper so the five drivers can't drift apart.
Node services (node-postgres)
These files create a
pg.Pool:action-server/src/db.tsaction-server/src/threads/worker.tssequencing-server/src/db.tsnode-postgres doesn't use
sslmodeand takes ansslobject instead, so add a shared helper that converts the env vars (the action server would readthem through
configuration()inaction-server/src/config.ts, the sequencing server throughgetEnv()insequencing-server/src/env.ts):Each pool then gets
ssl: pgSslConfig().Hasura
Hasura connects using
PLANDEV_DATABASE_URLandHASURA_GRAPHQL_METADATA_DATABASE_URL. Both are libpq-style URLs, so TLS should work by adding queryparameters (the compose file already appends
?options=...toPLANDEV_DATABASE_URL, so the SSL parameters go on with&):This most likely needs documentation and deployment manifest changes rather than code changes, but it should be tested with Hasura OSS. If Hasura OSS
doesn't honour
sslrootcertin the URL, Hasura would need itsssl_configurationmetadata block, which may be limited to Hasura Cloud/EE.deployment/plandev_db_migration.pyruns migrations through the Hasura CLI, so it inherits whatever Hasura is configured with.Out of this repo
plandev-gatewayalso connects to Postgres directly and will need the same Node change.Docs and deployment
deployment/Environment.mddocker-compose.yml,deployment/docker-compose.ymlanddeployment/kubernetes/*, including mounting the CA bundle(a ConfigMap or Secret in Kubernetes)
rds.force_sslin the cluster parameter groupTesting
ssl=onand a self-signed CA. Confirm each mode connects, and thatverify-fullfails when thehostname doesn't match
SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid();returnstwhen TLS is in usenikhilred2619 commentedon Nov 7, 2026
Hi Mark (@mkochco),
Thank you for the detailed breakdown. This is very helpful.
I'd be happy to work on the implementation following the proposed configuration and compatibility requirements.
Given the changes across Java services, Node services, Hasura, and deployment configuration, would you prefer the work to be submitted as a series of focused PRs or as a single implementation?
If this issue is available for me to take on, I can start with the shared TLS configuration and service-level changes, followed by the deployment updates and regression tests.
Thanks again for outlining the scope!
mkochco commentedon Nov 7, 2026
Hi @nikhilred2619, I'm not the code owner in this case. I would guess a single PR to avoid inconsistencies in runtime, or having blocking PRs.
@dandelany could you weigh in on preferred process here? @nikhilred2619 has offered to implement this against the plan above. Is a single PR against develop fine, or would you prefer it split (Java drivers, Node services, docs/deployment)? Any objection to the PLANDEV_DB_SSL_MODE / PLANDEV_DB_SSL_ROOT_CERT naming?
dandelany commentedon Nov 13, 2026
Hi @nikhilred2619 and @mkochco - apologies for slow responses, we're a small team & have been busy with review & testing activities around our latest release. A few thoughts:
plandev-gatewayandplandev-docswill need to be separate PRs since they are in other repos.action-serverandsequencing-server- I'm not sure we have a good package for sharing code between them today, so it may be simpler to just add the same function in both places.nikhilred2619 commentedon Nov 30, 2026
Hi @mkochco and @dandelany,
Sorry for the delay, and thank you for your guidance and patience.
I've completed the PostgreSQL TLS implementation, including regression testing, live certificate verification, and deployment documentation.
I've submitted the three PRs as suggested:
Please let me know if any adjustments are needed. I'm happy to address your feedback.
Thanks again!