Select Language:
When upgrading your Lambda functions from Node.js 18.x to newer versions like 20.x or 22.x, you might run into connectivity issues with your RDS PostgreSQL database. This problem happens because of a change in how newer Node.js runtimes handle certificates in Lambda.
In earlier versions, like Node.js 18.x and below, Lambda automatically loaded Amazon-specific CA certificates necessary for connecting to RDS. But starting with Node.js 20.x, Lambda no longer loads these additional certificates by default. This change can cause your database connections to fail.
The solution is straightforward. First, you need to set the environment variable called NODE_EXTRA_CA_CERTS
in your Lambda function’s configuration. Point this variable to the certificate file located at /var/runtime/ca-cert.pem
. Doing this will make Lambda load the same certificates it previously loaded in older versions, restoring proper connectivity.
For better performance and security, you can also bundle only the specific certificates your Lambda function needs—like the RDS CA certificate—and include it in your deployment package. Then, set the NODE_EXTRA_CA_CERTS
environment variable to the path where you include your certificate, such as /var/task/certificates/rds.pem
. This way, your function loads just the necessary certificates instead of all default ones.
While AWS hasn’t announced specific updates to CloudFormation templates for this change, it’s common for AWS to update their resources to support new runtimes before older ones are deprecated. You don’t have to wait for an official template update; you can simply modify your existing CloudFormation template to specify the newer Node.js runtime and add the environment variable configuration for your certificates.
This quick adjustment will solve your RDS connection issues when upgrading to newer Node.js versions in AWS Lambda.