Setup an EC2 instance with ubuntu 20.04 server
EC2 (Elastic Compute Cloud) instances are AWS cloud computing service which are basically virtual machine running in cloud (this is also option of bare-metal). There are various type of EC2 which are either general, memory, storage, or GPU centric. You can also configure number of CPUs, amount of RAM, storage, and networking and tailor it to you need.
EC2 also supports Microsoft windows as the operating system. In this story I will cover setting up Linux operating system.
Step 1
Search for EC2 in the AWS search bar and select EC2 in the Services column.
Step 2
Click on Launch instances in the top right side of the web page
Step 3
Type “ubuntu server” in the search bar and then select Ubuntu Server 20.04 LTS (HVM), SSD Volume Type with 64-bit (x86) Processor. Ubuntu Server 20.04 is the latest version available for the flavor Ubuntu.
Note: Sometimes you find it difficult to setup a package in Ubuntu Server 20.04. Then you can downgrade to 18.04 LTS version of Ubuntu Server.
It is better to select x86 processor because I am assuming you are going to use the server for development or deployment and most packages are built for x86 processor. There are some software packages that are specifically built for Arm processors. At that time you can select Arm
Note: I will recommend to stick to the Free tier eligible AMIs for the beginners so that you do not incur any heavy charges. If you are careful enough and stop the instances when they are not in use you may even not have to pay a single dime for the first year of the account creation.
Step 4
Make sure the checkbox is selected in the t2.micro EC2 instance type. This EC2 type has 1 virtual CPU and 1 GB of RAM. The CPU is virtual because the instance is setup on a hypervisor which enables AWS to create these virtual machines. There are more than a handful of options to select from, selecting a type mainly depends upon the configuration of CPU, RAM and Network Performance. When you are starting new you should always select t2.mirco at the drop of the hat. Selecting EBS only with allow you only one EBS volume. Select SSD type volumes will allow you multiple ephemeral SSD volumes.
If you want to explorer different EC2 types go through the following links.
AWS doc
Comparisons
Step 5
In the Configure Instance Details section we don’t have to make any changes. However I will give a rundown of available settings in brief. These are quick introduction to different concepts of AWS service. These are optional to know.
We can set the Number of instances with will be launch with this current configuration. Request Spot instances is the option to pay AWS upfront to reduce cost incurred in a longer run. In Network we can select the default VPC i.e. Virtual Private Cloud. It is basically a fancy way of configuration your private cloud network among different resources and manage the connectivity. We can select different Subnet in your VPC. Auto-assign Public IP give us option of auto assign an Public IP through which our EC2 will be reachable from the internet or later we can assign our own elastic IP address.
All EC2 instance are spread across different hardware in the server center. Placement groups are to place interdepended EC2 instance together in hardware available to reduce risk of downtime.
Capacity Reservation of EC2 instance in a specific Availability Zone, upside of this in contrast to Reserved Instance and Saving Plans that it does not require 1–3 years of commitment to the plan. It can created any time. Good for handling predicted seasonal increase of traffic. Downside is that it does not gives benefits of having a discounted price.
Domain join directory is a feature that is helpful for enterprises where it allow user on same authorization level to have access to data made available to that authorization group.
When an IAM Role is selected, it is attached to the your EC2 resource. This IAM Role manages the authorizations of the EC2 instance.
Configure Tenancy to determine if the instance runs of shared hardware, dedicated single tenant hardware, or dedicate physical hardware.
Amazon Elastic Inference allows you to attach low-cost GPU-powered acceleration to Amazon EC2 and Sagemaker instances or Amazon ECS tasks, to reduce the cost of running deep learning inference by up to 75%. Amazon Elastic Inference supports TensorFlow, Apache MXNet, PyTorch and ONNX models. This is straight from AWS documentation, which means you can run Deep Learning models in your instance with reduced cost.
In User Data you can write your script outside the instance, which can be on EC2 spin up. This is very helpful in scaling your EC2 resources.
As we select t2.micro instance with only EBS only storage we will get one storage volume. We can select the type of EBS volume it can be General Purpose SSD (cost effective), Provisioned IOPS SDD (High I/O capability), or Magnetic Storage.
AWS Tags for labels assigned to your resources. This help to monitor the cost and the resource.
We are going to access our instance with SSH connection from a terminal. So Select Create a new security group and add a single rule with type SSH and select Source My IP. This will make the instance be accessible using SSH from our computer only. If your IP is not static, you can also select Anywhere but later make sure you change the settings back to custom or My IP in the security group dashboard for security reasons.
We have everything set. Click on Launch.
We will get an option to select Create a new key pair and give key pair a name as I have given file-share.
Click on the Download Key Pair. Save the key pair securely on the computer. Then, Click on Launch Instance.
Once it says that Your instances are now launching, we should click on the Instance ID as marked in the image above.
This is open EC2 dashboard. Here we can see that it shows Initializing in the Status check. This is take some minutes before it get completely initialized.
We should refresh the page after some minutes. When the Status check shows checks passed, we can connect to our instance.
Click on the check box on the left and click on the Connect button.
This will open Connect to instance dialog. Click on the Connect button and a new page will be open with linux terminal in web page.
We have successfully setup our EC2 service with Ubuntu Server 20.04.