DEV Community

Cover image for AWS EC2 Instances basics
Grzegorz Piechnik
Grzegorz Piechnik

Posted on

AWS EC2 Instances basics

When running performance tests locally, you may find that the hardware you are using is inferior. There are also other problems in the form of bandwidth or issues like the inability to use the local station for other purposes. Therefore, it is more stable to use cloud solutions such as aws ec2. How to create such an instance to be able to run tests on it?

Creating an instance

To begin with, you need to go to AWS and properly register an account. After filling in all the data, we enter EC2 Instances.

AWS ec2 Instance

The next step is to correctly create instances. To do this, we click the orange “Launch instances” button at the top. This will redirect us to a subpage where we can select the type of machine, its operating system and enter its advanced settings. In our case, it will be the ubuntu system, whose name is my-test-instance.

AWS ec2 Instance 2

It is important to create or select an existing key pair. Since we don’t have one, we create one from scratch. It is vital to select the correct key extension at the bottom (depending on what tool we will use to connect to the server).

Image description 3

After generating the key and moving on, we get a message that our instance has been created.

Image description 4

When we go to the list of instances again, a new record appears before our eyes. By clicking on it we get all the necessary information to connect to it.

Image description 5

By default, our instance is enabled. Remember to stop the machine when you are done by pressing Connect -> Stop.

Connect to the Instance

We can connect to the created instance in two ways, depending on what type of key we generated in the previous step.

SSH

The first way is a standard SSH session. To do this, open a terminal and execute the following command.

ssh -i KEYPAIR.pem PLATFORM@PUBLIC_DNS
Enter fullscreen mode Exit fullscreen mode

In our case, it will be:

ssh -i my-test-keypair.pem ubuntu@ec2-18-132-63-123.eu-west-2.compute.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Putty

Another option is to use the Putty tool. It is simply a program that is a client for TELNET, SSH and rlogin services. Putty is used when the graphical interface is more understandable to us and we want to be able to save many session settings.

In order for the connection to Putty to take place, three data fields must be completed.

  1. Host name (or IP address).

Image description 6

  1. User name.

Image description 7

  1. Private key file for authorization.

Image description 8

Transferring files to an ec2 instance.

As in the previous case, the tool used will depend on the previously selected generated key pair.

SCP

$ scp -i yourKey.pem C:\desinationPath ubuntu@publicDNS:/home/ubuntu/yourFileOrFolder
Enter fullscreen mode Exit fullscreen mode

Putty

$ pscp -i yourkey.ppk C:\desinationPath ubuntu@public_DNS:/home/ubuntu/yourFileOrFolder
Enter fullscreen mode Exit fullscreen mode

Downloading files from an ec2 instance.

Use the following syntax to download files or directory.

SCP

$ scp -i yourKey.pem ubuntu@publicDNS:/home/ubuntu/yourFileOrFolder C:\desinationPath
Enter fullscreen mode Exit fullscreen mode

Putty

$ pscp -i yourKey.ppk ubuntu@publicDNS:/home/ubuntu/yourFileOrFolder C:\desinationPath
Enter fullscreen mode Exit fullscreen mode

Top comments (0)