How to create and launch AWS EC2 instance with Ubuntu 18.04
In this article we are going to discuss how to create and launch AWS EC2 instance with ubuntu 18.04 step by step, so lets start.
Step 1 – Launch AWS console
First of all we have to login into aws console and click on Launch Instance button as shown in below image.
Clicking on Launch Instance button it will redirect to next page.
Step 2 – Choose the OS and Hardware
After clicking on Launch Instance the below page will open. Here you have to choose OS for the virtual machine and hardware.
Select Ubuntu Server 18.04 LTS (HVM), SSD Volume Type.
After choosing OS and hardware we have to choose an instance type. We are going to choose t2.micro instance as it is free-tier eligible.
Step 3 – Configure Instance Details
When you will come on this page you will see the following screen.
step the most important thing is that the shutdown behavior we need to keep always Stop not Terminate, as we can see in the below image.
Now another important thing is Tenancy that we have to keep “Shared – Run a shared hardware instance”, if we choose other two options then additional charges may apply, so choose it carefully. But note that it is completely depends on our requirement, so based on our requirement we need to select the hardware we are going to use shared or dedicated .
next we will move onto User data, let consider we need to install some applications or install some packages during the launch process, we can also puts commands here so during launch packages also will get installed and system is ready to go.
Step 4 – Editing Some Basic Configurations
Go for the default settings for Configure Instance, Add Storage and Add Tags screens.
Initially AWS provide storage capacity of hard disk for storing applications is 8 GB but we can increase it up to 30 GB.
5 – Adding Tags
Tags are very important thing, if there are more than one instances then to know which server is going to use for which purpose, for such conditions tags are very useful.
6 – Configure Security Group
This is very important step. Below is the screenshot of this step is given.
of all we have to add security group name. We can write whatever we want to add, then we have to add description.
Now, Add 3 rules under Configure Security Group .
1. SSH : SSH is required to login to the virtual machine using command line.
2. HTTP : HTTP is for the web server.
If you want to add HTTP rule, you can add by clicking Add Rule button and choosing HTTP from the dropdown. Same for HTTPS.
Security groups acts as a virtual firewall according to AWS documentation. In other words we can set rules regarding to IP addresses that can access the added protocols. We need both the protocols are open to all IP addresses, we can also restrict accessing protocols from some IP addresses.
Clicking Review and Launch button we will redirect to a page where we can review our instance settings.
Step 7 – Creating a Key Pair
In this step page will represent with options for key file, which is uses for connect to the EC2 instance from your system.
Choose option Create a new key pair from the dropdown menu and download the key file.
key file downloaded the Launch Instance button became active. This will be the last step to clicking button and launch the instance in AWS.
After successfully launch of the instance will redirect to the new page where success message will be displayed.
For redirecting EC2 management console click on View Instances Button.
Step 8 – Locking the Key File
We need to change the permission for the downloaded key file, so that it is not publicly viewable for SSH to work.
We can achieved by following command:
sudo chmod 400 path/to/key/file
Step 9 – Connecting to Instance
Via SSH the downloaded key file can be used to connect EC2 instance from our system.
Here we are using the Linux terminal for SSH access.
1.SSH to the instance using the key file and hostname. By combining EC2 username with public DNS name with a @ character the hostname is generated.
Command shown below is used for SSH:
sudo ssh -i "path/to/key/file" ec2-hostname
We need to Replace ec2-hostname with the hostname of the instance.
2. If it gives connection warning type yes.
3. After successful connection we will get below screen.
Now necessary software we can install on this EC2 instance.