Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API Gateway+Lambda+VPC timeout issue

Good morning, Could you please help us with next problem: I have an API Gateway + Java Lambda Handler. this Lambda uses httpconnection to get some Internet REST API.

when we use this Lambda without VPC it works fine. but when we are using VPC with configured internet access - sometimes Lambda fails with timeout errors. it fails in 20% of all requests (80% requests works fine) with next errors at log.

REPORT RequestId: 16214561-b09a-11e6-a762-7546f12e61bd Duration: 15000.26 ms Billed Duration: 15000 ms Memory Size: 512 MB Max Memory Used: 47 MB

09:57:49
2016-11-22T09:57:49.245Z 16214561-b09a-11e6-a762-7546f12e61bd Task timed out after 15.00 seconds

According to my logs lambda cannot send GET request. I'm not sure where the problem at. Is this Lambda issue, VPC issue or some cofiguration issue. Also I did try many different REST Api endpoints, so it's definetly not an endpoint issue.

Appreciate any help.

like image 957
Svyatoslav Babych Avatar asked Oct 20 '25 13:10

Svyatoslav Babych


1 Answers

When you place a Lambda function inside your VPC it will not have access to anything outside the VPC. To enable your Lambda function to access resources outside the VPC you have to add a NAT Gateway to your VPC.

like image 63
Mark B Avatar answered Oct 23 '25 04:10

Mark B