Day 4 Tutorial: Building Your Virtual Machine
Overview
Let's say you want to create a Virtual Machine on AWS i.e. EC2 Instance. A virtual machine in AWS terms is called as a EC2 Instance. Now, for creating a EC2 instance from your personal laptop you need to navigate to the AWS Console and make a request for a EC2 instance (VM) through their UI. In return AWS would return an IP Address and other such specifications of the requested EC2 instance. This the overview of how things happen when you request for a VM from the AWS Console.
The above is a simple/vanilla method of requesting for a EC2 instance but this would obviously not be the case in the floor of work. In the real world, on a everyday basis you would be generating 100's of such requests for creating a new EC2 Instance. In that case raising all requests from the UI would not be possible and most importantly efficient. We always have to remember that as a DevOps engineer our end goal should be improving/achieving efficiency.
In order to achieve efficiency in the above process of requesting for a EC2 instance, we can add automation and make the process more robust and scalable and hence remove the manual rigour from the scene. As we are requesting for an EC2 instance the AWS enterprise provides us with access to the AWS EC2 API for helping in the automation process.
In a nutshell, if you are looking to automate the process of EC2 Instance creation, you will have to write a script which would give a call to the AWS EC2 API and hence the process of creation would be smoother, scalable and efficient.
Ways to automate EC2 instance creation
The developers of the cloud provider company have created/designed an API which to which our automation would make a call and put the request. If the request is authentic, valid, authorized and meets all the criteria's then the API returns the details of the created EC2 Instance with the user.
As a DevOps engineer we can create the script/automation using :-
AWS CLI (can be used if not familiar with any programming language)
AWS API (if you are familiar with writing a rest API & boto3 for python)
AWS CFT (Cloud Formation Templates)
This is a templating language/classic template which has a proper definition and structure, if you provide the inputs to AWS, you would receive the desired output as urged.Terraform
The most Advantageous option as compared to others because others are all AWS centric whereas Terraform is dynamic, can be used to automate cloud process for all cloud providers.AWS CDK (Cloud Development Kit)
If you are more focused on AWS, this is a better alternative than terraform as this provides advance benefits over terraform as it is AWS focused.
Note :- Terraform is mostly used in enterprises which operate on hybrid cloud model i.e. multiple cloud provider usage.
How to create a EC2 Instance using AWS UI | Manual
Assuming that we are new to cloud, just follow the below steps to create your first EC2 Instance:-
Navigate to the Amazon Web Services home page via simple google search or follow the link AWS Home Page . You will see the below webpage opening in your screen.
-
Click on create new account and follow simple steps, provide details and your account would be created. Once the account is created, login as "Root User" use your credentials to login to your AWS account.
Once you are logged in, go to the Services section in the top left of the webpage and search for ec2, select the first option as shown in the below image.
-
After selecting the EC2 option, you will see a Launch instance option in the top right of the webpage, select that option and you would get a window where you can fill in the details as asked.
Once you click on launch instance, the webpage would return a form and you can add all the required information as below :-
Name - Add the name of your choice
Application - You can choose the OS as per your comfort but choosing Ubuntu is recommended because of its wide usability.
Instance Type - Select the default option that is free tier eligible if you want to use it for free, You will not be charged for usage.
Key Value Pair - This will act as your credentials to login to your ec2 instance. Click on create new key and add the information as below pic.
Key Pair name can be of your choice.
Key Pair type should be RSA.
Private key file format should be .pem format.
Post this click on the "Create key pair" and the key file would be downloaded to your local. Please note, it is highly advised that we keep the key value pair file carefully as if those are lost you won't be able to login to your EC2 instance.
- Just click on Launch Instance at the bottom of the form and just wait for a moment post which the instance would be created and would be showing in your AWS Instance Dashboard like below picture.
You can use the Key value pair for logging into your ec2 instance using the terminal.
Will discuss in detail about automating the above process and logging in with above creds in the ec2 instance using your key value pair.
Happy Learning!
Subscribe to my newsletter
Read articles from Abhinav Prakash directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Abhinav Prakash
Abhinav Prakash
I am a Big Data & DevOps Engineer, trying to solve problems through Data Analytics & Engineering. I am trying to fit in & adapt to the vast technology pool that the world is currently residing in and be part of the scene by sincerely contributing to it through my stream. I dabble mostly on Java, YAML, Cloudera, Apache Hadoop, Ansible & Linux. It's been almost two years since I entered the industry and started working in the engineering team of the organisation that I am currently part of. I graduated in Information Technology & Engineering from SRMIST, Chennai and have been fascinated about systems & data manipulation since then. You can find me playing Counter Strike, Chess and listening to music or find me involved in a political debate at a forum when I am not working. Cheers🤝