Security Groups
2 minute read
In AWS, a Security Group is a virtual firewall that controls the inbound and outbound traffic for one or more instances in a VPC (Virtual Private Cloud).
Each security group consists of a set of rules that specify which types of traffic are allowed to access the instances associated with the security group. When you launch an instance in a VPC, you can either use the default security group or create a new one.
Security group rules can be defined based on protocols (such as TCP, UDP, and ICMP), port ranges, and the source or destination IP address ranges. For example, you can create a security group rule that allows incoming SSH traffic from a specific IP address range, or a rule that allows incoming HTTP traffic from any IP address.
One of the key benefits of security groups is that they are stateful, which means that they keep track of the connections that are established and automatically allow the return traffic. For example, if you create a security group rule that allows incoming HTTP traffic on port 80, the security group will automatically allow the return traffic on port 80 for any established connections.
Another advantage of security groups is that they can be associated with multiple instances, which makes it easy to manage the security settings for groups of instances with similar security requirements.
In addition to allowing or denying traffic, security groups can also be used to log traffic that matches a specific rule. This can be useful for monitoring and auditing purposes.