I am having a bit of trouble fixing this network issue in AWS. Before going into more details, I will start off by this:
I have a Network Load Balancer with a listener 8243
There's a target group attached to that 8243 listener, where the target group port is also 8243
Behind the target group, there's my EC2 instance running an application on 8243.
The EC2 instance has a security group (SG). Currently the target group health-check is failing because I haven't allowed the traffic from NLB to EC2 in the EC2 instance's SG. Therefore this issue is expected.
My problem is, I don't want to add an inbound rule to EC2's SG for the port 8243
where the source range is either public (0.0.0.0/0) or the Subnet IP range. Because I only want the inbound rule of EC2's SG to have 8243 open ONLY for the traffic coming from the NLB. But the problem is, I cannot attach a security group to the NLB as AWS doesn't allow it. This wasn't the problem when I was using an Application Load Balancer as I could reference ALB's SG in the EC2's SG.
Can someone help me fix this issue?