DEV Community

Alex
Alex

Posted on

Set Static Outgoing IP for AWS Lambda

Having a static outgoing IP for your AWS Lambda function (or any AWS instance) is a common use-case when the third-party you're trying to access data from imposes a restriction that they only accept requests from whitelisted IP addresses. By default, Lambda does not assign a static outgoing IP address and you can't simply assign an AWS elastic IP address to the Lambda function as you could for an AWS EC2 instance.


For Lambda, the process is a little more complex. You must:

  1. Create an AWS Virtual Private Cloud (VPC)
  2. Create public and private subnets within the VPC
  3. Place your Lambda function in the private subnet, and a NAT gateway in the public subnet
  4. The NAT gateway is assigned the static Elastic IP, which Lambda routes traffic too
  5. The NAT gateway then routes traffic to the Internet gateway which passes that traffic onto our third-party endpoint with a static outgoing IP

I walk through everything in my YouTube series, explaining how to create it manually and then automatically with AWS Cloudformation, explaining each component and the values chosen along the way.


If you find the video helpful you can greatly help me by doing one or all of the following:


Any questions or requests, just leave a comment.

Top comments (0)