- Newest
- Most votes
- Most comments
In a nutshell, if Alice and Bob are in the same subnet within the VPC, they can communicate with each other using the private IP address. You just need to make sure you have a DNS solution using either VPC DNS server or a custom DNS server in place so that communication doesn't rely on IP address. If Alice and Bob are in different VPC or different account, you can use VPC peering or AWS PrivateLink.
Imagine that we have two services, called "Alice" and "Bob" .... running on AWS EC2 instances and .... their IP addresses are volatile.
Can you expand on this, how are the IPs volatile? When the Alice EC2 is provisioned it gets a private IP which never changes, no matter how many times it is stopped and started, until it is terminated. Same for the Bob EC2. So each will just need security group rules allowing (say) 80/tcp inbound & outbound from & to the other's private IP.
Public IP addresses will change after a stopping and starting, but that's not relevant here as you've said you don't want to use public IPs for reasons of cost.
If you mean that multiple EC2s are going to be spun up and down constantly (how is this achieved if you're not using auto scaling?) then just keep all the Alice EC2s in the same subnet, and the same for all the Bob EC2s (doesn't have to be the same subnet). And for Alice to talk to Bob using HTTP, Alice EC2s need a security group with an outbound rule of 80/tcp to the Bob subnet, and Bob EC2s need a rule allowing inbound 80/tcp from the Alice subnet.
If Alice and Bob are in different VPCs, which could be owned by different accounts, this can still be made to work as long as the VPCs are peered.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 10 months ago
Thank you for your answer, EC2's private addresses indeed have considerable durability. However, the objective here is to have Alice and Bob (the services) communicate to each other, not just their hosting machines. Alice and Bob may want to move, they may want to upsize or downsize, they may be using short term residence in a spot instance. In that sense, my title "...EC2 instances..." may be misleading.
I wonder if there are reasonably simple AWS solutions for this situation, without dialing up the complexity with ECS, autoscaling, service discovery etc.