Skip to content

fix(cdk): connect the cron lambdas to RDS over verified TLS - #1349

Merged
NiallJoeMaher merged 2 commits into
developfrom
fix/cron-lambda-rds-tls
Nov 17, 2026
Merged

NiallJoeMaher merged 2 commits into
developfrom
fix/cron-lambda-rds-tls

Conversation

@NiallJoeMaher

@NiallJoeMaher NiallJoeMaher commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request details

The RSS fetcher and vote-reconcile lambdas have failed on every run since the database moved to Postgres 15, in both accounts. Postgres 15 on RDS turns rds.force_ssl on, and the lambdas connected without TLS:

ERROR Fatal error: no pg_hba.conf entry for host "…", user "…", database "…", no encryption

So no feed source has been ingested, and vote counts have not been reconciled, since then.

 rssFetcher / voteReconcile
   read /env/db/dbUrl from SSM
-  connect without TLS            -> rejected by RDS
+  connect with TLS, verify the server certificate
+    CA bundle: /var/runtime/ca-cert.pem (NODE_EXTRA_CA_CERTS)

 RDS instance
-  server certificate under rds-ca-2019 (expired August 2024)
+  server certificate under rds-ca-rsa2048-g1
  • Lambdas: ssl: true on the pg client. Node 20+ Lambda runtimes no longer trust the Amazon RDS CAs by default, so the two lambdas load the CA bundle that ships in the runtime.
  • RDS: the instance still serves a certificate issued under rds-ca-2019, which expired in August 2024, so a verifying client fails with certificate has expired. The stack now sets rds-ca-rsa2048-g1. Postgres 15.17 supports rotating the certificate without a restart.

Evidence

  • Before: both lambdas log the no encryption error above on every scheduled run.
  • Lambda change only: the connection is encrypted and fails at verification with certificate has expired, which is the expired instance certificate.
  • After, deployed to the Dev account:
    • vote reconcile returns All counts in sync;
    • the RSS fetcher returns sourcesProcessed: 34, articlesAdded: 195, with one source answering 403;
    • the instance reports rds-ca-rsa2048-g1 and the new parameter group in-sync. It is the same instance (creation time unchanged), and the parameter group restart took about 17 seconds.
  • The first Dev deploy failed and rolled back because RDS rejects a parameter group description with non-ASCII characters. The second commit makes the description ASCII.

Any Breaking changes

Door: two-way. No schema change. The certificate authority can be set back, and the lambdas only take effect on a CDK deploy.

Blast radius: contained.

  • Deploy order matters: the storage stack (certificate) before the cron stack.
  • The storage stack deploy also attaches the rds.force_ssl parameter group that is already in develop but has never been deployed. Attaching it restarts the instance once (about 17 seconds on Dev).
  • Clients that connect with sslmode=require and do not verify the certificate, which includes the app, are unaffected by the certificate change.
  • Once the lambdas work again, feed ingestion and vote reconciliation resume after a long gap.

Associated Screenshots

None

[Optional] What gif best describes this PR or how it makes you feel

None

The RSS fetcher and vote-reconcile lambdas connected without TLS, which
RDS has rejected since the Postgres 15 upgrade turned rds.force_ssl on,
so both have failed on every run. They now use TLS and verify the server
certificate against the RDS CA bundle that ships in the Lambda runtime.

Verification needs a valid server certificate: the instance still served
one issued under rds-ca-2019, which expired in August 2024. Move it to
rds-ca-rsa2048-g1 (Postgres 15 rotates without a restart).
@NiallJoeMaher
NiallJoeMaher requested a review from a team as a code owner November 17, 2026 14:59
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
codu Ready Ready Preview Nov 17, 2026 3:18pm UTC

Request Review

@github-actions

Copy link
Copy Markdown

