Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS VPC Lambda Function keeps losing internet access

Hope someone can help enlighten me on this issue. I am currently working on a lambda function that utilizes the cloud watch scheduler to check various devices and it is using elasticache to maintain a simple database on the readings.

My problem is that after I shut down my testing at night. I fire up the lambda function in the morning and the function has lost access to the internet. Which is represented by the function timing out. Regularly after a few hour of messing around with my routes and my vpc settings it will start working again. Just to break the following day. Sometimes it works with nat gateway other times with just a nat instance. The changes I typically make to the vpc set up are minor. The pattern for the set up I use is one public and one private and one natgateway.

Update: After not being able to access the internet from my VPC all day yesterday, today is functioning fine. What did I do differently, nothing. When it stops functioning again, probably later today, I will be calling up AWS to see if we can get to the bottom of this.

like image 259
Paul Siskind Avatar asked Apr 12 '16 18:04

Paul Siskind


1 Answers

I've just fixed the same issue with my lambdas - the issue was that I had set the lambda to run in all of my subnets (I have 2 private and 1 public). This knowledgebase article specifies you should run them in private subnets only, which makes sense:

https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/

Go to your lambda page on the AWS console, deselect the public subnet and save and the problem should be solved.

like image 181
Liam Avatar answered Oct 02 '22 05:10

Liam