Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to assign a Static IP to a AWS Lambda without VPC?

I am looking to assign a static IP to my Lambda which is being invoked via the API gateway. This is required because, the downstream system that i invoke from this lambda accepts web requests only from a Whitelisted IP.

I am successful in achieving this via the VPC that i associate with my lambda. But VPC introduces a bad cold-start time which sometime ranges 12-16seconds. So i am looking for a way to prevent this cold start from the VPC, but at the same time assign a static IP to the lambda.

like image 411
infernal_lad Avatar asked Jun 19 '19 21:06

infernal_lad


People also ask

Does AWS Lambda require a VPC?

By default, Lambda runs your functions in a secure VPC with access to AWS services and the internet. Lambda owns this VPC, which isn't connected to your account's default VPC. When you connect a function to a VPC in your account, the function can't access the internet unless your VPC provides access.

Can Lambda be outside of VPC?

By default, Lambda functions are not launched within a virtual private cloud (VPC), so they can only connect to public resources accessible through the internet.


1 Answers

You can't assign a public/static IP to any Lambda function.

Your only good option is to deploy into a VPC with an Internet Gateway and configure routing from the Lambda's subnet through a NAT which has an Elastic IP. Then your target host can whitelist the Elastic IP.

Also see:

  • Public IP address for AWS API Gateway & Lambda (no VPC) - Stack Overflow
  • AWS Lambda functions with a static IP – Matthew Leak – Medium
like image 187
jarmod Avatar answered Sep 29 '22 07:09

jarmod