Reputation: 1637
I have two AWS EC2 instances that are trying to talk to each other over a custom TCP port. Each instance has its own security group, but neither can talk to each other.
Here's my setup:
EC2 Instance 1
EC2 Instance 2
SG outbound rules:
The problem
Whenever instance-1 tries to initiate a TCP request to www.xxx.yyy.zzz:12345
, the connection times out.
If I add the following inbound rule to instance-2's SG, it works just fine:
Summary
I need instance-1 to talk to instance-2 without allowing traffic from anywhere to access port 12345. Is there a way to do this?
Upvotes: 3
Views: 1599
Reputation: 3973
You cannot access a public IP using a security group as the incoming source.
When you specify a security group as the source or destination for a rule, the rule affects all instances associated with the security group. Incoming traffic is allowed based on the private IP addresses of the instances that are associated with the source security group (and not the public IP or Elastic IP addresses). For more information about IP addresses, see Amazon EC2 Instance IP Addressing.
Use the private IP address or use the public IP as the source.
References
Security Group Connection Tracking
Upvotes: 5