Security Groups

5 minutes 5 Questions

A security group is a virtual firewall that controls the traffic for one or more Amazon EC2 instances. You can create security groups based on your requirements and then assign them to your instances, allowing or denying traffic based on rules. Rules can be configured for both inbound and outbound traffic, by specifying source or destination, protocol, and port range. Security groups help protect your instances by isolating them from unwanted traffic and ensuring only authorized access.

Guide: Understanding Security Groups in Amazon EC2

Importance of Security Groups:
Security Groups are essential in Amazon EC2 as they determine the inbound and outbound traffic rules for instances. These rules act as a virtual firewall that helps in securing your EC2 instances from unauthorized and potentially harmful access.

What are Security Groups in Amazon EC2?
A Security Group in Amazon EC2 is a rule set that controls inbound and outbound network traffic to EC2 instances. When you create an instance, you can assign it one or multiple Security Groups. A security group applies to an instance level, not the subnet level.

How does it work?
The rules of Security Groups define which traffic will be allowed into the instance and which will be allowed out. Default rules allow all outbound traffic but deny all inbound traffic. You can modify these rules according to the specific needs of your application running on the EC2 instances. Remember that rules are stateful, so if you allow an inbound request, the outbound response is automatically allowed.

Exam Tips: Answering Questions on Security Groups
1. Understand the difference between Security Groups and Network Access Control Lists (NACLs). Security Groups are stateful and apply at the instance level, while NACLs are stateless and apply at the subnet level.
2. You cannot deny a particular IP address using Security Groups as they only allow allow rules.
3. You can assign more than one Security Group to an EC2 instance.
4. When answering questions, keep in mind that changes to Security Groups take effect immediately.
5. You can't change the default rule for outbound traffic (all outbound traffic allowed) but you can add rules to further filter traffic.
6. Remember that all new inbound connections are denied by default and you need to create inbound rules to allow incoming connections.
7. Each Security Group rule can reference another group, thus granting members of the referenced group permission to access instances associated with the original group.
Test mode:

AWS Certified Solutions Architect - Security Groups Example Questions

Test your knowledge of Security Groups

Question 1

An Amazon RDS instance runs in a private subnet and must be reachable only from the company’s on‑premises network over a site‑to‑site VPN. To protect the database from unauthorized access, which security group rule on the RDS instance should be configured?

Question 2

An Amazon EC2 instance must send email via Amazon SES using the SMTP interface (not the SES API). The instance does not need to accept any inbound email connections. How should its security group be configured to allow this traffic?

Question 3

You manage an Auto Scaling group that launches Amazon Linux 2 instances in a private subnet. The VPC has a NAT gateway in a public subnet and an Internet Gateway. At boot, the instances must install the latest security updates using yum/dnf. The security group attached to the instances is configured for least privilege (no default allow-all egress). Which outbound security group rules must be configured to enable the instances to successfully obtain updates while minimizing exposure?

More Security Groups questions
92 questions (total)