Issue with lambda when connecting to vpc for static ip

0

Hello All, I have created my lambda function with serverless framework , and want to add it to a static IP for other service use

I have configured everything acc to aws blog for static ip
But when I am attaching than VPC to my lambda , my lambda function stope behaving normally , it gives response time out issue with 502 status

And when I detach the VPC its works fine

1 Answer
0

Hi there,

I understand that you have placed your Lambda inside a VPC in order to assign it a static IP, however you are observing a 502 time out error as a result.

Since the timeout error only occurs when you place the Lambda inside your VPC, this suggests that there may be a misconfiguration in your Lambda-VPC setup. To resolve this, please ensure that your setup is configured as follows:

 1. Your Lambda must reside inside a private subnet (s). A private subnet is one which has a route to a NAT Gateway in it's routing table. Please review the subnets in which you have placed your Lambda function, and ensure that they are private. 

 2. If you already have a route to the NAT Gateway, ensure that the NAT Gateway itself resides inside a public subnet. A public subnet is one which is has  a route to an Internet Gateway in its routing table. Please review the subnet in which you have placed your NAT Gateway, and ensure that it is public.  

In summary, when you place a Lambda function inside a VPC, it must be configured as mentioned above for it to be able to access public endpoints (over the internet), otherwise, a time out error is expected.

For more detailed guidance on setting up your Lambda with a VPC, please see: https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/

Kind Regards,

Ahmad

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions