4

I'm maintaining a fairly high-profile site which is hosted on Amazon EC2, and the previous developer pointed the A record at the instance's "public IP" instead of using an "Elastic IP". As far as I can tell the "public IP" is not in any way permanent so if ever I need to stop the instance, it will get a new one. Also, if I assign an elastic IP it removes the public IP, so if I change it the site will be inaccessible until the A record change propagates.

Obviously this is not good.

Is there any way I can assign an Elastic (or otherwise permanent) IP address without the current "public IP" being removed? Or, is there any other solution I haven't thought of to get me out of this mess?

Greg
  • 239
  • 1
  • 12

2 Answers2

6

Yes there is! Embrace the power of DNS eventual consistency.

  1. Set up an ELB, point it at your instance.
  2. Update the A record for your public instance with a CNAME for the ELB.
  3. Wait a week.
  4. Associate an Elastic-IP with the instance.
  5. Update the CNAME record for your app with a new A record for the EIP.
  6. Wait a week.
  7. Turn off the ELB.

For the two weeks of waiting site will likely get hits on both the old and new IP addresses. You might not be able to tell, but as both are still reachable you can manage this change pretty quickly.

Greg
  • 239
  • 1
  • 12
sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
  • Thanks, sounds like an ELB will be helpful - only problem is it doesn't seem to be possible to associate an Elastic IP to an ELB. I guess I might be able to point a CNAME at the ELB? – Greg Mar 23 '15 at 23:46
  • 1
    ELB cannot have an elastic ip. So change your DNS to point as a CNAME to the ELB. Wait a week. The set an elastic IP on your instance and move the DNS to that. After a week you can then remove the ELB. – Matt Houser Mar 24 '15 at 01:31
  • So, I remove my A record, replacing it with a CNAME, then once I'm sure that's working, I can add the elastic IP? – Greg Mar 24 '15 at 18:28
  • @Greg Pretty much. 1) Rename to ELB (CNAME), 2) Wait. 3) Change public IP on target box to elastic-IP. 4) Rename to target-IP (A record). 5) Wait. 6) Decomission the ELB. – sysadmin1138 Mar 24 '15 at 19:23
1

Another option is to create an ENI and attach an EIP to it. Then attach the ENI to your instance and change the DNS entry.

jpancoast
  • 111
  • 3