Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using an elastic ip in a CloudFormation template

"ServerEIP" : {
 "Type" : "AWS::EC2::EIP",
 "Properties" : {

Later on I have an EC2 Instance

"Server" : {
  "Type" : "AWS::EC2::Instance",

Because I want to make the IP Address of multiple instances known between each other, see here, I am using EIPAssociation to actually bind the Elastic IP to the EC2 instance:

"ServerIPAssoc" : {
     "Type" : "AWS::EC2::EIPAssociation",
     "Properties" : {
         "InstanceId" : { "Ref" : "Server" },
         "EIP" : { "Ref" : "ServerEIP" }

Now in my startup script on the instance which runs as init.d-script, I am reading the "public hostname" of the instance:


Now what happens here is that I initially seem to receive an incorrect hostname! Most likely the one for the initial public ip address that is assigned to the EC2 instance before the ElasticIP association takes place!

I already tried to put in some wait to let the public hostname settle, but it didn't have an effect when the sleep was not overly long (i.e. below 30 seconds).

Is there any other way I can ensure that I get the "public hostname" from the elastic ip address and not the one that is thrown away?!?

share|improve this question
up vote 1 down vote accepted

In the end I used a few seconds delay during startup to allow the actual ip/hostname to settle before making the REST call during startup!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.