When you start with AWS, the first thing you want is a server to run your application. In this guide I launch an EC2 instance from scratch, connect to it over SSH from the terminal, and show you how to delete it so you don’t get charged for anything extra.

Note: the video is in Spanish (Spanish audio only).

Create the instance

In the console, open the EC2 service and click Launch instance. These are the options I chose:

  1. Name: web-server.
  2. Image: Amazon Linux.
  3. Architecture: ARM. That lets me pick instances from the T4g family.
  4. Instance type: t4g.small.
  5. Key pair: create a new SSH key. When you click create, a .pem file downloads automatically: keep it safe, you need it to connect.
  6. Network: allow SSH access. For this test I opened it to any IP; on a real server, allow it only from your IP (in the dropdown: My IP).
  7. Storage: I left the default, 8 GB of gp3, enough for a test.

On the right you get a summary of everything you configured and the number of instances to launch. Leave it at 1. If you raise that number, AWS recommends creating an Auto Scaling group, which is what you need if you want your application to be highly available and resilient to failures.

Click Launch instance.

Launched too many? Terminate them

It happened to me: I launched five instances by mistake. To delete the extra ones:

  1. Go back to EC2 → Instances.
  2. Select the ones you want to delete.
  3. Open Instance state → Terminate and confirm.

If you refresh the list, you’ll see them move to the terminated state.

Connect over SSH

Copy the instance’s public IP (it’s in the columns on the right of the list) and open your terminal:

ssh -i /path/to/your-key.pem ec2-user@<instance-IP>
  • -i points to the key you downloaded.
  • ec2-user is Amazon Linux’s default user.

The first time, it asks whether you trust the server: type yes. Next time it won’t ask.

On Linux or Mac, if ssh complains that the key’s permissions are too open, lock it down before connecting:

chmod 400 /path/to/your-key.pem

To try it out, check the disk:

df -h

You’ll see the 8 GB you reserved.

If the connection hangs

If you created the instance without allowing SSH access, the ssh command just waits with no answer until it times out. Check the inbound rules: I explain how in How to configure AWS Security Groups.

Don’t forget to terminate it

When you no longer need it, go to EC2 → Instances, select it and choose Instance state → Terminate. That makes sure there are no extra costs.

The channel has videos explaining each option on this form in detail: images, instance types, security groups and SSH keys.


Found it useful? Watch the full video on YouTube (in Spanish) and subscribe to @Andrevops for more videos like this one.