AWS Certified Cloud Practitioner / EC2 - Elastic Compute Cloud

Security Groups Hands on

So we’ve launched our EC2 instance β€” great!

πŸš€ Now let’s actually explore security groups in action.

πŸ” Step 1: Viewing Security Groups from EC2

  • From your EC2 instance page

  • Go to Security tab

  • You’ll see: Attached security groups, Inbound rules and Outbound rules

πŸ‘‰ This gives you a quick overview, but not the full picture.


🧭 Step 2: Open the Full Security Groups Page

For a deeper view:

  1. Go to the left-hand menu

  2. Under Networking & Security

  3. Click on Security Groups

  4. Now you’ll see all security groups in your account.


πŸ“¦ Step 3: Understanding What You See

You’ll typically see:

  • Default Security Group

  • launch-wizard-1 (created when launching EC2)

Each security group has: πŸ†” A unique Security Group ID, πŸ“₯ Inbound rules and πŸ“€ Outbound rules


πŸ“₯ Step 4: Inspect Inbound Rules

Inbound rules control who's allowed to reach your EC2 instance.

Click Edit Inbound Rules and you'll see something like:

  • SSH β€” port 22 β€” source 0.0.0.0/0 (anywhere)

  • HTTP β€” port 80 β€” source 0.0.0.0/0


🌐 Step 5: Why Your Website Worked

Earlier, you accessed your EC2 using its public IPv4 address

πŸ‘‰ That worked because of this rule:

HTTP (port 80) open to the internet


🚨 Step 6: Breaking It (Very Important Learning)

  1. ❌ Delete the HTTP (port 80) rule

  1. Save changes

  1. Refresh your browser

πŸ‘‰ Result: You’ll see infinite loading / timeout

⚠️ Timeout = Security Group

Seeing a timeout β€” SSH, a website, an API, anything β€” check the security group first. It's almost always the cause.

Golden rule: Timeout = blocked by a security group.


βœ… Step 7: Fixing the Issue

  1. Add a new rule:

    • Type: HTTP

    • Port: 80

    • Source: 0.0.0.0/0

      ezgif-2578f0b6f2563620.mp4

  2. Save rules

  3. Refresh browser

  4. βœ… Your website works again!


βš™οΈ Step 8: Adding Other Rules

What you can configure

Ports: open whatever you need β€” HTTPS (443), a custom port like 8080, or a whole range.

Source: decide who that port is open to β€”

  • 🌍 Anywhere (0.0.0.0/0)

  • πŸ§‘ Only your IP ("My IP")

⚠️ One catch with "My IP": it's a snapshot, not a live setting. If your IP changes later β€” new network, ISP reassigns it, whatever β€” that rule no longer matches you, and you're locked out with a timeout until you update it.


πŸ“€ Step 9: Outbound Rules

Now take a look at Outbound Rules.

By default: all traffic is allowed, going anywhere.

That's what lets your EC2 instance freely reach out β€” hitting the internet, installing packages, calling external APIs β€” without you having to configure anything extra.


πŸ”— Multiple Security Groups

Important concept:

  • βœ… One EC2 can have Multiple security groups

  • βœ… One security group can be attached to Multiple EC2 instances

πŸ‘‰ Rules are combined together