Sending your outbound Lambda traffic through a static IP address might sound difficult, but it’s easier than you think.

Serverless is great. There, I said it.

At this point, I’m not sure many people would argue with me on that, but to each their own.

Serverless provides us with the luxury of fast compute in the cloud without having to worry about machines or state. Pretty awesome.

But since we don’t have to worry about machines or state, a handful of problems that we didn’t have before have presented themselves. Things like  monitoring your app become more difficult. You also have all the difficulties of distributed computing thrown into the mix.

But what about a static IP? There are a multitude of reasons why you would need a static IP address, like integrating with a third party or connecting to an internal network. These tasks typically need to whitelist IP addresses for security measures.

It’s hard to argue against security, so we must come up with a way to get Lambda functions to send external traffic from a known IP address.

Setup

Full disclosure: This has been a solved problem for a while. When I was doing my initial research on how to get Lambda to use a static IP, I used  this tutorial and  this one to work my way through the console and set it up.

But I am a boy scout. I like to leave things better than how I found them.

I’ve taken the tutorials, comments, trial and error, and  created a SAM template that will automatically deploy everything you need into the cloud with minimal setup.

Here is what you need:

  • AWS CLI configured on your machine
  • SAM CLI
  • An  S3 Bucket in your account to deploy resources into
  • A  CIDR block for the network you’re about to create

#programming #serverless #aws

How To Configure a Static IP for Your Serverless App
1.55 GEEK