In previous post I showed you that how you will create your AWS account and activate by requesting Increasing Instance limits. In this post you will see how we can launch our first Elastic Compute Cloud knowns as EC2 Linux Virtual Machine by following simple steps and within 5 minutes.
1. First and foremost thing is “Selecting the right Region” which is a geographical location where AWS is having their Datacenters. It is important for the performance point of view as we need to put our infrastructure as near as possible from our end users. it will reduce the latency which will improve the user experience.
Click on the top left where you will see the drop down showing all the regions. I select the Mumbai region.
2. Now you will see the All Services Menu. Just click it to expand and select “EC2”.
3. You will present with the options but don’t get confuse yourself by seeing overwhelm things. This is just a beginning of AWS world. In near future, we will explore other features also which are present therein EC2 screen.
Click on Launch Instance which is in this big blue bar.
4. Now you will be able to see the 7 Steps from which you need to choose the options, according to which you will get your Virtual Machine.
The first option is to choose the Operating System. You can scroll down to see the whole list which contains Ubuntu, RedHat, Suse, AWS own Linux version which is a fork of Redhat kind system, Windows Server OS and Few option in which there are preinstalled software there like MSSQL Server on Windows Server 2012 or Some Deep Learning Libraries preinstall/Bundled on Linux Distribution.
If you notice underneath every OS logo it is mentioned that “Free tier Eligible” which means if you have new AWS account and you are just exploring it then try the free tier service which will cost you nothing under certain limits.
In AWS world this OS selection is known as “Amazon Machine Image” which is published by AWS.I am going to choose “Ubuntu 16” AMI as this tutorials is about launching EC2 Linux instance.
Note: Don’t select the AMI where free tier Eligle is not mentioned until you are not sure about using MSSQL or other things because It will include the per hour License cost also.
5. Here you need to Select the Instance type which is nothing but the combination of vCPU and RAM required to run your application.
AWS Frequently update their Instance type depends upon the new hardware or CPU’s coming which is showing the beauty of cloud and it will start offering those type one by one in their regions. The possibility is in some regions, you will not be able to see some instance types.
Also, Instance type comes in T-shirt Sizes like Small, Medium, Large, Extra Large etc…for the introductory level let’s move further and Select our instance as T2.micro which is free for a year with 30GB SSD with new AWS Account. Click on the “Configure Instance Details”.
6. Here you will see a lot of options which give your control to you over your cloud infrastructure and Really it shows the difference between using a Virtual Private Server (VPS) provider available in Market and A real Cloud Provider. Don’t get confused by seeing this. I explain all the options one by one below.
a: Number of Instances: If you want to launch multiple instances in a single step then fill that number. But before filling that number make sure you have that allows launch limit in your AWS Account. I’m going to launch only one instance.
b: Purchasing Option: This is one of another pricing option offered by AWS which is known as Spot Instances. Basically, AWS have to run their Datacenter always for which they are paying for the cooling, electricity, Land etc and they have huge no of Instances in their Availability Zones. So for the unused, Capacity they are giving the option to use it at cheaper prices nearly 70% than the hourly on-demand prices but with the condition that when it required it for their on-demand customer it will terminate your instance and take it back to fulfill the on-demand customer needs which will give AWS more money.
We are not going to use Spot Instances today as it will be the talk for another day.
c: Network: Very important part of your infrastructure design as Virtual private network gives your ability to choose your desired Private network ranges defined under RFC1918. It gives the isolation to our infrastructure and control over the subnetting part for better Administration.
By Default, you will get predefined VPC in every region. Let’s choose the default once today.
d: Subnet: This option is the part of Network VPC which give further isolation for our infrastructure to define which instance have Public internet access or which will be in private network only. This is the same networking concepts which we apply in our On-premises Datacenters.
Subnets are applicable on Availability zones, I am going with the subnet in ap-south-1a availability zone.
e: Auto Assign Public IP: This option gives the assign the Public IP automatically as your instance will be launched.
f: Placement Group: This option is especially for those kinds of workload which need very less latency and high throughput. By choosing this option AWS will make sure your Instances will be near or place on the same physical host.
Note that this will work with Specific instance type and mostly use for High-Performance Computing kind of workload. So leave this option as our instance class T2 is not supported for HPC kinda workloads.
g: IAM Role: This option will assign a service role to our instance to talk with other AWS services without Hardcoding any secrets. Select None for this.
h: Shutdown Behaviour: This option will let us know if we want to terminate our instance if we stop our running instance. Select Stop state if you don’t want to delete it if you press stop option when it will be in running state.
i: Enable Termination Protection: This option gives us the flexibility if accidentally we click on the terminate instance when it will be running. For Production kind of workload, I highly recommend this to enable.
I am going to leave it unchecked.
j: Monitoring: By default, you will get metric for 5 minutes Interval for free with EC2, but if you want 1 minutes metrics and few additional metrics then select this option. It will cost your extra so depends upon the requirement.
k: Tenancy: This is an option where you can decide if you want to run your instance on shared physical hardware or Dedicated Hardware which will be assigned to you only. Dedicate Tenancy comes in picture when you need to fulfill compliances to run your application on Cloud.
Dedicated Host will be expensive so choose with care. I am going to run my VM on a shared tendency.
l: T2 Unlimited: Leave this option to uncheck for today as we will learn about T2 instance class
features in near future.
m: Network Interface: If you want to add the specific private IP front your subnet you can define here. otherwise, as auto assign, it will grab an IP from the subnet CIDR automatically.
n: Advance Details: This option gives you the ability to run startup script when your instance is going to launch. You can write bash/PowerShell script here so at startup time your instance will install dependencies which you define in the script.
As per your need fill all the option and click the Next button at the right bottom to move further.
7. Choose the Storage size which you want to attach as root volume on your instance. You can attach additional volume at this point or later also on a running instance. I am going to choose 8 GiB SSD storage.
You can attach upto 30GB under free tier limit for one year from the date you create AWS account.
8. Add tags which will help us to identify the instances by name, environment or department if we have running multiple workloads in our account. I am going to add name “CloudPolice-EC2-Launch-Post”.
9. This step is very important as Security group applies at instance level which defined the inbound traffic. You can consider it as a firewall at instance level which will help you to secure it with various aspects. we will learn about security group in later posts.
Create New Security Group and Give it a relevant name and description. from the type select the Ports you want to open as for access Linux server we need to SSH so I am opening Port 22 and for making it web server I open port 80 also. I am opening it for the open world by add source “Anywhere”.
For Security purposes from Source Option, you can choose the specific IP from where you want to access or SSH into your instance.
10. This is the last step where we can review our Instance setting before launching it. If you want to change anything you can go back to any step. Click on the Launch option and you will see another Dialog box.
11. Most important part of our instance is this where we need to generate an SSH key pair which will help us to connect via SSH to our instance. AWS will give your private key which you need to store safely and it will be once downloadable only. Try to understand this logic carefully as AWS is by default no giving us option for using Password authentication for Linux Instances.
Click on the first Drop down menu and choose “Create a new key pair”.In Seconds Box where is it asking for Key Pair Name” Enter any name you want for your key pair”. I am entering “CloudPolice-Demo” and it will enable the option of Download Key Pair. Click on “Download Key Pair” to download.
12. Finally, Click on Launch and you will see it will initiate the process of Launching our EC2 Linux instance.
Within a minute or two you will be able to see the status 2/2 which will give us info that our instance is reachable. You will be able to see the public IP of the instance which will be used for SSH or WebServer purposes.
In this post, we launch our first AWS EC2 Linux instance which is under free tier. Now if you are not aware how to use SSH client on Windows or Linux I will write step by step tutorials on that soon.
Note: You can use AWS CLI or Programming SDK to launch VM but that is a talk for another day so just follow the GUI steps today to launch your first EC2 Linux instance.
If you face any issue or have any query feel free to drop in a comment.