Ritika Patidar
5 min readApr 13, 2022

Launch an EC2 Instance in AWS cloud and Host a Static Website inside the Web server.

Task1:- Launch an EC2 Instance:-

  1. In the AWS Management Console on the Services menu, choose EC2.

2. Choose Launch instance

3. Choose an Amazon Machine Image (AMI)

An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud.

4. Choose Select next to Amazon Linux 2 AMI (at the top of the list).

5. Choose an Instance Type.

We will use a t2.micro instance which should be selected by default. This instance type has 1 virtual CPU and 1 GiB of memory.

6. Configure Instance Details

This page is used to configure the instance to suit your requirements. This includes networking and monitoring settings.

For Network, select Lab VPC.

7. Scroll down then expand Advanced Details.

A field for User data will appear.

When you launch an instance, you can pass user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts.

Your instance is running Amazon Linux, so you will provide a shell script that will run when the instance starts.

8. Copy the following commands and paste them into the User data field:

#!/bin/bash

yum -y install httpd

systemctl enable httpd

systemctl start httpd

echo '<html><h1>Hello Ritika Patidar! </h1><p> This is static page.</p></html>' > /var/www/html/index.html

The script will:

· Install an Apache web server (httpd)

· Configure the web server to automatically start on boot

· Activate the Web server

· Create a simple web page

9. Choose Next: Add Storage

Amazon EC2 stores data on a network-attached virtual disk called Elastic Block Store.

You will launch the Amazon EC2 instance using a default 8 GiB disk volume. This will be your root volume (also known as a 'boot' volume).

10. Choose Add Tag then configure:

· Key: Name

· Value: Web Server

11. Configure Security Group

A security group acts as a virtual firewall that controls the traffic for one or more instances. configure:

· Security group name: Web Server security group

· Description: Security group for my web server

12. Delete the existing SSH rule.

13. Click on Remove

14. Choose the Choose an existing key pair drop-down and select Proceed without a key pair.

15. Choose Launch Instances

our instance will now be launched.

16. Choose View Instances at the bottom

The instance will appear in a pending state, which means it is being launched.

17. Wait for your instance to display the following:

· Instance State: running

· Status Checks: 2/2 checks passed

We have successfully launched our first Amazon EC2 instance.

Task 3:- Update security group and Access the web Server and Preview website in your web browser using your instance public ip address.

  1. Choose the Details tab.

2. Copy the IPv4 Public IP of your instance to your clipboard.

3. Open a new tab in your web browser, paste the IP address you just copied, then press Enter.

Question: Are you able to access your web server? Why not?

You are not currently able to access your web server because the security group is not permitting inbound traffic on port 80, which is used for HTTP web requests. This is a demonstration of using a security group as a firewall to restrict the network traffic that is allowed in and out of an instance.

To correct this, you will now update the security group to permit web traffic on port 80.

4. Keep the browser tab open, but return to the EC2 Management Console tab.

5. In the left navigation pane, choose Security Groups.

6. Select Web Server security group.

7. Choose the Inbound rules tab.

8. Choose Edit inbound rules then configure:

a. Type: HTTP

b. Source: Anywhere-IPv4

c. Choose Save rules

9. Return to the web server tab that you previously opened and refresh the page.

We should see the message Hello Ritika Patidar ! This is static page

Congratulations! We have successfully modified our security group to permit HTTP traffic into our Amazon EC2 Instance.