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


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 EC2 instance in AWS step by step with the free tier eligible options.


  • Create an account in 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.

launch ec2 instance in aws  select EC2 service

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

launch ec2 instance in aws select launch Instance option

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.

launch ec2 instance in aws  shoosing machine image

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.

launch ec2 instance in aws  choosing instance type

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.

launch ec2 instance in aws  configuring instance details

In section 7 on this page as marked in red, 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.

If you would like to have any packages installed by default in your instance, you can specify it in the Advanced details -> User Data section. For e.g. If you would like to install WordPress by default in your EC2 instance, place the below script the User data section.

yum install httpd php php-mysql -y
cd /var/www/html
tar -xzf wordpress-latest.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf wordpress-latest.tar.gz
chmod -R 755 wp-content
chown -R apache:apache wp-content
service httpd start
chkconfig httpd on
  • yum install httpd php php-mysql -y – To install httpd apache server, php, mysql servers. These are the packages required to run WordPress
  • cd /var/www/html – to navingae to the html directory from where the apache will server files
  • wget – To download the WordPress latest stable version to your local directory
  • tar -xzf wordpress-latest.tar.gz – To extract the wordpress zip file to the local directory
  • cp -r wordpress/* /var/www/html/ – To copy the WordPress sources files to the HTML directory
  • rm -rf wordpress – Remove extracted wordpress version
  • rm -rf wordpress-latest.tar.gz – Remove the WordPress installation
  • chmod -R 755 wp-content – To change the necessary permissions of the wp-content folder so that its accessible
  • chown -R apache:apache wp-content – To provide apache user the necessary access to the wp-content folder
  • service httpd start – To start the Apache tomcat server
  • chkconfig httpd on – To check if the apache server is working

With this, wordpress will be installed by default when you launch the ec2 instance.

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.

launch ec2 instance in aws - adding storage

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.

launch ec2 instance in aws - adding tags

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 is added.

SSH is a type which is used to connect to a linux instance using the port 22. 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 This will allow any IP address to access this instance with the port 443 with https instance.

launch ec2 instance in aws  - configuring security group

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.

launch ec2 instance in aws  - creating a key pair

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.


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

What Next?

How to execute shell commands from Python?

how to launch linux ec2 instance in aws?

Select the Linux Amazon Machine image in the step 2 of this tutorial. Then you can launch Linux EC2 instance.

What is the cost to launch ec2 instance in aws marketplace?

One year free tier is available when you do it by following this guide. However, if you are using the lightsail option available in AWS, then one month is free and thereafter, you’ll be charged minimum 5$.

What is the cheapest EC2 instance?

T2 instances are a low-cost, general purpose instance type that provides a baseline level of CPU performance with the ability to burst above the baseline when needed.

How long does it take to start an ec2 instance?

Linux instances are frequently ready 60-90 seconds after launch. Windows instances take considerably longer because the AMI has been configured for sysprep, which involves a reboot.

Does a stopped ec2 instance cost money?

No AWS doesn’t charge for the stopped EC2 instance. However, you’ll be charged for the other resources such as storage you have attached to your instance.

Can I restart a terminated ec2 instance?

No, you cannot restart the terminated instance. When you terminate, your instance is destroyed.

how to create amazon ec2 instance windows

Select the windows Amazon Machine image in the step 2 of this tutorial. Then you can launch Windows EC2 instance.

Leave a Comment

Share via
Copy link
Powered by Social Snap