AWS EC2 Instance
Tags: ec2, aws, cloudcomputing, amazon
Published: 2020-04-23 17:52:46

This Gistdicated to all those beginners and learners who are seeking to learn and explore Cloud Computing. Cloud Computing seems to be a complicated term, but believe me it not. Especially, when you're working on AWS Cloud Computing platform. So, without wasting more time lets begin.
![AWS](https://user-images.githubusercontent.com/32240906/80129379-96460480-85b4-11ea-98c0-45fa938d1f93.png)

# Introduction
Hey Readers! This Blog is to acknowledge one of the most widely used Cloud Computing services provided by Amazon under AWS cloud computing services. That is, **EC2 or Elastic Cloud Computing**. It is widely used and easy to learn and explore. We all know the fact that in cloud computing no other company or service can even be compared with AWS, not even **Google's Cloud Computing**. It is because AWS provides-
1. better and easy to use **UI/UX** to the users.
1. **Consistency & Reliability**.
1. **Flexibility, Scalability, and high-performance**
1. **Pay-As-You-Go** Pricing (cost-effective)
1. a lot of **customization**.
1. **Security** as its prior concern
1. Learning platforms and **Tutorials**, and never lasting **documentation**.
1. And most of all, incomparable **customer care** support.

Click here to know more about AWS.
![image](https://user-images.githubusercontent.com/32240906/80126671-03f03180-85b1-11ea-8fff-d9900a3899b8.png)

Meanwhile, Check out the free-tier services first provided by AWS, visit: [https://aws.amazon.com/free/](https://aws.amazon.com/free/) for the same.

Coming to the main focus of this writing, we're going to cover below-mentioned topics in this blog:
## Elastic Cloud Computing (EC2):
1. About EC2
1. Setup EC2 Instance
1. Stepwise installation.
1. Setup SSH Key
1. Connect and clone Git repo
1. install Node.js, NPM modules, and learn how to launch a website.
1. Conclusion

## AWS Elastic Cloud Computing (EC2)
**1. About AWS EC2**
_Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the **Amazon Web Services (AWS) cloud**. Using Amazon EC2 eliminates your need to invest in hardware upfront, so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. **Amazon EC2** enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic. Read more…_
 ~ AWS

**2. Setup EC2 Instance**
Sign up on **AWS** at [https://aws.amazon.com/](https://aws.amazon.com/) and make an account. You will need to enter your billing and credit card information. However, you'll be charged few dollars or less just to get confirm it's a legit account and the deducted amount will get refunded later on.

Note: You should delete instances you no longer need to ignore any additional billing unknowingly.

Find and Select Amazon EC2 from listed products and services.
Click the button: "`Launch Instance`"

Now, adhere to the steps mentioned below to get started and for a successful installation.

Step 1: `Choose an Amazon Machine Image (AMI)`: This is the operating system your virtual machine in the cloud will be. As Ubuntu is popular, open-sourced, easy to use, and included in free tier eligibility.

![image](https://user-images.githubusercontent.com/32240906/80126311-8b897080-85b0-11ea-8e09-e45a5fb60fdb.png)

Step 2: Choose an Instance Type: Leave it at "`General purpose t2.micro free tier eligible`". Click "`Next: Configure Instance Details.`"

![image](https://user-images.githubusercontent.com/32240906/80126349-993ef600-85b0-11ea-9e0b-a50ae0f35f7e.png)

Step 3: Configure Instance Details: Leave the default settings. Click "`Next: Add Storage`"

Step 4: Add Storage: Leave the default settings. Click "`Next: Add Tags`"

Step 5: Add Tags: Create a key and value. I named mine `"tutorial-key": "tutorial-value"`

Step 6: Configure Security Group: Check the radio button labeled "`create a new security group`" and give it a name and description. Make sure there is an SSH type listed and add HTTP and HTTPS. Click "`Review and Launch`"

![image](https://user-images.githubusercontent.com/32240906/80126361-9e03aa00-85b0-11ea-885d-cec386f849eb.png)
Step 7: Review Instance Launch: Click "`Launch`" The following window should appear. Select "Create a new key pair" and type in a name. Click "Download." Make sure you save this file!!! Click "`launch instance`" You should be redirected to a page where you can click "view instances" to see all your instances. Your new EC2 instance should appear and may take a few moments to initialize.

**Yuuhoo! You have successfully created a new EC2 instance!**
![Picture1](https://user-images.githubusercontent.com/32240906/80131008-3309a180-85b7-11ea-91c6-e2b9fc45c797.png)

I hope, by now. you must have successfully launched an EC2 in your **AWS console**. But If you get stuck somewhere and unable to solve any problem, write me back in anytime. Connection links are listed in end. As we're going to setup ssh connections further we need EC2 instance up and running.

**4. Set up ssh connection**

![image](https://user-images.githubusercontent.com/32240906/80126528-dd31fb00-85b0-11ea-9525-7db7d3925590.png)

On your local machine, move the download file (tutorial.pem) to your project's root folder and open terminal in the root directory of your project.

Type `'chmod 400 tutorial.pem'` to change required permissions.

Go back to your AWS Console and open `EC2 dashboard> Running instances` and click on '`connect`'. Here you'll find more details to access your **SSH instance**. Now, copy example there and type in similar command in terminal:

**_`ssh -i "tutorial.pem" ubuntu@ec2–15–236–127–272.ap-south1.compute.amazonaws.com`_**

Now, you may get into your remote EC2 instance's operating system via your terminal.

Note: you can also use third-party software like **Putty**.

![Picture2](https://user-images.githubusercontent.com/32240906/80131387-c9d65e00-85b7-11ea-97d5-8e26cefed87d.png)

**5. Clone GitHub Repo** and Launch your website:**
Clone project from Github to EC2 console terminal. Run:
```
git clone https://github.com/genialkartik/NodeJS_demo_repo.git .
cd NodeJS_demo_repo
```
**6. Install node.js, npm, and launch our website**
```
 sudo apt-get update
 sudo apt-get install nodejs
 sudo apt-get install nodejs-legacy
 sudo apt-get install build-essential
 sudo apt-get install npm
 npm install
 npm start
```

If everything goes well, you'll get a message in the console
`'Server running at http://ec2-15-236-127-272.ap-south-1.compute.amazonaws.com:3000'`
Follow the link or enter your Public DNS (IPv4) in URL with :**`3000 port`**.

After a few mins or two, you should be able to refresh your site in the browser and see your web application up and running!
Woaaahhoo!! Congrats you did it!!

**7. Conclusion**
Phew!! that was a lot to understand for the day. I hope you loved it and successfully launched your website using **AWS EC2 instance**.
If you really like it or it may prove helpful to you anyhow, you are welcome to continue looking around on [kartiktyagi.codes](https://kartiktyagi.codes) and read even more exciting articles. You are welcome to reach me out for any unsettled questions! :)