How to Launch EC2 Instance in AWS[Step by Step]?

This post originally appeared in my blog: askvikram.com. Click here to read it in my blog.

Introduction

AWS EC2 is a virtual machine that provides secure, resizable compute capacity in the cloud. It provides dedicated server resources to host your web sites.

In this tutorial, you’ll launch the AWS EC2 instance with the free tier eligible options.

Prerequisites

  • Create an account in aws.amazon.com and login to the aws console.
  • Ensure you have EC2 Creation rights in the AWS Account if you are using an account created by your organization.

Step 1 - Selecting EC2 from AWS Console

In this step, you will navigate the EC2 home page from the AWS console home page to create the EC2 Instance.

Click Services option available in the top left. You’ll see all the available AWS services. Select EC2 under the compute section of the page.

You’ll be taken to the EC2 home page. Select Launch instance button as shown below to launch an EC2 instance.

Step 2 - Choosing an Amazon Machine Image

Amazon machine image is a template which contains the complete software stack such as Operating system, application servers and other applications which are necessary to host an EC2 Instance.

AMIs are provided by AWS, the user community and also other providers in the AWS Marketplace.

Here, you'll select the AMI provided by Amazon AWS which is eligible for the free tier.

Select the option as shown in the image and click next to select the instance type.

Step 3 - Choosing an Instance Type

Instances are different types of servers which can run the applications.

Each instance type comprises CPU, memory, storage, and networking capacity which gives you the flexibility to choose the appropriate mix of resources for your applications.

In this tutorial, you’ll select t2.micro instance type which is free tier eligible. You get up to 750 hours of micro instances each month.

t2.Micro has 1 virtual CPU, 1GiB memory with low to moderate network performance. This is sufficient to try out the AWS EC2. This is scalable at the later point of time. So if you need more computing capacity based on your growth, you can scale as required.

Step 4 - Configuring Instance

In this step, you’ll configure the selected instance such as the number of instances to be launched and other networking options for the instances.

Most of the options can be let as it is with the default value.

In section 7 on this page, you can optionally enable termination protection to prevent accidental termination. If enabled, this instance cannot be terminated using the AWS Console.

You can also select Monitoring to enable cloudwatch detailed monitoring functionality.

This will Monitor, collect, and analyze instance metrics through Amazon CloudWatch where data is available in 1-minute periods. The default monitoring with Cloudwatch is free, basic monitoring, where data is available in 5-minute periods.

Now, click next to configure storage to your instance.

Step 5 - Adding Storage

In this step, you’ll configure storage for your instance. Storage is the place where the operating system data and the user data will be stored.

By default, a root volume is added with the default configuration, 8 GiB storage with the general purpose SSD volume type. Volume types are the different types of storage volumes available for different purposes. To know more about other volume types, read about different volume types available.

You can increase or decrease the size of the storage volume in the size column. Upto 30GB of EBS General Purpose (SSD) is eligible for the free tier.

Next you’ll configure what should happen to the storage volume when this instance is deleted.

Delete on Termination is enabled by default. This will delete this storage when you terminate the instance. If you would like to retain this storage even after deleting this instance, unselect Delete on Termination option.

Additionally, if you would like to enable Encryption of the data in this volume, you can enable it in the Encryption column by selecting the default Key Value created by amazon. You can also create keys for encryption by yourself.

Now, you have completed configuring the storage for your instance. Click next to add tags.

Step 6 - Adding Tags

In this step, you’ll add tags to your instances and storage volumes.

Tags are used to easily categorize or group the resources in the aws. It consists of the case sensitive key value pair.

If you would like to tag your instance and storage, add a tag and assign to this instance. If you don’t want to group this instance, you can leave it empty.

Now, click next to configure security group.

Step 7 - Configuring Security Group

Security group is a set of firewall rules to control the traffic for your instance. In other words, You can define which IP address is allowed to access your instance via a defined port.

You can create a security group by adding a security group name and security group description. This will save the security group and it can be reused while creating other instances.

By default, a rule with ssh type, port 22 with source ip 0.0.0.0/0 is added.

SSH is a type which is used to connect to a linux instance using the port 22. 0.0.0.0/0 means it will allow all IP addresses to access your instance using the port 22.

If you are planning to host a website in this instance and make it visible to the public, you can add a rule https type with port 443 with source ip as 0.0.0.0/0. This will allow any IP address to access this instance with the port 443 with https instance.

Now, you have configured security group. Click next to review your instance settings and finally launch it.

Step 8 - Reviewing and Launching

This is the final step before launching your instance.

You can review the AMI details, Instance type, security groups, instance details, storage, tags to ensure if its correctly configured for your requirement.

If you’re ok with the configuration details, you can click Launch.

This will ask you to create a new key pair which can allow you to connect to your instance securely.

Select the option Create a new key pair option in the first combo box. Enter name for your key pair and click Download to download your private key. The private key will be downloaded in pem format which you can use to login to your instance.

Warning: If you would like to proceed without a keypair, you must know the password built into the Amazon Machine image you have selected in the step-1 of this tutorial. However, it's recommended to use the key pair for authentication for the better security of your instance.

Finally click Launch to launch the instance.

Now, your instance will be launched based on the configuration you’ve selected.

Check how to connect to your instance in various ways.

Conclusion

In this tutorial, you have launched an EC2 instance with the free tier eligible options. You can go ahead and host any dynamic or static websites in this instance.