How to Create an EC2 Instance Linux Virtual Server on Amazon AWS
When it comes to Amazon, many people will probably immediately think of the largest and most famous e-commerce platform in the world.
But as you probably know, in addition to e-commerce, Amazon is also a very famous name in the field of cloud computing with Amazon Web Services (AWS), and it is in direct competition with other companies. giants like Microsoft and Google.
In terms of service quality, there is no need to discuss, many large corporations in the world such as BMW, Lamborghini, US State Department, NASA, Facebook, Netflix, ICRAR, Twitch, LinkedIn, BBC and dozens of other prominent names have been using Amazon's EC2 cloud computing service.
And EC2 is also one of the most important services of Amazon AWS, alongside Amazon S3 storage and Amazon RDS content delivery network (CDN).
Well, in the article below, I will show you in detail how to create your own EC2 Instance Linux virtual server on Amazon AWS in the easiest way!
#first. What is EC2? and some concepts to know when working with EC2
NOTE: This article has a lot of terms that newbers will not understand, because it has a lot to do with technology, a lot with webmasters. If you want to dig deeper, you can Google the terms you don't understand to find out more!
As I said above, Amazon Elastic Compute Cloud – Amazon EC2 is one of the most famous and important services of AWS, this is a cloud computing infrastructure responsible for providing machine resources. virtualization on demand.
Amazon EC2 provides scalable virtualized computers (VPS) with virtual hardware components such as RAM, CPU, etc.
In general, it is very flexible in choosing data storage partitions in different platforms, and another strength is the security of service management by AWS's powerful virtualization architecture.
Yes ! In short and easy to understand, EC2 is a virtual server rental (VPS) service of AWS.
EC2 Instance Linux is the name of a virtual server running the Linux operating system, where Instance is equivalent to the word VPS.
Amazon Machine Image – AMI is an operating system installer file that has AWS pre-installed the necessary software and tools for each need and packaged into templates for you to choose from.
When you choose any AMI, AWS just unzips that installer file to the hard drive of the newly created VPS (like we ghost win) and then gives it to you to use, much faster than the installation method. traditional ISO files.
Amazon EC2's AMIs system is quite rich and diverse, enough for most of your needs, supporting both Windows Server and Linux.
In addition, you can also create your own AMI, but of course I will not guide in this article, because it is very long and complicated.
Key Pair is a pair of Private key and Public key used to SSH into EC2 Instance Linux, which will be issued only once when creating a new EC2 Instance.
Once lost there is no way to get it back, which means you could potentially lose access to your own virtual server (VPS).
You also must not reveal the Key Pair to the outside (especially the Private key) because anyone with the Key Pair and the corresponding virtual server IP can connect to SSH.
For Windows, you must have a Key Pair to get the account and password to connect to Remote Desktop. How to connect SSH as well as Remote Desktop to EC2 Instance I will have the following tutorial.
Security Group is a firewall layer that controls incoming and outgoing connections to your EC2 Instance server.
Each EC2 Instance will have 2 layers of firewalls to manage the connection: the operating system's local firewall (iptables, ufw, Windows Firewall) on Linux/Windows and the Security Group Firewall.
#2. How to Create an EC2 Instance Linux Virtual Server on Amazon AWS
Step 1: First, log in to your account on the Amazon AWS Management Console service management page here.
If you don't have one, create a new account!
From the AWS Management Console page, click Services => then select EC2 to access the EC2 Dashboard management interface on Amazon AWS.
Step 2: Unlike other VPS rental services, with Amazon AWS you will have to choose the server location from the beginning and will not be able to change it later.
The default server region after you create an account will be Northern Virginia (N. Virginia), USA.
This area is quite far from Vietnam, so you should move to a closer area that is Asia-Pacific (Asia Pacific).
In the Asia Pacific region, please prioritize the Hong Kong, Singapore and Tokyo servers for the fastest access speed.
Particularly with AWS Free Tier accounts, you will not be able to select the Hong Kong area, but Tokyo and Sing will be able to.
Step 3: Next, select the Instances tab in the left sidebar of the screen => and then click the Launch Instance button to create a new EC2 Instance.
Step 4: Select the operating system – AMI
I have already introduced in detail what AMI is above, so I won't say it again.
There are quite a few operating systems from Linux to Windows for you to choose from, here I need to create a server to run NodeJS, so I will choose Ubuntu 20.04 LTS.
As for the operating system type, remember to leave the default as 64-bit (x86) => then press Select to go to the next step.
Step 5: Select Instance Type – Configure EC2 Instance Hardware
Of course, when creating a new EC2 Instance, you will need to choose the configuration parameters that fit your needs.
AWS currently offers more than 100 optimized server configurations for different needs called Instance Type, and they don't allow you to customize the hardware configuration yourself like they do with Google Cloud.
However, for those who are using a free 12-month AWS Free Tier account, they are only allowed to use a single configuration (Instance Type), t2.micro (1 vCPUs Intel Xeon 2.5GHz, 1 GiB RAM). This configuration is too redundant for testing and learning purposes.
You'll still be able to choose from other more powerful configurations, but you'll have to pay a fee based on the usage time and deduct the money from the linked bank card at account creation.
=> You choose the package t2.micro => then click Next : Configure Instance Details to go to the next step.
Step 6: Advanced settings – Configure Instance
Going to the advanced setup, these are mostly premium and paid features of AWS.
If you are a person in the process of learning and do not have in-depth knowledge about Amazon's EC2 Instance Linux virtual server, I recommend that you keep the default settings.
But I will explain a little more about the parameters, you can learn if you like:
- Number of instances: This is the number of Instances that we will run at the same time, with the same AMI Image selected.
- Purchasing option: This option will help us to make bid spot instances.
- Network: Select VPC (if available), otherwise use Amazon's VPC by default. Renting a VPC will incur an additional fee as it is not included in the Free Tier package.
- Subnet: This one, you can choose 1 of 3 zones a , b , c arbitrarily .
- Auto-assign Public IP: This part is self-assigned Public IP address, so you should leave it as default.
- IAM role: I leave it as None because I don't need it at the moment.
- Shutdown behavior : You should leave it as Stop. The purpose is to avoid the case that you execute the shutdown command, the Instance will be terminated.
- Enable termination protection: You can select this option if desired. This option will help you avoid unintended termination of the instance.
- Monitoring: This option will help you monitor Instance in more detail. Instance's stats will be collected every 1 minute instead of every 5 minutes. And with this function you will have to pay because it is not in the Free Tier.
- Tenancy: Choose Share – Run a shared hardware instance, you will not have to pay additional fees to rent the underlying host.
- Network Interfaces: Amazon will automatically assign you an IP if you do not define the Primary IP.
Alternatively, you can also visit the Amazon EC2 manual page here to learn more about the features in this Configure Instance section.
Step 7: Configure the hard drive – Add Storage
AWS Free Tier accounts will only be able to use up to 30GB of ESB hard drives of General Purpose SSD (gp2) or Magnetic.
You enter the desired capacity in the Size box (GiB), the Volume Type section you keep is General Purpose SSD (gp2) => then click Next : Add Tags to continue.
Note that when you delete an EC2 Instance, the corresponding hard drive will also be deleted, to be able to keep the hard drive for other uses, please uncheck the box Delete on Termination.
Step 8: Tag EC2 Instance – Add Tags
Simply put, tagging EC2 Instance will make classifying and managing virtual servers much easier and more convenient.
=> In this tutorial we temporarily skip the tagging part for EC2 Instance, this is not necessary yet guys.
Step 9: Configure Firewall – Configure Security Group
The configuration in this Security Group section will allow you to access and use certain EC2 Instance services such as HTTPS, HTTP, FTP, MySQL, .
If you need to use any service, open the port (Port) on the firewall for that service by clicking the Add Rule button => then select the corresponding service in the Type box. Note:
- For EC2 Instance running Linux, the service that needs to be open is SSH (Port 22) and Windows is Remote Desktop (Port 3306). If you use it as a web server, you need to open HTTPS (443) and HTTP (80).
- The Source section indicates which IP's access will be accepted or blocked, leaving the default 0.0.0/0 will allow all IPs to access that service. If you have specific IP information, enter this Source box.
Each time you create a new EC2 Instance you will be given the choice to create a new one or use an existing Security Group, if you have already created it, you can choose Select an existing Security Group to reuse it, saving you time reconfiguring.
=> When done, click Review and Launch.
Step 10: You will be given an overview of the configuration as well as the hard drive settings, firewalls, tags, etc. before confirming the creation of a new EC2 Instance.
If something is wrong, you can click the Previous button to go back to the previous steps and correct it. And if everything is fine, then click Launch to confirm the creation of a new EC2 Instance.
Step 11: Here, a popup will appear giving you options to use Key Pair.
If you are creating an EC2 Instance for the first time, you will have to choose Create new key pair to create a new one and I also recommend you to use this option.
Enter the Keypair name in the Key pair name box => then click Download Key Pair to download. After downloading, AWS will allow you to Launch Instances.
In addition, you can also choose to use an existing Key pair (Choose an existing keypair) that you have downloaded on your computer or saved somewhere. The same Key pair can be used for many different Instances in different regions.
Or don't use Key pair if you choose Proceed without keypair. This option is not secure at all, because anyone with your EC2 Instance IP can SSH or Remote in.
After downloading the Key Pair, remember to save it for use and now I will show you how to connect SSH to EC2 Instance Linux with Key Pair in the following article.
Step 12: You wait a bit and the Launch Status page with the message Your instances are now Launching will appear as shown below indicating that EC2 Instance has been successfully initialized.
That's it, now you can go back to the management page and start using your EC2 Instance.
#3. Epilogue
Well, that's it, I just finished showing you how to create an EC2 Instance Linux virtual server on Amazon AWS. It looks so long and complicated, but when done, it is extremely simple and fast. And if you are intending to use VPS at Amazon AWS to make VPN Server, rest assured, the quality is excellent.
You should read it
- Amazon released Linux 2 - an attempt to change the game
- How to Create an ARM-Based Linux Virtual Machine with Azure
- Learn about Amazon EC2 service
- The basic advantages of Linux servers and Window servers
- How to create file swap in Linux
- Amazon also has a smart virtual assistant
- Learn about Class, Object and Instance in object-oriented programming
- How to check for simple Linux server performance
- Amazon AI system helps to cut 15% of speech recognition error on Alexa
- Setting up Ubuntu virtual machine with Hyper-V Quick Create on Windows 10
- Amazon Alexa Virtual Assistant is proposed by more than 1,000,000 users in 2017
- Microsoft raised the white flag, accepted to turn virtual assistant Cortana into assistant for Assistant and Amazon Alexa