3

I want my server to connect to a db server (both on an EC2 instance). How can i give the db server a static IP address to use within EC2 without using VPC?

Mersey
  • 33
  • 1
  • 3
  • 1
    Just use a VPC. Hell, it's the default for new accounts. Takes an extra five minutes to set one up and comes with all sorts of benefits. – ceejayoz May 01 '14 at 15:35

1 Answers1

4

Elastic IPs are the only way without using a VPC. You can use a Security Policy to restrict all public traffic so you'd essentially have a private IP address (plus, these are free).

Edit: As pointed out by @ceejayoz, this incurs Internet bandwidth fees and is not the recommended method. Unless you absolutely cannot use VPC for some reason, use it. Otherwise, use the "internal" EC2 assigned IP or static as a last resort.

Nathan C
  • 14,901
  • 4
  • 42
  • 62
  • 1
    Elastic IP is a fixed public IP. I don't think it gives you a fixed private one. DB traffic over a public IP will suck. – ceejayoz May 01 '14 at 15:35
  • @ceejayoz Traffic is still routed like it was private. I had two instances once with static IPs, and they were one hop from each other provided they were in the same zone. – Nathan C May 01 '14 at 15:37
  • @ceejayoz But I agree with your statement...VPC is the de-facto way. – Nathan C May 01 '14 at 15:38
  • Nathan, per the EC2 docs, "Instances that access other instances through their public NAT IP address are charged for regional or Internet data transfer, depending on whether the instances are in the same region." Definitely not the same on a billing basis, and that's likely because they're not the same on a technical basis too. – ceejayoz May 01 '14 at 15:45
  • @ceejayoz Ah...forgot about that gotcha. I'll update my answer since the OP wanted to know alternates, but it's not a good one... – Nathan C May 01 '14 at 15:51
  • Tnx guys, I'll just use VPC – Mersey May 01 '14 at 15:56
  • 4
    Referencing the elastic ip by its dns name will resolve to the internal ip where possible avoiding data transfer charges. – Matt Houser May 01 '14 at 22:48