Published on

How to Create EC2 Instance on AWS – Detailed Beginner’s Guide

Published on

How to Create EC2 Instance on AWS – Detailed Beginner’s Guide

In this tutorial, you will learn step by step guide to create EC2 instance on AWS.

What is Amazon EC2 Instance?

An EC2 instance is nothing but a virtual machine in Amazon terminology. It stands for Elastic Compute Cloud.

In simple words, its like your machine – where you will install your applications and perform tasks. You can access EC2 instance from anywhere in the world and manage on the go.

Read the official Amazon AWS documentation for more information.

Create EC2 Instance on AWS

Follow bellow steps to create EC2 instance on AWS.

Login and access to AWS Services

Step 1:

  • Login to your AWS Console, click on Services tab at the top and select the EC2 under Compute.
aws-services
  • Next you will be directed to EC2 Dashboard, where you will find no of instances running, key pairs, Elastic IPs, security groups, etc.,
ec2-dashboard

Step 2: On the top right, select AWS Region in which you want to provision the EC2 server.

As of now AWS provides 21 Regions all over the globe and this number may increase in future. Here, we have selected region N. Virginia.

create ec2 instance

Step 3: Switch back to EC2 Dashboard and click on Launch instance.

You will see two options:

  • Launch instance – launch instance from start.
  • Launch instance from template – choose a pre-filled template to launch instance.

Select Launch instance and as soon as you click on Launch instance, you will be redirected to instance creation wizard.

Configure your instance as follows,

Choose AMI

  • You will be asked to choose your AMI (Amazon Machine Image). Its basically an operating system that you will be using to create your instance. For example, installing an operating system (windows or linux) on your machine.
  • Once you selected the your desired operating system, an instance will automatically booted with the OS that you opted.

For this example, select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type and click on Select.

select-ami

Choose Instance Type

Select the instance type based on your business requirements,

  • Let’s choose the t2.micro (free trier) – which has 1 vCPUs, 2.5 GHz, and 1 GiB memory.
  • Next click on configure instance details.
select-instance-type

Configure Instance

Configure the instance as follows or depends on your business needs.

Step 1: Choose the no of instances you want to create with the same configuration. You can create up to 20 instances.

no-of-instances

Step 2: Under purchasing options, keep the Request Spot instances unchecked. This is required when we wish to launch spot instances instead of on-demand instances.

purchasing-options

Step 3: Now we will need to configure basic networking details for EC2 instances.

  • In the Network configuration,
    1. You can create new VPC
    2. You can select the existing VPC
network-configure

For now let’s use the default VPC and will learn how to create new VPC in next tutorial.

  • In the Subnet configuration,
    1. You can create new subnet
    2. You can select the existing subnet
subnet-config

Once your instance is launched in a public subnet, AWS will assign a dynamic public IP to it from their pool of IPs.

Step 3: You can either choose Auto-assign IP – If you want to AWS to assign it an IP automatically, or you want to do it manually later.

auto-assign-ip

Step 4: Next keep Placement group unchecked and Capacity reservation open. You can change these values as per your needs.

Placement group is useful when you want greater redundancy and higher network throughput.

Capacity reservation useful when if you want to reserve capacity for your EC2 instances in specific Availability Zones.

placement-group

Step 5: Configure the Domain join directory and the IAM role.

Domain join enables you to join your instance to a directory you’ve defined in AWS Directory Service, giving you a single sign-on and centralized management experience across a network of Windows and Linux instances.

aws-doimain

We have not joined due to some access related issues but in your organization you can select the directory or you can create directory (in case, if you have an access).

Step 6: Now configure the remaining options as follows,

additional-config
  1. Select the instance behavior when OS level shutdown is performed. You can either select Stop or Terminate.
  2. Enable this If you want to save contents of the instance’s RAM to root volume.
  3. Enable If you want to protect instance from being accidentally terminated. Note: If you enable then you can’t terminate instance from API or AWS Console until you disable.
  4. Enable this If you want to monitor, collect instance metrics thru Amazon CloudWatch.
  5. You will get three options to choose,
    • Shared
    • Dedicated
    • Dedicated Host
  6. Elastic Inference provides cost efficient hardware acceleration for deep learning inference for all EC2 instance types, at a fraction of the cost of standalone GPU instances.
  7. Selecting Unlimited for the credit specification allows applications to burst beyond the baseline for as long as needed at any time. 
  8. Specify Amazon EFS file systems to mount to your instance. 

