DEV Community

Cover image for AWS Elastic Compute Cloud (EC2) | Amazon Web Services (AWS)
M. Oly Mahmud
M. Oly Mahmud

Posted on

AWS Elastic Compute Cloud (EC2) | Amazon Web Services (AWS)

Amazon EC2 offers cloud-based virtual machines, commonly found within AWS. Rather than using real computers, users run these on remote systems. We'll guide you through setting up an Nginx web host gradually. During this process, key concepts will be explained clearly but briefly.

Step 1: Sign in to AWS Console

Head to the AWS Management Console then sign in. This interface serves as your central hub for using AWS tools.

Step 2: Go to EC2 Dashboard

Amazon EC2 (Elastic Compute Cloud) offers on-demand computing power in the cloud. It's like leasing virtual servers from Amazon’s infrastructure, yet you can adjust resources anytime based on demand.

With EC2, pricing follows usage - no need to buy fixed hardware. Instances start or stop within minutes, offering flexibility through scalable access instead of permanent setups

Look up EC2 and open it.

You’ll notice a sight similar to this one.

Next, select instances.

Step 3: Launch a New Instance

An instance is basically a virtual computer hosted on AWS systems. While setting up one, you’re reserving hardware resources such as processing power, RAM, disk space, along with software to run it.

Click Launch Instance.

Step 4: Name the Instance

Assign a name - such as web-server- to the instance. Use this tag to recognize it within the AWS dashboard.

Step 5: Choose an AMI

An AMI serves as a ready-made blueprint for launching virtual machines. It includes:

  • The operating system (like Ubuntu, Amazon Linux, or Windows)
  • Optional application software
  • Configuration settings

For example, choosing Ubuntu 24.04 means your instance will boot up with that OS installed, ready for use.

Select an AMI (Amazon Machine Image).

Step 6: Choose Instance Type

Instance types define processing speed, RAM size, connection efficiency, or disk space.

For example:

  • t3.micro: compact, affordable - ideal for practice or light tasks
  • m5.large: a solid choice for everyday applications due to its well-rounded performance
  • c6g.xlarge: built for intense computing workloads

AWS provides various instance type groups tailored to specific needs - like general computing, high-performance processing, or enhanced memory capabilities - alongside options powered by GPUs.

Select an instance type - it sets the hardware for your server. I’ll go with t3.micro this time.

Step 7: Create a Key Pair

Upon logging into a regular computer, one enters a username followed by a password. In contrast, EC2 relies on key pairs - set up by AWS - for verification. Each key pair includes two parts:

  • A public key stored in AWS
  • A private key (a .pem file) save it on your computer

While connecting via SSH, AWS verifies your private key against the one stored publicly on the machine - confirming alignment without requiring a password. That method allows safe login through cryptographic validation instead of credentials.

If access is lost to the private key file, login becomes impossible - store it securely. Alternatively, losing this file blocks entry entirely; handle with care.

Select create key pair then proceed.

Call it something. Leave the rest as is.

Generate the key pair now.

Step 8: Configure Security Groups

A security group acts like a digital barrier, managing data flow to your system. This setup specifies accessible ports alongside permitted users. While it blocks unwanted connections, it allows approved communications through designated channels.

With this arrangement, it’s necessary to permit:

  • SSH (port 22): this allows terminal access to your instance
  • HTTP (port 80): this means users reach the web server through a browser

For practice, allow these ports from any IP address (0.0.0.0/0). In real use, restrict SSH access to just your IP - this improves safety.

Step 9: Launch the Instance

Click Launch Instance. After that, AWS sets up your virtual machine.

In just moments, you’ll see it appear on your EC2 dashboard.

Step 10: Connect to the Instance

Select an instance, then choose Connect. With the SSH Client option selected, execute the AWS-provided command in your terminal - it appears as follows:

ssh -i "demo-key-pair.pem" ubuntu@<Public-IP>
Enter fullscreen mode Exit fullscreen mode

This links your computer to the EC2 server safely; alternatively, different choices are available.

Step 11: Install Nginx

Once linked, execute this command :

sudo apt update && sudo apt install -y nginx
Enter fullscreen mode Exit fullscreen mode

This refreshes your package manager while setting up the Nginx web server.

Step 12: Access the Server in a Browser

Take the Public IPv4 address from your instance on the EC2 dashboard - enter it into a web browser.

You ought to view the Nginx welcome screen - this shows the server’s active and reachable online.

Step 13: Terminate the Instance

Once testing finishes, shut down the instance - skipping this step could lead to ongoing charges. Here's how:

  1. Go to the EC2 dashboard
  2. Select your instance
  3. Click Instance State → Terminate instance

Terminating a server removes it forever. When temporary shutdown is needed, use Stop instead - this keeps your data safe. Choosing one action or another depends on whether files should stay intact after halting operations.

Wrapping Up

So, we've explored:

  • EC2 delivers adjustable virtual machines through the cloud
  • A single instance means a virtual machine actively operating within the cloud environment
  • An AMI serves as the operating system plus application blueprint needed to start instances
  • Instance types define the hardware power and performance of your server
  • Key pairs protect access through public-private verification methods
  • Security groups work like firewalls deciding which users reach your system, by setting clear entry rules based on trusted sources

Top comments (0)