How to Launch Linux EC2 Instance in AWS

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity on the Amazon Web Services cloud. An instance is a virtual server with flexible capacity. With EC2, you can set up and configure the operating systems and applications that run on your instances ie. servers. Here we will learn how to launch Linux EC2 Instance in AWS. So Let’s get started with Amazon EC2 by launching a Linux instance.

Prerequisite

  • An Account on AWS with Web Console Access
  • Good speed Internet Connection

Launching an Amazon EC2 Instance

Here we will launch a linux instance ie. ubuntu 20.04 which will be Amazon EBS-backed instance means root volume is an EBS volume. You can either specify the Availability Zone in which you want your instance should run, or let Amazon select an Availability Zone for your instance. When you launch an instance, you have to secure it by specifying a key pair and security group. When you connect to your instance, you must connect it with  the private keys of the key pair that you specified earlier when launching your EC2 instance.

amazon ec2

Amazon EC2 Console

You can access Amazon EC2 console at https://console.aws.amazon.com/ec2/

Amazon Ec2 console

From the console dashboard, choose Launch Instance.

Amazon Ec2 console

Choose an Amazon Machine Image

The section shows a list of basic configurations of AMIs that is a templates for linux and windows instance. Select the AMI for your favourite linux distribution. We will launch Ubuntu 20.04 LTS.  Choose your desired AMI and click on Select.

choose an AMI

Choose instance type

For practice, you should go for Free tier eligible AMIs. By default, t2.micro type is selected. Notice that this instance type is eligible for the free tier. Click on Next: Configure instance Details.

choose instance type

Configure instance details

This section contains various options related to instance configuration. You can specify how many instances you want to launch. You can specify purchasing options, Network related details, IAM Roles, Machine Behaviour, File System and Advance details with metadata and userdata. In network section, you can specify Virtual private cloud, subnet and elastic IP or pool IP. You can specify placement group so that you can launch all your instances on a particular Server Racks.

configure instance details

You can configure instance shutdown behaviour, enable cloudwatch monitoring, tenancy (shared hardware resources or dedicated hardware for your instance) etc.

configure instance details

In Userdata option, you can execute commands or install packages while  instance creation. Now click on Next: Add storage.

configure instance details

Add Storage

In this section, you can specify resize root volume and change volume type and you can enable encryption. If required you can add additional volumes. Next click on Next: Add Tags.

add storage in EC2 instance

Add Tags

You can specify the tags ie. name of the launched instances to create standard inventory so that anybody can distinguish instance type.

adding tags in EC2 instance

Here we specified the name of our instance. Next click on Next: Configure Security Group.

added tags in EC2 instance

Configure Security Group

This is like firewall in AWS. To access you EC2 instance and it’s services, you have to open those services or ports in Security Group. You can maintain a single security group and attach it every newly launched EC2 instance. Here we will create new security group and will open ssh port 22. By default. SSH port 22 opened for Linux instance and RDP port 3389 for windows instances. Next click on Next: Review and Launch.

configure security group on EC2 instance

Review Instance Launch

Here, you can review all the settings you specified in each section. Once you are done, you can click on Launch.

ec2 review and launch

Generate private Key Pair

Next, you have to either create a new key pair or use existing key pair. You have to download a private key in a safe location in your local machine and AWS stores public key. This key pair is required to connect to your launched instance. After downloading newly created key in your local computer, you will be able to launch EC2 instance. Next click on Launch Instance.

EC2 instance key pair generate

EC2 Instance Launch Status

After clicking on Launch Instance, you will get following screen:

ec2 instance launch status

You can see the newly launched EC2 instance in EC2 console as follows. Here status check is initializing and takes approx 2-3 minutes to get it done.

ec2 instance launch status

Here instance has passed both System Status Check and Instance Status Check.

ec2 instance launch status

Finally, your EC2 instance has been launched and you can connect it either using putty or git bash via ssh protocol. Private key is must while connecting EC2 instance.

Conclusion

Hence you have successfully launched EC2 instance using AWS web console. I hope you enjoyed this tutorial. Stay tuned for more on Cloud Computing, DevOps, Linux etc. Thanks!!

Read Also :   How to Resize Attached EBS Volumes of Linux Instance without downtime on AWS

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment