I am working on a AWS lambda in which i want to use DynamoDB and a VPC(Amazon elasticcache for redis). But I was getting time out error when trigger lambda
4
- 1You can use this as reference if you use the NAT Gateway option from Mark B's answerKaustubh Khavnekar– Kaustubh Khavnekar2022-01-19 19:06:30 +00:00Commented Jan 19, 2022 at 19:06
- Can you provide the error that you were getting?Allan Chua– Allan Chua2022-01-20 05:56:13 +00:00Commented Jan 20, 2022 at 5:56
- @AllanChua I am not getting any error simply my lambda is getting 30 seconds timeout. And I don't want to increase my lambda time >30 because We have a 30 seconds limit in API gatewaysamirkrishna cholleti– samirkrishna cholleti2022-01-30 11:05:29 +00:00Commented Jan 30, 2022 at 11:05
- @samirkrishnacholleti, can you share what are you trying to achieve in the lambda? which language of the SDK did you use? Are you using transactions?Allan Chua– Allan Chua2022-01-30 17:05:03 +00:00Commented Jan 30, 2022 at 17:05
Add a comment |
2 Answers
You either need to create a DyanmoDB VPC Endpoint in the VPC, or add a NAT Gateway to the VPC, and only deploy the Lambda function in subnets that have a route to the NAT Gateway.
Comments
Depending on the VPC configuration subnet/Security Group of your lambda,
If your lambda is in a private subnet :
- If you want a secure internal way, you can pass with VPC endpoint
- Else if you want to pass with internet, you must have a NAT Gateway.
Check also the security groups/NACLS....
4 Comments
Kaustubh Khavnekar
This is not correct for public subnets. See this answer
Hatim
Thank you @KaustubhKhavnekar, I didn't know the lambda don't have a public ip, I don't understund why ? but I will change my answer based on that, that means when you deploy a default lambda (without vpc config) they deploy it in a private subnet + NAT ?
Kaustubh Khavnekar
That is an internal AWS implementation detail, so unless AWS has publicly disclosed it somewhere, we won't know.
Hatim
perfect ! Thank you