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?
1 Answer
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.
-
1Elastic 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.– ceejayozMay 1, 2014 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 CMay 1, 2014 at 15:37
-
@ceejayoz But I agree with your statement...VPC is the de-facto way.– Nathan CMay 1, 2014 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.– ceejayozMay 1, 2014 at 15:45
-
4Referencing the elastic ip by its dns name will resolve to the internal ip where possible avoiding data transfer charges. May 1, 2014 at 22:48