If you are using free trier then please do check above features charges and select if its necessary.

Step 7: Configure advanced details (1) if required and click on Add Storage (2).

advanced-config

Add Storage

Here you will see the instance has been automatically provisioned a General Purpose SSD root volume of 8GiB.

  1. You can either choose the default 8 GiB General Purpose SSD volume or you can increase If required.
  2. AWS provides 3 types of EBS volumes- Magnetic, General Purpose SSD (gp2,gp3), Provisioned IOPs( io1,io2). You can select any one depends your your application’s IOPs needs.
  3. Click on Add Tags
add-storage
aws fundamentals

Add Tags

This gives visibility to the AWS account administrator when there are multiple instances and the instances should be tagged based on the department/environment such as DEV/SIT/PROD, etc.,

  1. Add your tags in key-value pair
  2. Click on Configure Security Group
tags

Configure Security Group

In this next step we can configure security groups to restrict traffic to our instance ports. This is an added firewall mechanism provided by AWS apart from your instance’s OS firewall.

This configuration is up to your business needs and how you are going to access your instances.

Note: You can either create new security group or choose an existing security group.

  1. Select the types (SSH, HTTP, HTTPS, etc.,)
  2. Choose the Source (Custom, Anywhere or Your own IP)
  3. Once you configured then click on Review and Launch
security-groups

Configure Security Group

Step 1: Review your instance configuration and edit if required and click on Launch.

review-instance

Step 2: In the next screen, you can either select the existing key pair or create new key pair.

  1. Select Create a new key pair
  2. Name your key pair
  3. Download the Key Pair
  4. Finally click on Launch Instances
key-pair-ec2

Make sure to store these key pair in secure place to avoid unauthorized access.

That’s simple! Your instances will be up and running in less than 5 minutes and Click on Instances tab see the status of your instances.

list-instances

Now click on any one of your instances.

instance-details

There you can see that the instance has received a Public IP from the pool of AWS automatically.

But If you want to persist an IP even if my instance is stopped and restarted then you can use Elastic IP address.

Follow below steps to create EIP and associate EIP to your instance.

Create EIP and Associate to Instance

An EIP is a static public IP provided by AWS and its stands for  Elastic IP. Basically when you create an instance, it will receive a public IP from the AWS’s pool automatically.

 If you stop/reboot your instance, this public IP will change. In order have a static IP for your instance, you can use an EIP.

Step 1: On the left side (EC Dashboard) panel, click on Elastic IPs under Network & Security.

elastic-ip

Step 2: Next click on Allocate Elastic IP Address

allocate-ip

In the next screen, select the Network Border Group, Tags (optional) and click on Allocate.

border-group
ip-tags

Step 3: Now in the Elastic IPs dashboard, select any Elastic IP that we created before, click on Actions and select Associate Elastic IP address.

eip-actions

Step 4: In the next screen,

  1. Select Resource Type as Instance
  2. Select the Instance from drop down list
  3. Select the private IP address from the drop down list
  4. Click on Allocate
allocate-eip-address

That’s simple!

Step 5: Now switch back to Instances and verify public IP address.

reserved-ip

There you can see you got a new Public IP address which is reserved for your instance even if your instance restart/crash.

aws fundamentals

Conclusion

We hope this tutorial helped you to understand what is EC2, how to create EC2 instance and also how to create and associate Elastic IP address to an instance.

If you feel that we missed some vital information, please do let us know in the comment section and we are happy to take your suggestions.

Please do share it with your friends and don’t forget to follow us on FacebookTwitter and LinkedIn. Visit our AWS Hub for more tutorials and updates.

In this tutorial, you will learn step by step guide to create EC2 instance on AWS.

What is Amazon EC2 Instance?

