How to Launch EC2 instance in AWS

Share

An Amazon Elastic Compute Cloud (EC2) instance is a virtual server that a AWS subscriber can provision on Amazon cloud infrastructure using compute service. These are charged on an hourly basis based on the configuration selected, like instance type (including processing memory and storage), region where the instance is deployed, and AMI. In this blog we will learn how to launch an instance and connect to it.

Launching an EC2 instance in AWS Cloud

Login to your AWS  cloud console  search for EC2 and click on it.

click on instances under Resources

Now click on Launch instances and follow below given steps to launch a ec2 instance.

 

Step-1:

A tag is a label that you can give to every AWS resource. Tags are key-value pairs, which means each tag will have a key and a value. In the below snapshot Name is a key and terraform is a value. This will help you while finding the resources and performing actions on them. Click on ADD tag to add more tags. You can give any type of key value pair.

 

Step-2: Select Amazon Machine Image  according to your requirements

An Amazon Machine Image is a template configured with an operating system and other pre-installed software packages required to launch an EC2 instance according to your requirements, although you can create your own AMI. You can use any of the preconfigured AMI’s from Community AMI’s or Market Place AMI’s. Community AMI’s are published by users like you and me. Marketplace AMI’s are charged on an hourly usage basis. Below is a snapshot of an AMI description from Market Place AMI’s which has a pre-installed Microsoft SQL Server on Windows. Launching an instance from this AMI allows you to run the instance as a database server and saves your time and effort for installing SQL Server software.

To check all the available AMI’s, click on “Browse more AMIs” under “Application and OS Images.”

In the below snapshot (from the AWS web console) as shown, we have options to select between market place AMI’s, custom AMI’s, and community AMI’s, and on the left pane on Refine results, you can apply filters to search for the required type of AMI.

for this blog I am selecting a free tier eligible (free of cost) “Red Hat Enterprise Linux 8 AMI” to launch the ec2 instance.

 

Step-3: Select Instance Type

The instance type you select determines the hardware of the computer used to launch your instance based on the CPU, memory, storage and networking capacities. Instance types are grouped into

General purpose instances have balanced resources of compute, networking, and memory and can be used for workloads like web servers and code repositories.

Compute optimized instance types have high performance processors powered by AWS Graviton3 processors. These instances are used for batch processing workloads, dedicated gaming servers, media transcoding, and other compute-intensive applications.

Memory optimized  are used for High performance and databases , and processing large data sets in memory.

Storage optimized instances designed for workloads which makes high sequential read and write operations to extremely huge data sets residing on local storage, these instance types are optimized to deliver tens of thousands of low latency Input and Output operations per second for applications.

As shown in below image I am using  instance type t2.micro (1vCPU and 1GiB Memory),click on compare instance types to see all the available instance types.

 

Step-4: Creating a key pair.

To securely connect to your instance create a new key pair or use the existing  one. A key pair consists of a public key and private key , ec2 will store the public key on the instance and you will have the private key. Please download the key pair and when you are creating a new one and store it securely , if you are selecting a existing key pair, please check if you have access to that key pair before creating the instance.

Click on “Create new key pair” to create a new key pair.

Give a name to your key pair ,As shown in the screenshot below, RSA is selected as the encryption type, and under Private key file format, select .pem if you want to connect via SSH, and select .ppk if you want to connect via putty (a terminal emulator). In this blog, you will also learn how to connect to an EC2 instance via open SSH, so select “.pem” for the file format, then click on “create key pair”. A file will be automatically downloaded; store it safely.

Step-5: Creating a security group

The security group acts as a virtual firewall which controls the inbound and outgoing traffic of the resource that it is attached to. It’s a set of rules that you define which network can access which port. Both inbound and outbound rules can be configured separately. In the below snapshot, I am allowing traffic on ports 22 (ssh) and selecting the source type as Anywhere. This means I am allowing traffic on port 22 from any network. You can also create outbound (outgoing traffic) rules for your resources. By default, outbound traffic is allowed from all the ports.

 

Click on edit for “Network Settings”

Select Create security group for Firewall, give a name for your security group and allow traffic on port 22 as we will use SSH to login to the instance. For source type, select Custom and give the network details that you want to give access to (keep it as anywhere if you want to access your instance from any network or your IP address if you will only access it from that machine). Click on “Add security group rule” if you want to allow traffic on any other ports.

after creating  security group scroll down to Summary check the configuration you have selected and click on Launch Instance

 

Connecting to Instance using SSH client 

Click on the view all instances

Now wait till the instance state changes to Running and click on the instance ID that you have created.

Copy your Public IPv4 address

open the terminal from the file location where you stored your key pair (from step-4) and use below command to connect to your instance.

ssh -i "key2.pem" ec2-user@3.109.108.210

secure shell(ssh) is a network communication protocol it allows computers to communicate and share data ,instead of key2.pem give your  pem file name (created in step 4),3.109.108.210 is my instance Public IPv4 address give your IP here.

enter ”yes” when it prompts for confirmation, done ,now you are on remote instance.

Feel free to contact our technical team for more technical information. Hire Google cloud engineer to manage daily GCP cloud devops operations.

Leave a Reply

Your email address will not be published.

*