3 ms·
You connect the same way as you do in a regular app. Which is to say, you open the database connection outside of the request handling method (for example, as a
by ryanworl 8y ago
You connect the same way as you do in a regular app. Which is to say, you open the database connection outside of the request handling method (for example, as a global) and then use it from within the request handling method. When your app wakes up again for another request, the database connection is still open and you just use it.
- qudat 8y agoAs far as I know this works but more as a hack not as a robust officially supported solution.
- scarface74 8y agoHow is that a “hack”? You create your DB and you get a connection string to a publicly accessible database or you create it inside a VPC and you configure your lambda to run inside a subnet within your VPC and you configure your security group. This can all be configured within the console.
- nrb 8y agoThe main issue with this approach is that running your lambda in a VPC results in painfully slow cold starts, on AWS at least.
- paulddraper 8y agoIDK why the parent mentioned VPC. It's not necessary.
- scarface74 8y agoWithout a VPC, how do you not expose your Aurora cluster to the world? https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AuroraPostgreSQL.Security.html https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Auror... Aurora DB clusters must be created in an Amazon Virtual Private Cloud (VPC). To control which devices and Amazon EC2 instances can open connections to the endpoint and port of the DB instance for Aurora DB clusters in a VPC, you use a VPC security group. These endpoint and port connections can be made using Secure Sockets Layer (SSL). In addition, firewall rules at your company can control whether devices running at your company can open connections to a DB instance. For more information on VPCs, see Amazon Virtual Private Cloud (VPCs) and Amazon RDS.