3

Is there a logical way to have sequentially numbered hostnames with servers that are autoscaling but not sequentially killed?

So if server13 is killed and server14/15 are alive, and the cluster upscales with 2 servers it will add a server with hostnames server13 and server16?

ujjain
  • 3,963
  • 15
  • 50
  • 88

1 Answers1

2

If hostname refers to only the output of the hostnamecommand (on the instance itself), assign a instance profile that allows for the instance to query existing autoscaling group members and their tags using AWS CLI. Then use a tag to denote the server hostname or index, and upon autoscaling adding a new instance, have it look at the current list of servers and assign a missing hostname to it. You can use UserData to fire up this script.

If hostname refers to an actual DNS name (in Route 53): you could maybe utilize an autoscaling lifecycle hook and have it fire a lambda that does the appropriate Route 53 record set changes (similar logic as above).

Jukka
  • 686
  • 3
  • 4