A company has a VPC with a public subnet and a private subnet. An Amazon RDS instance is in the private subnet, and an application server is in the public subnet. The security team needs to allow the application server to connect to the RDS instance on port 3306 (MySQL). Which configuration will meet this requirement securely?
This is the correct approach: referencing the application server's security group (SG) as the source in the RDS inbound rule permits only traffic originating from network interfaces attached to that specific SG. This pattern—often called SG chaining—is dynamically updated if the instance's private IP changes, is not tied to subnet boundaries, and automatically covers any additional instances that later receive the same SG, making it the most precise and maintainable solution.
Why this answer
It uses a security group reference as the source in the inbound rule for the RDS security group. This allows traffic only from the specific application server(s) associated with that security group, regardless of their IP addresses, and automatically scales if the application server is replaced or scaled. This is the most secure and AWS-recommended method for controlling traffic between resources within a VPC.
Exam trap
The trap here is that candidates often confuse security group references with CIDR-based rules, mistakenly thinking that allowing traffic from the subnet CIDR (Option C) is equivalent to allowing traffic from the application server, when in fact it permits any resource in that subnet to connect.
How to eliminate wrong answers
Option A is wrong because allowing traffic from the entire VPC CIDR is overly permissive; any resource in the VPC, including unintended instances or services, could connect to the RDS instance, violating the principle of least privilege. Option C is wrong because allowing traffic from the subnet CIDR of the application server permits any resource launched in that subnet (e.g., other instances or containers) to access the RDS instance, not just the intended application server. Option D is wrong because allowing traffic from 0.0.0.0/0 exposes the RDS instance to the entire internet, which is a severe security risk and contradicts the requirement to keep the RDS instance in a private subnet.