How to attach an Elastic IP to an Elastic Beanstalk app

amazon-beanstalkamazon-elastic-ipamazon-web-services

I can give a single instance an Elastic IP. No problem.

But I have an Elastic Beanstalk app. It can create and remove instances as needed. It has a load balancer. How can I get these features (Elastic IP and Elastic Beanstalk) to work together?

Ultimately, all I want to do is make calls to my server through my domain like this:
mydomain.com/someApiCall
and I don't want to worry about my Elastic IP becoming "detached."

Best Answer

That is currently not possible and actually a limitation of the Elastic Load Balancing (ELB) in use, see e.g. Why does Amazon not allow assigning an Elastic IP to an Elastic Load Balancer?:

The elastic load balancer is simply a collection of individual software load balancers hosted within EC2, with DNS load balancing traffic among them. The pool can contain many IPs, at least one per availability zone, and depending on traffic levels.

D.Svanlunds's answer to Load balancers and elastic IP provides a good summary of why ELB is designed this way, and Shlomo Swidler's The “Elastic” in “Elastic Load Balancing”: ELB Elasticity and How to Test it provides an early but in-depth analysis of the ELB architecture and the implications for testing a web application in this context.


Update

Regarding your comment: You are communicating with your AWS Elastic Beanstalk application via the DNS name mapped to the Elastic Load Balancer, to which you can map a CNAME record in turn as usual, see Overview of Elastic Load Balancing:

Elastic Load Balancing automatically generates a DNS name for each load balancer. You can map any other domain name (such as www.example.com) to the automatically generated DNS name using CNAME or use an Amazon Route 53 alias for the load balancer's DNS name.

Further details can be found in Using Domain Names With Elastic Load Balancing, which describes how to associate your Elastic Load Balancing instance with a custom domain name — including subdomain names and the zone apex.