An EC2 instance is nothing but a virtual machine in Amazon terminology. It stands for Elastic Compute Cloud.

In simple words, its like your machine – where you will install your applications and perform tasks. You can access EC2 instance from anywhere in the world and manage on the go.

Read the official Amazon AWS documentation for more information.

Create EC2 Instance on AWS

Follow bellow steps to create EC2 instance on AWS.

Login and access to AWS Services

Step 1:

  • Login to your AWS Console, click on Services tab at the top and select the EC2 under Compute.
aws-services
  • Next you will be directed to EC2 Dashboard, where you will find no of instances running, key pairs, Elastic IPs, security groups, etc.,
ec2-dashboard

Step 2: On the top right, select AWS Region in which you want to provision the EC2 server.

As of now AWS provides 21 Regions all over the globe and this number may increase in future. Here, we have selected region N. Virginia.

create ec2 instance

Step 3: Switch back to EC2 Dashboard and click on Launch instance.

You will see two options:

  • Launch instance – launch instance from start.
  • Launch instance from template – choose a pre-filled template to launch instance.

Select Launch instance and as soon as you click on Launch instance, you will be redirected to instance creation wizard.

Configure your instance as follows,

Choose AMI

  • You will be asked to choose your AMI (Amazon Machine Image). Its basically an operating system that you will be using to create your instance. For example, installing an operating system (windows or linux) on your machine.
  • Once you selected the your desired operating system, an instance will automatically booted with the OS that you opted.

For this example, select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type and click on Select.

select-ami

Choose Instance Type

Select the instance type based on your business requirements,

  • Let’s choose the t2.micro (free trier) – which has 1 vCPUs, 2.5 GHz, and 1 GiB memory.
  • Next click on configure instance details.
select-instance-type

Configure Instance

Configure the instance as follows or depends on your business needs.

Step 1: Choose the no of instances you want to create with the same configuration. You can create up to 20 instances.

no-of-instances

Step 2: Under purchasing options, keep the Request Spot instances unchecked. This is required when we wish to launch spot instances instead of on-demand instances.

purchasing-options

Step 3: Now we will need to configure basic networking details for EC2 instances.

  • In the Network configuration,
    1. You can create new VPC
    2. You can select the existing VPC
network-configure

For now let’s use the default VPC and will learn how to create new VPC in next tutorial.

  • In the Subnet configuration,
    1. You can create new subnet
    2. You can select the existing subnet
subnet-config

Once your instance is launched in a public subnet, AWS will assign a dynamic public IP to it from their pool of IPs.

Step 3: You can either choose Auto-assign IP – If you want to AWS to assign it an IP automatically, or you want to do it manually later.

auto-assign-ip

Step 4: Next keep Placement group unchecked and Capacity reservation open. You can change these values as per your needs.

Placement group is useful when you want greater redundancy and higher network throughput.

Capacity reservation useful when if you want to reserve capacity for your EC2 instances in specific Availability Zones.

placement-group

Step 5: Configure the Domain join directory and the IAM role.

Domain join enables you to join your instance to a directory you’ve defined in AWS Directory Service, giving you a single sign-on and centralized management experience across a network of Windows and Linux instances.

aws-doimain

We have not joined due to some access related issues but in your organization you can select the directory or you can create directory (in case, if you have an access).

Step 6: Now configure the remaining options as follows,

additional-config
  1. Select the instance behavior when OS level shutdown is performed. You can either select Stop or Terminate.
  2. Enable this If you want to save contents of the instance’s RAM to root volume.
  3. Enable If you want to protect instance from being accidentally terminated. Note: If you enable then you can’t terminate instance from API or AWS Console until you disable.
  4. Enable this If you want to monitor, collect instance metrics thru Amazon CloudWatch.
  5. You will get three options to choose,
    • Shared
    • Dedicated
    • Dedicated Host
  6. Elastic Inference provides cost efficient hardware acceleration for deep learning inference for all EC2 instance types, at a fraction of the cost of standalone GPU instances.
  7. Selecting Unlimited for the credit specification allows applications to burst beyond the baseline for as long as needed at any time. 
  8. Specify Amazon EFS file systems to mount to your instance. 