Uh oh! @vercel[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The RDS instance now specifies a CA certificate. The RSS fetcher and vote reconciliation Lambdas receive the CA certificate environment setting and enable SSL in their PostgreSQL client configurations.

Changes

RDS TLS Configuration

Layer / File(s) Summary
Set the RDS CA
cdk/lib/storage-stack.ts
The RDS instance configuration now specifies RDS_CA_RSA2048_G1. The parameter-group description uses ASCII characters.
Configure Lambda database connections
cdk/lib/cron-stack.ts, cdk/lambdas/rssFetcher/index.ts, cdk/lambdas/voteReconcile/index.ts
The two Lambdas receive NODE_EXTRA_CA_CERTS set to /var/runtime/ca-cert.pem. Their PostgreSQL clients now set ssl: true.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · up to e0c6e

This change makes the RSS fetcher and vote-reconcile Lambdas connect to RDS over verified TLS and moves the database to a non-expired certificate authority. I found no merge-blocking problem. Deploy the storage stack before the cron stack, and plan for the instance restart that attaching the force_ssl parameter group causes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the cron Lambdas (RSS fetcher and vote reconcile) now connect to RDS over TLS with certificate verification. It matches the raw summary (ssl: true, NODE_EXTRA_CA_CERTS…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the template's sections (Pull Request details, Any Breaking changes, Associated Screenshots, and the optional gif section). It explains the root cause (Postgres 15 on RDS enabl…
Full details: Title check

Explanation

The title names the main change: the cron Lambdas (RSS fetcher and vote reconcile) now connect to RDS over TLS with certificate verification. It matches the raw summary (ssl: true, NODE_EXTRA_CA_CERTS bundle, CA update to rds-ca-rsa2048-g1) and the stated objectives. It is concise and follows the conventional commit style.

Full details: Description check

Explanation

The description follows the template's sections (Pull Request details, Any Breaking changes, Associated Screenshots, and the optional gif section). It explains the root cause (Postgres 15 on RDS enables rds.force_ssl, and the lambdas connected without TLS), the fix (ssl: true, CA bundle via NODE_EXTRA_CA_CERTS, and the move to rds-ca-rsa2048-g1), deployment order, and the expected impact. It includes concrete before/after evidence from a Dev deploy. The template's 'Fixes #(issue)' line is missing, so no linked issue is referenced. Breaking changes and screenshots are addressed (None for screenshots). The description is thorough and mostly complete, so this check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the roots below,
The database links now safely flow.
Two fetchers greet the CA with care,
While SSL guards the paths they share.
I twitch my nose and hop away,
With carrots for this TLS day.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ebb7b70-b9ee-4b0e-8de8-77f06432c401
Commits

Reviewing files that changed from the base of the PR and between e45c117 and e0c6e19.

Files selected for processing: 1

  • cdk/lib/storage-stack.ts
Files skipped from review as they are similar to previous changes: 1

  • cdk/lib/storage-stack.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown

Uh oh! @coderabbitai[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

1 similar comment
@github-actions

Copy link
Copy Markdown

Uh oh! @coderabbitai[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

RDS rejects a parameter group description containing non-ASCII
characters, so the stack could not deploy.
@github-actions

Copy link
Copy Markdown

Uh oh! @vercel[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@github-actions

Copy link
Copy Markdown

Uh oh! @coderabbitai[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@github-actions

Copy link
Copy Markdown

Uh oh! @vercel[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@github-actions

Copy link
Copy Markdown

Uh oh! @coderabbitai[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

1 similar comment
@github-actions

Copy link
Copy Markdown

Uh oh! @coderabbitai[bot], the image you shared is missing helpful alt text. Check #1349 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@NiallJoeMaher
NiallJoeMaher merged commit 4c0de11 into develop Nov 17, 2026
6 of 8 checks passed
@NiallJoeMaher
NiallJoeMaher deleted the fix/cron-lambda-rds-tls branch November 17, 2026 15:28

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — e0c6e195 Deployed Nov 17, 2026 by vercel[bot]
production — e0c6e195 Deployed Nov 17, 2026 by NiallJoeMaher via e2e #660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant