DEV Community

Cover image for Learn & Implement Contest - AWS UG OSTech Conf 2021
awsugjaipur for AWS UG Jaipur

Posted on • Updated on

Learn & Implement Contest - AWS UG OSTech Conf 2021

This contest is a part of AWS UG OSTech Conf 2021

Prerequisite: Must have access to AWS console
Disclaimer: We have used AWS EC2 t2.micro instance that is free tier eligible still can cause billing, It's user responsibility to terminate instance after performing the contest.

Step1: Launching EC2 instance

1.1) In AWS Console, search for EC2 and click on that service, you will be redirected to the AWS EC2 page as follows and then click on Launch Instance.
Launching EC2 Instance

1.2) To run EC2 successfully, select an Amazon Machine Image (AMI). AMI contains all the software configurations (Operating System, Application Server, and applications) required to launch your instance. In this case, we will pick Amazon Linux AMI.


1.3) Now, select the Instance Type that determines the type of CPU, storage, network capacity, and memory needed during the installation. Choose t2.micro, and hit the next button as shown below:


1.4) Click the Next button until you reach the Configure Security Group page to retain the default settings. A security group is a set of firewall rules that control the traffic for your instance. On this page, you can add rules to allow specific traffic to reach your instance.

For example, if you want to set up a web server and allow internet traffic to reach your instance, add rules that allow unrestricted access to the HTTP and HTTPS ports.
It's must to put 22 port on my_ip field.
Enter the Security Group name and then hit the Review and Launch button.


1.5) After hitting the Launch button you will see a pop-up page that requires you to select a Key Pair. This contains both a public and private key folder that is used to connect to your EC2 Instance securely via SSH. Click on the create a new key pair button and give a name to the key pair. Go ahead and download your key pair.


1.6) Save your key file to a safe place on your system and then click on Launch Instances, it will direct you to the launching page. Hit the View Instances button to access the EC2 Instances page, then click on connect and you will see several options to connect your instance, it will only need SSH to be installed and the pem key that you have downloaded, mentioned in the previous step.

Copy ssh command provided there and use it to connect, you can use Git Bash, CMD, or Putty.


Step 2: Install required tools and packages

2.1) After connecting to the instance via SSH, now run the below commands -

 sudo su 
 yum update -y
 yum install docker git -y
 systemctl start docker
 usermod -a -G docker ec2-user
 systemctl enable docker
Enter fullscreen mode Exit fullscreen mode

These commands will install Docker and Git in your AMI, and enable your Docker service.

2.2) Now you have to clone a repository and modify a file by replacing AWS with your Full Name by using the below commands -

 git clone
 cd OSTechConf21/contests/learn-and-implement/
 sed -i 's/I am/AWS/g' learn/index.html
Enter fullscreen mode Exit fullscreen mode

Note: Don't forget to replace AWS with your name like :-
$ sed -i 's/I am/Elon Musk/g' learn/index.html

Step 3: Build Image and Run Container

First, check that you are in the learn-and-implement/ folder and a Dockerfile is present.
This command will build the image

docker build -t 'ostechconf21' .
Enter fullscreen mode Exit fullscreen mode

This command will run your docker container in which web page is hosted

docker run -p 80:80 -d ostechconf21
Enter fullscreen mode Exit fullscreen mode


It's Done! 🥳

Step 4: Final Steps

4.1) Open the Amazon EC2 console and in the navigation pane, choose Instances and select your instance.

The following information is available on the Networking tab:
Public IPv4 DNS — The external DNS hostname.


4.2) Copy the Public DNS and paste that in any browser.


Congratulations !! If you can see your webpage with your name as above screenshot.

4.3) Now go to EC2 console and copy instance Public DNS and open that in any browser and share the screenshot as given on contest page.

Connect with AWS UG Jaipur:
YouTube | LinkedIn | GitHub

Top comments (1)

lokeshs66317127 profile image
Grraphic :) era

[root@ip-172-31-50-221 OSTechConf21]# sed -i 's/I am/Lokesh/g' learn/index.html sed: can't read learn/index.html: No such file or directory

Please give some sol.