-1

I am running a RDS instance which is running under a VPC. I have a lambda which connects to RDS instance for read/write operations. Now I want to assign lambda in same VPC so that it is able to connect with RDS but I don't want my lambda to have public access.

Now, I want to define a public API endpoint using API gateway which can connect to my private lambda inside a VPC. I have read multiple articles and AWS documentation but could not get the exact steps to achieve that. Is that possible? Thanks for any pointers in advance.

Aarkan
  • 3,811
  • 6
  • 40
  • 54
  • What exactly are you struggling with? Creating an api gateway, connecting it to a lambda in a vpc, putting the lambda into a vpc or letting the lambda talk to RDS? – luk2302 Feb 23 '21 at 18:03
  • I am struggling with connecting the api gateway to a lambda in a vpc. – Aarkan Feb 23 '21 at 18:04
  • Why? There should not be anything special to do. The lambda should be integrated just as non-vpc lambda would be. – luk2302 Feb 23 '21 at 18:08
  • The api gives me timeout when I configure it with a lambda inside vpc. I am using console way. – Aarkan Feb 23 '21 at 19:10
  • [AWS - Route from public API Gateway to in-VPC lambda](https://stackoverflow.com/questions/60678826/aws-route-from-public-api-gateway-to-in-vpc-lambda) this post hs very clear pictures how it works under the hood. Nothing special is needed as pointed out by @luk2302. And below is a screenshot how you can do it, it works with both proxy and w/o proxy. I did tested this just now. What you are left with your networking setup and your security groups attached to the lambda. Plus make sure your lamda is sending the correct response if you are using `proxy` integration. – samtoddler Feb 23 '21 at 21:12

1 Answers1

0

You can specify a lambda function within a VPC from this screen, same as you would if the lambda didn't reside within a VPC.

enter image description here

bloodquantum
  • 28
  • 1
  • 3
  • Thanks but it does not work. It gives me a timeout error. – Aarkan Feb 23 '21 at 19:09
  • @Aarkan "It gives me a timeout error." is not a proper error description, what is *it*? What timeout do you get, does the lambda actually get invoked? Does the API gateway have permission to invoke the lambda, etc!? Note that all that should be part of the original question. – luk2302 Feb 24 '21 at 08:37