How do I assign a static source IP address for all instances in a load-balanced Elastic Beanstalk environment?

2 minute read

I want to assign a single static IP address to my load balanced AWS Elastic Beanstalk environment to identify traffic coming from it.

Short description

You can use a network address translation (NAT) gateway to map multiple IP addresses into a single, publicly exposed IP address. When your Elastic Beanstalk environment uses a NAT gateway, the backend instances in your environment are launched in private subnets. Elastic Beanstalk routes outbound traffic through the NAT gateway. You can identify the source of the outbound traffic from the backend instances by the Elastic IP address. The Elastic IP address is a static IP address required by the NAT gateway.


Elastic Beanstalk launches your Amazon Elastic Compute Cloud (Amazon EC2) instances into private subnets. These private subnets use a NAT gateway with an attached Elastic IP address as a default route. The load balancer is in public subnets. Elastic Beanstalk routes all external traffic to and from the load balancer through an internet gateway.

Important: Before getting started, set up a NAT gateway.

  1. Open the Elastic Beanstalk console.
  2. Choose Create New Application, and then complete the steps to create your application.
    Note: If you're using an existing application, then skip to step 3 and configure your environment.
  3. Choose Actions, and then choose Create environment.
  4. Choose Web server environment, and then choose Select.
  5. Choose the options in the Environment information and rest of the Platform and Application Code sections based on the needs of your environment.
  6. Choose Configure more options.
  7. For Configuration presets, choose High availability. This sets your environment to a load-balanced environment.
  8. For the Network card, choose Edit, and then edit as follows:
    • For VPC, choose your VPC.
    • In the Load balancer settings section, for Visibility, choose Public.
    • In the Load balancer subnets table, choose the public subnets.
    • In the Instance settings section, clear Public IP address.
    • In the Instance subnets table, choose only private subnets with the NAT gateway that you set up earlier
  9. Choose Save.
  10. Choose Create environment.

The Elastic Beanstalk environment that you created now has all outbound traffic originating from a single Elastic IP address.

AWS OFFICIALUpdated a year ago