If you are using free trier then please do check above features charges and select if its necessary.

Step 7: Configure advanced details (1) if required and click on Add Storage (2).

advanced-config

Add Storage

Here you will see the instance has been automatically provisioned a General Purpose SSD root volume of 8GiB.

  1. You can either choose the default 8 GiB General Purpose SSD volume or you can increase If required.
  2. AWS provides 3 types of EBS volumes- Magnetic, General Purpose SSD (gp2,gp3), Provisioned IOPs( io1,io2). You can select any one depends your your application’s IOPs needs.
  3. Click on Add Tags
add-storage
aws fundamentals

Add Tags

This gives visibility to the AWS account administrator when there are multiple instances and the instances should be tagged based on the department/environment such as DEV/SIT/PROD, etc.,

  1. Add your tags in key-value pair
  2. Click on Configure Security Group
tags

Configure Security Group

In this next step we can configure security groups to restrict traffic to our instance ports. This is an added firewall mechanism provided by AWS apart from your instance’s OS firewall.

This configuration is up to your business needs and how you are going to access your instances.

Note: You can either create new security group or choose an existing security group.

  1. Select the types (SSH, HTTP, HTTPS, etc.,)
  2. Choose the Source (Custom, Anywhere or Your own IP)
  3. Once you configured then click on Review and Launch
security-groups

Configure Security Group

Step 1: Review your instance configuration and edit if required and click on Launch.

review-instance

Step 2: In the next screen, you can either select the existing key pair or create new key pair.

  1. Select Create a new key pair
  2. Name your key pair
  3. Download the Key Pair
  4. Finally click on Launch Instances
key-pair-ec2

Make sure to store these key pair in secure place to avoid unauthorized access.

That’s simple! Your instances will be up and running in less than 5 minutes and Click on Instances tab see the status of your instances.

list-instances

Now click on any one of your instances.

instance-details

There you can see that the instance has received a Public IP from the pool of AWS automatically.

But If you want to persist an IP even if my instance is stopped and restarted then you can use Elastic IP address.

Follow below steps to create EIP and associate EIP to your instance.

Create EIP and Associate to Instance

An EIP is a static public IP provided by AWS and its stands for  Elastic IP. Basically when you create an instance, it will receive a public IP from the AWS’s pool automatically.

 If you stop/reboot your instance, this public IP will change. In order have a static IP for your instance, you can use an EIP.

Step 1: On the left side (EC Dashboard) panel, click on Elastic IPs under Network & Security.

elastic-ip

Step 2: Next click on Allocate Elastic IP Address

allocate-ip

In the next screen, select the Network Border Group, Tags (optional) and click on Allocate.

border-group
ip-tags

Step 3: Now in the Elastic IPs dashboard, select any Elastic IP that we created before, click on Actions and select Associate Elastic IP address.

eip-actions

Step 4: In the next screen,

  1. Select Resource Type as Instance
  2. Select the Instance from drop down list
  3. Select the private IP address from the drop down list
  4. Click on Allocate
allocate-eip-address

That’s simple!

Step 5: Now switch back to Instances and verify public IP address.

reserved-ip

There you can see you got a new Public IP address which is reserved for your instance even if your instance restart/crash.

aws fundamentals

Conclusion

We hope this tutorial helped you to understand what is EC2, how to create EC2 instance and also how to create and associate Elastic IP address to an instance.

If you feel that we missed some vital information, please do let us know in the comment section and we are happy to take your suggestions.

Please do share it with your friends and don’t forget to follow us on FacebookTwitter and LinkedIn. Visit our AWS Hub for more tutorials and updates.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related Articles

How to Create Multiple Folders at Once in Windows 10

Creating folders and subfolders manually is time consuming tasks...

How to Integrate Solace with MuleSoft using JMS API

In this tutorial, we will demonstrate step by step...

How to Open Port on AWS EC2 Instance

In this tutorial, we will demonstrate step by step...

LEAVE A REPLY

Please enter your comment!
Please enter your name here