How it works...
In this recipe, we created and configured a security group with inbound and outbound rules that are applicable for an EC2 instance in a public subnet running a web server. We will use these steps to create security groups in other recipes. The exact rules may differ based on the use case. Instead of providing the CIDR range, we can also specify another security group in a rule to say that only instances with that security group should be allowed.
In the Working with NACLs recipe in Chapter 5, Network Security with VPC, we explicitly allowed the ephemeral port range of 1024 - 65535 for outbound requests. This isn't needed for security groups since security groups are stateful. If an outbound port is opened, the response for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access