I haven't been able to find any best practices for AWS security groups. I figure there are two approaches I could take, but I'm not sure on if there are any particular drawbacks to either one.
Scenario 1:
Define small, specialized security groups such as "ssh," "mongodb," "web," etc, and then in essence "stacking" multiple security groups on each EC2 instance to specify which ports are open.
Scenario 2:
Define larger, more generic security groups such as "web1" which opens ports 80, 443, ssh, database, and apply this to any appropriate EC2 instances.
I think I'd rather go with scenario #1, but don't know if there are any disadvantages or technical issues with this approach. Is there a best practice?
AWS limits the amount of groups you can apply to a network interface:
Security groups per network interface 5
A common approach is to create SGs such that it's easy to update your fleet of servers, but in a way that still makes sense for all the hosts they're applied to.
Consider these points
These factors will shape what you'll want to open up for your instance security groups.
A generic approach
Given all this, a common approach would be:
Variations on the "common" SG: