EC2 is a part of AWS, that allows users to rent virtual computers on which to run your own applications. EC2 encourages scalable deployment of applications by providing a web service through which a user can boot a virtual machine, which Amazon calls an instance, containing any software desired. A user can create, launch, and terminate server-instances as needed, paying by the second for active servers
Select the operating system for your EC2 instance.
Select instance type, and click on Next. Be sure to select the right instance type; it costs more money to run a bigger instance, use the AWS Calculator Page to find the right instance type for your project.
On the Configure Instance Details page, make any configuration changes you want to make and click Next. If you don't see what you want to change, just click Next.
On Add Storage page, type the amount of storage you want to add to your instance in the size column.
On Add Tags page, add tags for your instance, you can leave it empty and click Next.
On Configure Security Groups page, if you have a security group, select it. If you don't have a security group, click on Create a new security group and add rules to it to allow traffic to your instance. For example, you can allow traffic to port 80 and 443 for HTTP and HTTPS respectively, from any IP address if you are hosting a web server, or you can allow traffic to port 22 for SSH from any IP address if you want to be able to SSH into your instance. And click on Next.
On the Review page, you'll be asked to create a key pair. If you don't have a key pair, create one and click on Create Key Pair and give it a name and click on the Download button and save it carefully this is how you will be able to access your instance later, if you lose it you won't be able to access your instance.
After the key pair is created, click on Launch Instance.
Then you'll be redirected to the Instances page and you'll see your new instance.
Access your instance details
You can see more details about the instance by clicking on the instance ID, this will redirect you to the Instance summary page where you can find the Public IP of the instance.
Connect to your instance
Now open a Terminal or Command Prompt and type the following command to access your instance.
ssh -i [YOUR KEY PAIR NAME].pem ec2-user@[YOUR PUBLIC IP]
In my case, I used the following command to access my instance. For the first time, you'll be asked to type "yes" to continue.
ssh -i ubuntu.pem email@example.com
You can find exact commands to access your instance by clicking on the connect button on the top right side of the instance details page.
Now you have a new EC2 instance running on AWS ready to use. But keep in mind that EC2 instances can get pretty expensive to run, depending on the traffic you get, so you should be careful when you use them, and set proper budget notifications and limits in the billing console. If you're not that comfortable with using EC2 and managing all these things, then you can always use the DigitalOcean Droplet to host your VM, where your instance will be charged according to the plan you choose.