Security Groups (Firewall Rules)
Security Groups are virtual firewalls for your EC2 instances. They control inbound and outbound traffic at the instance level. Security Groups are stateful, meaning if you allow inbound traffic, the outbound response is automatically allowed.
Inbound and Outbound Rules
Security Groups support both inbound and outbound rules. Inbound rules control incoming traffic to your instances, while outbound rules control traffic leaving your instances. By default, all outbound traffic is allowed.
Stateful Behavior
Security Groups are stateful. If you send a request from your instance, the response traffic for that request is automatically allowed, regardless of outbound rules. This applies to both inbound and outbound traffic.
Multiple Security Groups
You can attach multiple Security Groups to a single EC2 instance. The instance will be allowed if any of the attached Security Groups allow the traffic. This provides flexibility in managing access.
