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
Asked
Active
Viewed 168 times
2
-
1[You can use this as reference if you use the NAT Gateway option from Mark B's answer](https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/) – Kaustubh Khavnekar Jan 19 '22 at 19:06
-
Can you provide the error that you were getting? – Allan Chua Jan 20 '22 at 05: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 gateway – samirkrishna cholleti Jan 30 '22 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 Jan 30 '22 at 17:05
2 Answers
4
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.

Mark B
- 183,023
- 24
- 297
- 295
1
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....

Hatim
- 1,116
- 1
- 8
- 14
-
1This is not correct for public subnets. See [this answer](https://stackoverflow.com/a/52994841/17896613) – Kaustubh Khavnekar Jan 19 '22 at 19:03
-
1Thank 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 ? – Hatim Jan 20 '22 at 08:28
-
1That is an internal AWS implementation detail, so unless AWS has publicly disclosed it somewhere, we won't know. – Kaustubh Khavnekar Jan 20 '22 at 08:54
-