Yes you can. You are supposed to instantiate those connections outside the function call as per the docs.
Example: https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds-deploym...
Re:The hidden costs of serverless
by alexnewman on Friday January 19, 2018 @05:49PM
(#16190666)
Tried and failed
Re:The hidden costs of serverless
by jdchernofsky on Thursday January 18, 2018 @01:12PM
(#16179648)
The problem on Lambda is that you can’t persist any application state beyond the function call itself, so you can’t take advantage of connection pooling the way you normally would in a self-contained webapp. Without some kind of middleman, each database call will require you to open a new connection to the database and close it when the function ends. This becomes catastrophic for the database server as the number of requests scales up.