Create a new EC2 instance in AWS

An EC2 instance is a virtual server in Amazon’s Elastic Compute Cloud (EC2) for running applications on web services (AWS) infrastructure. Instances are created from Amazon Machine Images (AMI).

Prerequisites :

For creating an instance is to enter into the AWS console, for which one needs to Sign in or login in the AWS account.



When you sign in AWS dashboard appears. At upper right corner it shows a region by default, but  you can choose a Region that specifies where your resources are managed. Here we are choosing Frankfurt.



There are multiple ways to navigate to individual services either you can enter the name of service in the search box or you can simply click on services to open full list of services. Here we click on services and the list appears.


AWS provides broad list of services such computing, storage, robotics etc. Here we are selecting EC2 under compute to launch an instance.



Now from the console dashboard choose Launch Instance.




Following are the steps to launch an instance on AWS:-

Step 1 – Choose an Amazon Machine Image (AMI)

It serves as template for your instance. There are many AMI linux, Microsoft, Amazon based. Here we are choosing Amazon Linux 2 AMI (HVM) as it is eligible for free tier.


Step 2 – Choose an Instance Type

Instance type consists combination of memory, storage, network performance, CPU and instance sizes. Choosing Instance type allows you to scale your resources to the requirements of your target workload. Here we choose t2.micro which is free tier eligible and proceed to configure instance details.



Step 3 – Configure Instance Details

Now select number of instances to be launched, here we are selecting only 1 instance. You can also request for spot instance, here we do not require because we choose free tier. You can also select network , subnet, assign public IP, assign IAM role, enable termination protection etc.

But for now we will leave all settings on default and process to next steps




Step 4 – Add Storage

Add storage to your instance, You can increase or decrease the size, choose volume types such as SSD (gp2), SSD (io1) or Magnetic.

General purpose SSD (gp2) : that balances price and performance for a wide variety of workloads. These volumes deliver single-digit millisecond latencies and the ability to burst to 3,000 IOPS for extended periods of time.  Volume size is 1 GiB to 16 TiB.

Provisioned IOPS SSD (i01) : Highest-performance SSD volume for mission-critical low-latency or high-throughput workloads. An io1 volume allows you to specify a consistent IOPS rate when you create the volume. The Volume size is 4 GiB to 16 TiB.

Magnetic (Standard) : Magnetic volumes are backed by magnetic drives and are suited for workloads where data is accessed infrequently, and scenarios where low-cost storage for small volume sizes is important. These volumes deliver approximately 100 IOPS on average, with burst capability of up to hundreds of IOPS. Volume size is 1 GiB to 1 TiB.

Extra or new volume can also be added to instance. Here we leave it with default settings and move to add tags.


Step 5- Add tags

It can be done by clicking add tag. Each tag is a simple label consisting of a customer-defined key and an optional value that can make it easier to manage, search for, and filter resources.



Here we are adding “Name” as key and “Nupur” as Value. Then we will proceed to next step. One can also skip this step.



Different types of tags

Step 6- Configure Security Group

It provides security at the protocol and port access level. Each security group works as much the same way as a firewall and contains a set of rules that filter traffic coming into and out of an EC2 instance

You can either create a new security group or select an existing group.

Select the type of security group according to your requirements , here we are choosing existing security group and leave other settings as default and proceed to next step.


Step 7- Review Instance Launch



Step 8- Create Key pair

When prompted for a key pair, Select Create a new key pair, enter a name for the key pair, and then choose Download Key Pair. This is the only chance for you to save the private key file, so be sure to download it. Save the private key file in a safe place. You’ll need to provide the name of your key pair when you launch an instance and the corresponding private key each time you connect to the instance. Alternatively you can also select existing key pair if you have created earlier.

Don’t select the Proceed without a key pair option. If you launch your instance without a key pair, then you can’t connect to it.

When you save file then proceed to launch your instance.



Step 9- Launch Status

Now you can view the status of the launch. Click on View Instance on the bottom of the page. It takes a short time for an instance to launch. Its initial state is pending, after the instance starts it changes to running and it receives a public DNS name.








Connecting to Amazon EC2 Instance

Now that you have launched your EC2 instance, you can connect to it and use it.

  • Click on connect it gives you a preview to connect your instance.
  • You can find Public DNS or Public IP both on the same page , it will be used to connect to your instance.




  • Connect from Mac or Linux Using an SSH Client.
  • Your Mac or Linux computer most likely includes an SSH client by default.
  • Open your command line shell and change the directory to the location of the private key file that you created when you launched the instance.

Use the chmod command to make sure your private key file isn’t publicly viewable.$

$ chmod 400 my-key-pair.pem

Use SSH command to connect to the instance

$ ssh -i  my-key-pair.pem ec2-user@public_dns_name

so finally you are connected to your instance 🙂

Terminating Instances

  • In the amazon dashboard, select the instance from the instance list.

  • Choose Actions then Instance State and Terminate.

  • Confirm to terminate instance.



  • Amazon EC2 shuts down and terminates your instance




Now you can try creating other instances using different AMI and instance types, and try connecting to your instances.