title: How to properly connect AWS Lambda to RDS in VPC?
body: <p>I am trying to build a graphQL API with <a href="https://serverless.com/framework/docs/providers/aws/" rel="noreferrer">Serverless Framework</a> on <a href="https://aws.amazon.com/lambda/" rel="noreferrer">AWS-Lambda</a> using <a href="https://www.apollographql.com/docs/apollo-server/servers/lambda.html" rel="noreferrer">Apollo-Server-Lambda</a> etc. I need to use a not publicly available PostgreSQL RDS instance. </p>
  
  <p>I can get lambdas up and running and sending back requests when not in VPC. I can get a Postgres RDS Database up and running and connected to PgAdmin (when in publicly available mode).</p>
  
  <p>The problem is once I make the RDS Postgres 'non public' and try to get all these pieces talking together I fail. </p>
  
  <p>I have tried multitude of different approaches. </p>
  
  <p>This is regularly portrayed as magic. It is wonderfully written <a href="https://gist.github.com/reggi/dc5f2620b7b4f515e68e46255ac042a7" rel="noreferrer">https://gist.github.com/reggi/dc5f2620b7b4f515e68e46255ac042a7</a></p>
  
  <p>I could not get access to Postgres with my lambdas using this. So my first question.</p>
  
  <p>Do I need a NAT gateway for incoming (ingress) api calls to lambdas in a VPC?
  My current understanding is that maybe I only need a NAT gateway for my lambdas to make outgoing calls to other api's out of aws or things like S3. Is this correct?</p>
  
  <p>Next up. I have made a security group for my lambdas and have added this security group to the inbound list for the security group that was created for RDS. My understanding is this is how the lambdas should gain access to RDS. I have not had such luck. Maybe this is related to public or non public subnets? Maybe this is related to my understanding of the necessity of a NAT?</p>
  
  <p>Basically the only visibility I have been able to get is Lambdas timing out after 20 or 30 seconds depending on my limit when they are trying to connect to postgres in private. Cloudwatch logs reveal nothing else. </p>
  
  <p>Lastly, for now , what is the best way to connect my dev machine to Postgres once it is 'not public'? I have my machines IP listed for inbound TCP/IP to port 5432 to postgres in the RDS security group but that does not seem to give me the access I was hoping for. Do I really need a VPN connected to VPC? Whats the simplest way?</p>
  
  <p>I have done this tutorial with basic alterations for Postgres <a href="https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds.html" rel="noreferrer">https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds.html</a></p>
  
  <p>I have read and considered answers from this question &amp; more
  <a href="https://stackoverflow.com/questions/37030704/allow-aws-lambda-to-access-rds-database">Allow AWS Lambda to access RDS Database</a></p>
  
  <p>I have had many success-full deployments with serverless framework with many variations on serverless.yml config to try these options or else I would show a specific one I thought was failing but this is more broadly that I cant seem to grasp exactly how all these VPC, security groups, routing tables etc are supposed to interact. </p>
  
  <p>Any help greatly appreciated!</p>