[Recipes] Understanding Security Groups for EC2


You have created an EC2 instance. Need to understand how to work with Security groups.

Solution Summary: 

We will remove rule for HTTP from our security group and try running public IP again.


This lab assumes that you can create an EC2 instance, connect to it and do basic operations.

  1. Create an EC2 instance of type t2 micro. Reuse the security group and the keypair we had created in previous labs. Note: You may also create a new security group, but allow HTTP and HTTPS in addition to SSH.

  2. Login using the public ip through SSH, and elevate as root:

    1. sudo su

  3. Install and start apache server

    1. yum install httpd –y

    2. service httpd start

    3. checkconfig httpd on (this steps is required to start httpd automatically every time we reboot)

    4. Go to the html directory of the apache server

      1. cd /var/www/html

    5. Create a very small html file:

      1. vi index.html

      2. click on insert or i.

      3. Type: <html><h1>Hello Buddy!</h1></html>

      4. Click on ESC, type :x, and press enter to save

    6. Verify getting the html output:

      1. Copy the public ip for the instance from the console

      2. Run it on the browser after http (e.g. You should see the web page with: Hello Buddy!

  4. Go back to EC2’s Security Groups section, select the security group we are using and remove rule for HTTP. It will be immediately reflected: try running the public ip url again and it will not display the page.

Recipe Tags: 
Title (Optional): 
Understanding Security Groups for EC2


lijo's picture

step3.3- checkconfig httpd on

Above command doesn't work on windows machines.

Try this instead : chkconfig httpd on



We learn together, do innovations and then document them at cloudericks.com.

Offline Contact
We connect physically only in Bengaluru currently, but most of our activities happen online. Please follow us here or in social media for more details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About us

Team Cloudericks is a community started by Heartin Kanikathottu to learn about and master cloud computing. Our current focus is on Amazon Web Servivces.

Cloudericks.com aims to document what we learn. We believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream