My goal is to start some EC2 instances that should be managed by an auto-scaling group. All instances should have public IPs.
In my tests, I noticed that depending on the configuration of the AWS account, this is not always possible. In the test account that I can use, some regions have an default VPC. In that regions, I was able to get public IPs.
In other regions, we have no default VPC configured. In that case, it is my understanding that it is not possible to get public IPs. Is that correct?
Also, the AWS documentation mentions the term ClassicLink. From my understanding that concept applies only to old accounts. It would also allow to have public IPs but only if there are VPCs configured where the "ClassicLink" flag is set. (In my account that is not the case, so I could not test it.)
In summery, I wanted to ask if my understanding is correct. Is it true that you can only have public IPs for EC2 instance in an auto-scaling group if at least one of the conditions holds:
- In the region, there exists one default VPC
- You have an old account (supporting EC2-Classic) and in the region there exists at least one VPC where ClassicLink is enabled
(Note that I cannot use an ELB, as the instances are not identical. If an ELB shuffles requests, it would confuse the system, as the sender needs to have control over which instance will handle the request.)
Typically autoscaling groups sit behind a load balancer, AWS ELB. Giving each new instance a public IP isn't typically useful, as you'd then have to communicate the IP address either to DNS or to the client.
However, if you have an edge case where this is useful you simply have your launch configuration assign the instance a public IP. .
Also, in the default VPC, I believe a public IP is assigned to new instance by default, whereas in any VPC you create the default is don't assign a public IP.
You can of course associate an elastic IP with an EC2 instance at any time.
ClassicLink is only used when you have instances outside VPC. I don't know much about AWS outside VPCs as it's so legacy it's not tested in any of the many AWS exams I've done. You're probably best migrating everything to VPCs.