What is AWS EC2 and How to Deploy an Environment on It?

Introduction:

AWS (Amazon Web Service) is a cloud provider which provides its users with a wide range of services via the Internet. Cloud Computing is a technology where a resource is provided as a service through the Internet to a user. It offers the following benefits:

  • Data Privacy and Security
  • No maintenance worries
  • Faster Data Recovery
  • Auto scalability
  • Cost reduction

AWS revolutionized the IT industry by introducing companies with a new way to use servers. The three reasons for which AWS stands out as the leader of cloud services are as follows:

  • Simple and per hour billing
  • Amazon’s brand name
  • Easy profile setup

Service Domains in AWS:

  • AWS offers the following Service domains:
  • Compute
  • Storage
  • Database
  • Security
  • Management
  • Customer Engagement
  • App Integration

The EC2 service is present under this particular service domain.

Compute:

The Compute service domain basically deals with servers. If we need servers or we need any workload which requires processing, the Compute domain will provide services where you can launch and implement that workload. The services provided by Compute domain are:

  • AWS EC2 (Elastic Compute Cloud)
  • Elastic Beanstalk
  • AWS Lambda
  • Autoscaling
  • AWS Loadbalancer
  • AWS ECR (Elastic Container Registry)
  • AWS ECS (Elastic Container Service)

What is AWS EC2?

Elastic Compute Cloud (EC2) is one of the primary components of the AWS ecosystem. EC2 allows on-demand, scalable computing capacity in the AWS cloud. EC2 is nothing but a raw server; it is just like a fresh computer provided by AWS. We need to specify the type of processor we need and the type of RAM. Post clicking on Launch, we get a server which is of our specified configuration. Now we have to connect to it remotely. For that, we require SSH (Secure Shell/ Secure Socket Shell) for Linux OS and RDP (Remote Desktop Protocol) for Windows OS.

We can launch a single EC2 instance or multiple EC2 instances. We can create an EC2 instance and then install software on it. Then, multiple copies of the same EC2 instance can be created. The facility of changing the configuration of the server whenever we want to makes this service truly ELASTIC.

Deploying an Environment in EC2:

Deploying an environment in EC2 is easy but a lengthy process. For a beginner to AWS, there are some steps which are needed to be followed meticulously in a sequential way:

Account Creation in AWS:

 

  • Navigate to aws.amazon.com
  • Create an AWS account
  • Fill up the necessary details
  • Choose the account type as Personal
  • Fill up the card details and click on Submit
  • Choose the Free Tier Policy as per which we will get some of the AWS services at free of cost for 1 year at the rate of 750 hrs of usage per month
  • Click on Launch free instances
  • After signing up, the user has to login into his or her account
  • Navigate to AWS Management Console and click on Sign in
  • Fill up the username and password and click on Sign in/ Log in

Account Creation

Opening EC2 Dashboard:

AWS Management Console shows the list of services along with the domain names. When we click on the EC2 service, the EC2 dashboard is launched.

Launching the instance:

  • On the EC2 dashboard, click on Launch Instance
  • Choose the OS which is fit for our need and make sure that it is free tire eligible (we choose Ubuntu here)

  • Select the server
  • Configure the server: t2.micro-> 1 CPU and 1 GB of RAM->next-> (Keep all details unaltered)->Next->Hard drive storage (default: 8 GB)->Next->Add tags: Metadata-> Next
  • Configure Security Group: Security group is a very simple firewall. There are certain inbound rules that can be added. These rules decide what kind of connections is allowed in this server.

Source value decides who do we want to use the SSH protocol and why. The custom value stands for anyone and anywhere. This option is helpful when the IP address of the computer through which the protocol will be accessed is not fixed. If the IP address is constant, then we need to choose the option of MyIP. Then only we will be allowed to connect to this instance using the SSH Protocol and that too only from the system using which we launched the instance.

Key pair:

  • Review and Launch
  • Launch-> Select an existing key pair or create a new key pair. A key pair consists of a public key that AWS stores and a private key file that the user stores. Together, they allow the user to connect to the instance securely. For Windows AMIs (Amazon Machine Image), the private key file is required to obtain the password used to log into your instance. For Linux AMIs, the private key file allows us to connect through our instance using SSH.

  • Create a new Key pair
  • Name the key pair (MTest, say)
  • Download Key pair-> MTest.pem file gets downloaded. This file will be used to connect to our instance. At first, its status will be shown as Pending. Within some time, the status will change to Running.

Connecting to the instance:

  •  Download Putty and Puttygen based on the configuration of our systems and install them.
  • The Utility of Puttygen: If we need to use the .pem (Privacy Enhanced Mail) file with Putty, we have to do it after converting it to .ppk (Putty Private Key) file through Puttygen
  • After installing Puttygen open Puttygen
  • Click on Load
  • Browse for the newly downloaded .pem file (MTest.pem in this case)
  • Save private key
  • Click on yes
  • Name it and save

  • Now we have to launch Putty. Use the IPv4 Public IP value for launching Putty. This value is to be used as the IP address in the login of the session part.
  • Navigate to SSH in Connection. Now we need to put the key using which connection will be established.
  • SSH-> Auth-> Browse-> Select the .ppk file-> Click on Open

  • Click on Yes
  • Login as: ubuntu
  • Then it will authenticate the key entered and will be able to connect to the server that we created on AWS.

For Windows OS:

There are only two types of Operating Systems that you can launch using AWS—Linux and Windows. Linux is a command line-based OS. So, we need to connect to it through SSH. But Windows is a Graphical User Interface (GUI) based OS. Thus, it is to be noted that for Windows, we won’t get a .pem file. We will get a .rdp file along with a password. We can use the same key-pair to launch multiple instances.

  • On the EC2 dashboard, click on Launch Instance
  • Choose the OS which is fit for our need and make sure that it is free tire eligible (we choose Microsoft Windows here)

  • Select the server
  • Configure the server: t2.micro-> 1 CPU and 1 GB of RAM->next-> (Keep all details unaltered)->Next->Hard drive storage (default: 30 GB)->Next->Add tags-> Next
  • Configure Security Group: Security group is a very simple firewall. There are certain inbound rules that can be added. These rules decide what kinds of connections are allowed in this server.

  • Launch the Instance. Initially, the instance will be in pending status.
  • Once the instance is in running status, navigate to Actions-> Connect.

  • Click on Download Remote Desktop Protocol File. Our username is Administrator. In order to know the password, we need to click on Get Password. But the Password will be available only after 4 minutes from the launching of the instance. If we have joined our instance to a directory, we can use our directory credentials to connect to our instance.

  • After 4 minutes, we need to check for the password once again. The following screen opens:

  • The .pem file (previously created) will work as the key pair file. We need to browse and open the MTest.pem file and click on Decrypt Password

  • After getting the password, we need to open the downloaded RDP file.
  • Click on Connect and then enter the password and click on Ok
  • The following message appears:

  • Click on Yes
  • Connection with the server is then established

Conclusion:

Passwords are generated during the launch of Amazon Windows AMIs or custom AMIs that have been configured to enable this feature. Instances launched from a custom AMI without this feature enabled to use the username and password of the AMI’s parent instance.

So, this was all about AWS EC2 and how to deploy an environment on it. Hope, the article was helpful.