I'm working on some automation scripts to bootstrap my application and will be using an auto-scaling group in AWS to spin up/down EC2 instances for my application.
I need to be able to re-create a consistent name for the machine that follows a pattern: MYAPP001
, MYAPP002
, MYAPP003
.
The Question
Is there a way to query meta-data during the user-data bootstrapping phase to determine that this machine that just came up is 002
in the group?
If I can determine this, then I can rename the machine to MYAPP002
.
Scenario to Help Explain
Imagine a 3rd-party service that expects machines to be named MYAPP001
, MYAPP002
, MYAPP003
. In this software, it's OK for a machine to go offline and come back online later with a different IP address. However, you cannot have two different machines talk to this software at the same time with the same host name.