In this post, We are going to create a Linux virtual machine hosted on the cloud (also known as Instance) using Amazon EC2. Amazon Elastic Compute Cloud (Amazon EC2) is an IaaS (Infrastructure as a Service) that provides secure, resizable compute capacity in the cloud.
Sign in to the Amazon Management Console.
From the navigation bar, choose a suitable geographic region that meets your requirements.
Tip: Choose a nearer geographic region from your location to get faster responses
Choose EC2 inside the Compute section of All services, It will redirects you to the Amazon EC2 Console
From the EC2 dashboard choose Launch Instance
Choose an Amazon Machine Image (AMI)
Select an appropriate Amazon Machine Image(AMI). An AMI is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance
Tip: Choose Ubuntu if you are not familiar with other machine images
Choose an Instance Type
Choose a suitable Instance type as per your needs. An Instance type describes the hardware specifications of the virtual machine (i.e. CPU, memory, storage, and networking capacity) and then click next.
Tip: Choose t2.micro, Because it is the only instance type which is eligible for free tier
Configure Instance Details
In this step, We can configure our instance i.e Network type, IP allocation, Monitoring, IAM role, etc. If you don't have any prior knowledge of cloud computing then I would recommend you to not change any setting and simply click next.
An Amazon EBS Volume is similar as physical hard drive. In order to store data, We need to attach EBS volume to an instance. You can attach any size of disk space as per your needs. Free tier eligible customers can get up to 30 GB of EBS. We are choosing 25 GB disk space with General Purpose SSD (GP2) instance type.
Enable "delete on termination" checkbox. It will delete the disk space associated with the server, whenever the server will terminate.
A tag is a key-value pair that you assign to an instance to uniquely identify them from a group. It doesn't alter instance's functionality. Click on add tag button, Enter "Name" in key field and "myserver" in value field. then click next.
Configure Security Group
A security group controls inbound and outbound traffic from the server. There are set of protocol by which we can access the instance server i.e. HTTP, HTTPS, SSH.
- Click on Create a new security group in assign a security group section.
- Enter a security group name and description.
- Now you need to define some protocol by which you are going to access the server. SSH protocol is added automatically, so you don't need to add it manually. Choose anywhere in source drop-down box of SSH protocol. This makes your server accessible from anywhere. Alternatively, You can bound the server with custom IP address as well.
- Now click review and launch.
Review Instance Launch
Review your instance launch details. You can go back to edit changes for each section. If all details are correct then you can click on launch.
- It will ask you to select an existing key pair or create new key pair. A key pair, consisting of a private key and a public key which is used to access instance server securely. Creating a new security group for individual server is the best practice.
- Enter key pair name and click on Download Key Pair button, Once you are done downloading, Save this key in a secure folder and then click on Launch Instance button. Note:- If you lost your key pairs, then you will not able to download it again.
Open Terminal or Command Prompt, Go to the folder where you store the key pair file and type the command
ssh -i key-pair.pem ubuntu@public_ip
replace "key-pair.pem" with your key-pair file name and public_ip with your instance's public ip.
sudo su - sudo apt-get update
So we have successfully created and accessed an instance server. With the help of ec2 instance we can build web server, database server, vpn server, game server, data analysis server, geolocation or map server and lot more.
We'll going to build or experiement all of this with our EC2 Server.