The Beginner’s Guide To Create Amazon EC2 Instances

So, you decided to start using AWS as your cloud provider. Well, there are a lot of services that can be used on the go, but one of the most basic and probably the most common is Amazon EC2. In this blog, you will see the basic concepts, and we’ll tell you step-by-step how to create EC2 instances.

What Is Amazon EC2

EC2 (Elastic Cloud Compute) is the service where you can create servers (from now on I’m going to call them instances since it’s the name used inside AWS) to launch your websites or applications.

Why Use Amazon EC2

Since there are a bunch of other providers on the network that can host your app, we choose Amazon EC2 because it offers a lot of possibilities. You can start with a small instance, and then, when you get more traffic, grow it up to a bigger option, making EC2 more flexible and adaptable than other technologies to host your application.

It is easy to increase your hard drive size in case you need to store more code or images for your app, without mentioning that you are two clicks away from starting using the load balancer on AWS, considering that you just literally have to select your load balancer and add an instance to it. The thing is that most of the common hosting users are afraid of how much AWS would cost, but considering its capacity and flexibility, your application will be in good hands on AWS.

AWS has more time on the market, so the services have been improved since it started, refining them every year for better user experience and technology innovation. All of these reasons made AWS the top provider chosen by millions of companies around the globe.

EC2 Instance Types

One of the first things that you are going to find when you try to create an EC2 instance, is the instance type/size. There are several options for each kind of workload you want to do.

General Purpose EC2 Instance

These kinds of instances are used the most for testing purposes. General purpose instances are divided into “T” and “M” varieties.

Note: “T and M” instances offer two types of virtualization: PV and HVM. The first was the one provided by AWS in the past, and it’s available on t1 and m1 instance types. I wouldn’t recommend it because you can’t take advantage of all the hardware, and in some cases is a bit slower.

Another restriction is that you are going to be able to increase your instance type to instances only based on PV, and the newer instance types are not going to be available. My suggestion is always to use HVM instances.

Compute Optimized

If your application requires processing a lot of information like math operations, load balancing, rendering tasks, or sometimes video encoding, you need an instance that can process all that information in less time. The “C” instance is your ally in this stressful operation since it has more CPU capacity and lower RAM.

Memory Optimized

If your app doesn’t require too much CPU but instead needs more and faster RAM, you should check out the available options on the “X1e, X1, and R” instances.

Accelerated Computing

Creating a movie and rendering the textures? Need to design with power? Or do you just have money to spend and want to play games on streaming? If you feel identified, P and G instances are what you are looking for, all these instances have their own NVIDIA Graphics card and vary the amount of GPU that they have depending on the instance size.

Storage Optimized

These kinds of instances are provisioned with a more significant amount of TB for storage, and you are going to have the best I/O Performance. These instances are a great option for those databases that need to be written regularly on the disk, here we have three groups of instances: H, I, and D.

These are all the available instance types and some of their uses I hope with this little explanation it’s easier for you to choose from one or another.

What’s An AMI?

Now, before we enter into how to create an ec2 instance, let’s discuss what an AMI is; it’s the acronym for Amazon Machine Image. Pretty clear right? I don’t think so. To make this a bit easier to understand, I’ll give you an example.

If you have worked with old computers or even with physical servers, you probably know that you need to update or install the same stack on more than three devices. This is done by using tools like Norton Ghost or Acronis True Image to create disk snapshots which let you take a picture of the current state of the disk to load it on the other devices in less time, compared to doing it manually.

Well, an AMI has the same idea, but it is a combination of multiple snapshots. This means that if the instance has more than one disk, the AMI is going to contain the other disks.

That’s the theory, but you also have to know that all the OS
offered by AWS are packed as an AMI so that you can find empty images with Ubuntu, Fedora, Centos, RedHat, Amazon Linux, and even with Windows Server.

There are other AMI options on the marketplace with preinstalled software like LAMP and LEMP stacks, Redis optimized or hardened software to launch your brand new instances. But be careful my friend, some of those marketplace AMIs are not only smiled, some of them include a fee per hour for you to use it (plus the cost per hour of the instance). So, if you want to choose an AMI from the AWS Marketplace check the prices of it.

Note: To Use some of the instances you need to accept an agreement, sometimes you are going to be redirected to the AWS Marketplace to take it and, in other cases, you will have to access the marketplace to accept it.

How To Create EC2 Instances in AWS and Launch Them

Now you know the basics of the EC2 service and know that there are a lot of options and things to do. But the most important thing is to apply the knowledge. So let’s see how to create EC2 instances and launch them using an AWS Marketplace AMI so you can see the complete process of creating EC2 Instance.

Requirements

1 x AWS account (if it’s an IAM user verify that you have permission to launch EC2 instances).

Instructions

Step 1 on How To Create EC2 Instance

First of all, we need to log in to the AWS Console and access it using this URL. You are going to see this page, click the button “Sign In to the Console.”

The Beginner’s Guide To Create Amazon EC2 Instances

Step 2 on How To Create EC2 Instance

It’s going to open a page requesting your username or email. Type your password.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 3 on How To Create EC2 Instance

This it’s what the AWS console looks like:

