2
votes

My website is running behind an AWS Classic Load Balancer. It has some scaling policies and it launches some new EC2 instances when it has to.

Is it possible to have the range of public IP addresses that will be used for the EC2 instances when they will be launched by the load balancer ?

2
What do you mean, "used for the instances?" For outgoing requests from the instances to (e.g.) 3rd party APIs? If so, yes: serverfault.com/q/759998/153161 - Michael - sqlbot

2 Answers

0
votes

Is it possible to have the range of public IP addresses that will be used for the EC2 instances when they will be launched by the load balancer

Not to my knowledge. Public IP addresses are assigned automatically by AWS from a pool of addresses and I do not believe it is possible to know in advance what address will be assigned to your EC2.

See here for more details

Why do you need the ip address of the new instances, out of interest? Are you trying to dynamically provision access to resources on them as part of your ec2 startup process?

0
votes

This is technically possible if you use Elastic IPs. While you can't create a pool for your scaling policies to pull from, you can create several EIPs and configure Lambda scripts that trigger during scaling events, and assign available EIPs to the new instances using the associateAddress API.

Alternatively, this seems like a similar problem, and maybe a useful solution for you.