Can a security group reference another security group, and why is that useful?
IntermediateConceptNAT, Firewalls & VPN
Answer
Yes. A rule's source can be another security group ID, meaning "any ENI that has that group attached". Instances can scale and change IPs without rule edits.
aws ec2 authorize-security-group-ingress --group-id sg-db --protocol tcp --port 5432 --source-group sg-app
That one rule says "only the app tier may reach Postgres", which is the standard three-tier pattern.
More on NAT, Firewalls & VPN
What is NAT and why is it used?BeginnerWhat is the difference between SNAT, DNAT and PAT?AdvancedHow does an AWS NAT gateway work, and what are its limits?AdvancedWhy is NAT gateway cost a common surprise and how do you reduce it?IntermediateWhat is conntrack and what happens when its table fills up?AdvancedWhat is the difference between a stateful and a stateless firewall?Beginner