The Beginner’s Guide To Create Amazon EC2 Instances
The Beginner’s Guide To Create Amazon EC2 Instances

Step 4 on How To Create EC2 Instance

Click on EC2.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 5 on How To Create EC2 Instance

This is how the EC2 Dashboard looks.

Step 6 on How To Create EC2 Instance

Click the big blue button “Launch Instance.”

Step 7 on How To Create EC2 Instance

Immediately after you click the button a list of AMIs is going to appear. There you can select the one that you prefer, in this case, I’m going to choose Ubuntu Server 16.04 LTS.

Step 8 on How To Create EC2 Instance

After you click the select button of your chosen AMI, you are going to be able to select the EC2 instance type from the list, for this example, I’m going to use t2.micro, select and the next button.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 9 on How To Create EC2 Instance

Now to create an ec2 instance, the next page is going to show you some options to set up your instance. For the moment, just be sure that the Auto-assign Public IP is set to enable and click next.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 10 on How To Create EC2 Instance

To create an ec2 instance on this page, you can choose the amount of GB that your hard drive it’s going to have.

Note: Never leave the default 8gb, if you want to be on the free tier limits you can set a value around 20gb -24gb, because sometimes you leave it as default and your instance is not going to have too many spaces to do many things and click next.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 11 on How To Create EC2 Instance

You should be on the Tags screen to create ec2 instance.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 12 on How To Create EC2 Instance

Let’s click on the button “Add Tag” and on the key column type “Name” on the value type the name that you want to give to your instance and click on Next.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 13: Set up a Security Group

A Security group it’s like the firewall for your instance. Here, you have to open the ports that you are going to use: i.e., if you want to have a web server, you need to open port 80. If you want SSH access, you need port 22, so let’s create a new one.

The Beginner’s Guide To Create Amazon EC2 Instances
The Beginner’s Guide To Create Amazon EC2 Instances

Step 14

Now to create ec2 instance, let’s give a name and description to the new Security Group.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 15: Ports

The port 22 (ssh) open world (0.0.0.0/0) is added by default; we can leave it like that or choose “my IP” on the list of the source column. As a security measure, AWS only opens the ssh port to the ones that you trust, and don’t leave it open world, add a description to identify and click on “Review and Launch.”

The Beginner’s Guide To Create Amazon EC2 Instances

Step 16

A summary of all the settings that you have set is going to be shown on the screen if everything looks fine, click on Launch, if not you can return to change everything that you need.

The Beginner’s Guide To Create Amazon EC2 Instances

Step 17

A key? This little thing is what you need to be able to access your brand-new instance. Give it a name and click the button “Download Key Pair.” Then, save that file because you are not going to be able to get it at another time. AWS doesn’t store keys, so if you lose it, you are going to lose access to your instance.

Step 18

Click on “Launch Instance” to create an ec2 instance.

The Beginner’s Guide To Create Amazon EC2 Instances

If everything goes well you are going to see the next screen, click on the id to view it on the dashboard.

The Beginner’s Guide To Create Amazon EC2 Instances
The Beginner’s Guide To Create Amazon EC2 Instances
The Beginner’s Guide To Create Amazon EC2 Instances

Step 19: Access to the Instance

In the image above you can see the public IP of the instance. Save it, since we are going to use it for access purposes. To access using Linux or Mac, you need to change the permissions of the key before using it.

The Beginner’s Guide To Create Amazon EC2 Instances

For copy/paste purposes:

chmod 400 YourKeyName.pem


Time to get connected to the instance. You need to know that since we have launched an Ubuntu Instance, the user is Ubuntu, you can check this information on the AMI information.

The Beginner’s Guide To Create Amazon EC2 Instances

Since this is the first time you are going to get connected it’s going to ask you if you want to trust the remote host (your instance) type “yes” and press enter, and you are going to get in.

If you are using Windows it depends on the tool that you are using. Let us PuTTY, this tool doesn’t accept pem files, so we need to convert the file using a tool provided by PuTTY: PuTTYgen.

The Beginner’s Guide To Create Amazon EC2 Instances

Click on load and choose your pem file and you are going to see the loaded key, just press “save private key.”

It’s going to ask you if you want to add a passphrase (another layer of security) just press yes to continue without it.

The Beginner’s Guide To Create Amazon EC2 Instances

Save the file, this is going to create a file with the “.ppk” extension. Now let us get connected using PuTTY.

The Beginner’s Guide To Create Amazon EC2 Instances

On hostname type ubuntu@IPADDRESS.

The Beginner’s Guide To Create Amazon EC2 Instances

Now, like in the image above, click on the + on the left to SSH and select Auth. There, click on the browse button, select the ppk file created by PuTTYgen, and click open.

The Beginner’s Guide To Create Amazon EC2 Instances

The same thing that happened on Linux will happen again this time. It’s going to ask you if you want to trust the host, just click yes, and you will be there.

The Beginner’s Guide To Create Amazon EC2 Instances
The Beginner’s Guide To Create Amazon EC2 Instances

And You Are In

With this, you know the basics of creating EC2 instances, and some concepts, you know how to launch an instance, and how to access it. 

 

 

 

 

Top