DEV Community

Cover image for Creating and Connecting to an Amazon EC2 Instance
Fredrick Chukwuma
Fredrick Chukwuma

Posted on

Creating and Connecting to an Amazon EC2 Instance

AWS Elastic Compute Cloud (EC2)

Amazon EC2 is a core Infrastructure-as-a-Service (IaaS) offered by Amazon Web Services that provides resizable, on-demand virtual servers in the cloud. It lets users rent virtual machines, called instances, to run applications without purchasing or maintaining physical hardware. EC2 instances can be launched, scaled, and terminated in seconds, making them ideal for workloads that vary in size or demand.
EC2 supports multiple operating systems like Linux and Windows, integrates natively with AWS networking (VPC), storage (EBS, S3), security (IAM, Security Groups), and automation services, and operates on a pay-as-you-go pricing model.

In this project, I will show you how to create and connect to an Amazon Web Services EC2 instance.

Create and deploy an EC2 instance

  • In the AWS portal, search for and select EC2

ec2 search

  • On the EC2 dashboard, select launch instance

launch instance

  • Give your EC2 instance a name

instance name

  • Select an operating system or image name (I will select the Ubuntu OS in this project)

ubuntu os

  • Create a key pair

key pair

  • Leave other settings at default, then select launch

launch instance

Connect to the EC2 instance

  • Make sure your instance has successfully launched, and select Connect to instance

connect instance

  • On the connect to instance page, leave the connection type to default and select connect

connect

  • Now I am connected to the server

server page

  • first I type in the "sudo su" command. The sudo su typically defaults to switching to the root user, granting full administrative access to the instance

sudo su

  • Notice the Ubuntu@ip changed to root@ip after the sudo su command

root ip

  • Now you type in the "apt update" command. The apt update command is a core operation in Ubuntu‑based EC2 instances that refreshes the local package index. It contacts the repositories listed in /etc/apt/sources.list (and any files under /etc/apt/sources.list.d/) and downloads the latest metadata about available packages, versions, and dependencies. This metadata update ensures that subsequent package‑management actions (apt upgrade, apt install, etc.) can resolve the newest software versions correctly.

apt update

apt update

Conclusion
Launching an Ubuntu EC2 instance on AWS provides a robust and flexible cloud computing solution, allowing users to run applications without managing physical hardware. The process is straightforward, from selecting an Ubuntu AMI to configuring security groups and launching the instance. This setup enables scalable, pay‑as‑you‑go compute resources that can be tailored to specific workloads, making it ideal for both development and production environments. By following the step‑by‑step guide, you can quickly deploy a secure, Linux‑based server that leverages AWS’s extensive ecosystem. With proper security hardening, your Ubuntu EC2 instance can become a resilient foundation for a wide range of cloud‑native applications.

Top comments (4)

Collapse
 
realcloudprojects profile image
SKILL.SCH

Nice!

Collapse
 
fredrick_chukwuma_13220c9 profile image
Fredrick Chukwuma

Thanks Coach

Collapse
 
precious_nwafor profile image
Precious Uchechukwu Nwafor

Awesome!

Collapse
 
fredrick_chukwuma_13220c9 profile image
Fredrick Chukwuma

😉