An enterprise is deploying a payment processing engine on Amazon EC2 instances in Subnet A (CIDR ) of a VPC. The instances must query a database service exposed via an Interface VPC Endpoint located in Subnet B (CIDR ) within the same VPC. The database listens on TCP port . The network architecture mandates that Subnet A and Subnet B use custom, non-default Network Access Control Lists (NACLs). Which combination of Security Group (SG) and NACL configurations will allow successful communication while adhering to the principle of least privilege?
- AFor the EC2 instances SG: Outbound rule allowing TCP port to the Interface Endpoint SG, and Inbound rule allowing TCP ports from the Interface Endpoint SG. For the Interface Endpoint SG: Inbound rule allowing TCP port from the EC2 instances SG, and Outbound rule allowing TCP ports to the EC2 instances SG. For Subnet A NACL: Outbound rule allowing TCP port to . For Subnet B NACL: Inbound rule allowing TCP port from .
- BFor the EC2 instances SG: Outbound rule allowing TCP port to the Interface Endpoint SG. For the Interface Endpoint SG: Inbound rule allowing TCP port from the EC2 instances SG. For Subnet A NACL: Outbound rule allowing TCP port to the Interface Endpoint SG, and Inbound rule allowing TCP ports from the Interface Endpoint SG. For Subnet B NACL: Inbound rule allowing TCP port from the EC2 instances SG, and Outbound rule allowing TCP ports to the EC2 instances SG.
- For the EC2 instances SG: Outbound rule allowing TCP port to the Interface Endpoint SG. For the Interface Endpoint SG: Inbound rule allowing TCP port from the EC2 instances SG. For Subnet A NACL: Outbound rule allowing TCP port to , and Inbound rule allowing TCP ports from . For Subnet B NACL: Inbound rule allowing TCP port from , and Outbound rule allowing TCP ports to .Answer
- DFor the EC2 instances SG: Outbound rule allowing TCP port to . For the Interface Endpoint SG: Inbound rule allowing TCP port from . For Subnet A NACL: Outbound rule allowing TCP port to . For Subnet B NACL: Inbound rule allowing TCP port from .
Answer
The correct configuration uses stateful Security Groups targeting port without reverse rules, and stateless Network ACLs that explicitly permit the request on port and the response traffic on ephemeral ports between the two subnet CIDRs.
Security Groups are stateful. When the EC2 instance initiates a connection to the database endpoint on port , the Security Group automatically allows the return traffic. Therefore, the EC2 Security Group only requires an outbound rule to the Endpoint Security Group, and the Endpoint Security Group only requires an inbound rule from the EC2 Security Group. Conversely, Network ACLs are stateless. Subnet A's NACL must explicitly allow the outbound request to Subnet B on port , and it must also allow the inbound return traffic from Subnet B on the ephemeral port range (). Similarly, Subnet B's NACL must allow the inbound request on port and the outbound return traffic to Subnet A on the ephemeral port range ().
Step-by-Step Solution
Key Concept
VPC Network Security: Stateful Security Groups vs. Stateless Network ACLs