How to use Elastic Beanstalk with an IP Whitelisted API

What it looks like:

How to do it:

  • Step 1: Create a new subnet and give it a suitable CIDR block. I used
  • Step 2: Create a new NAT Gateway in the new subnet. Amazon will create an Elastic IP such as 13.54.86.XX
  • Step 3: Create a Route Table for the new NAT Gateway. This should be configured to send internet traffic out via the Internet Gateway.
Note: Your VPC local route may be different from depending on your VPC configuration.
  • Step 4: Modify the NAT subnet to use your new route table.
  • Step 5: Modify the Main Route Table to direct traffic to your target server via the NAT Gateway and direct other internet traffic via the Internet Gateway.
You can add route multiple IP addresses and ranges to the NAT Gateway



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store