DEV Community

Cover image for Setting Up and Connecting to an Amazon EC2 Instance
nnamdi nmarah
nnamdi nmarah

Posted on

Setting Up and Connecting to an Amazon EC2 Instance

Amazon Elastic Compute Cloud (EC2)

Amazon EC2 is a fundamental Infrastructure-as-a-Service (IaaS) solution provided by Amazon Web Services. It delivers scalable, on-demand virtual servers in the cloud, allowing users to run applications without the need to buy or manage physical hardware. These virtual servers, known as instances, can be quickly launched, resized, or terminated, making EC2 well-suited for workloads with changing performance or capacity requirements.

EC2 supports various operating systems, including Linux and Windows. It seamlessly integrates with AWS services such as networking through VPC, storage solutions like EBS and S3, security services including IAM and Security Groups, as well as automation tools. The service operates on a pay-as-you-use pricing model, ensuring cost efficiency based on actual usage.

Create and deploy an EC2 instance

  • In the AWS portal, search for and select EC2

search for and select EC2

  • On the EC2 dashboard, select launch instance

select launch instance

  • Give your EC2 instance a name

name your instance

  • Choose an operating system or machine image for your instance

Choose an operating system

-Create a key pair

Create a key pair

  • Leave other settings at default, then select launch

select launch

  • Verify that your instance has launched successfully, then click Connect to instance.

click Connect to instance

  • On the Connect to instance page, keep the default connection settings and click Connect.

click Connect

  • I am now successfully connected to the server.

I am now successfully connected to the server

  • First, I enter the sudo su command. This command switches to the root user by default, providing full administrative privileges on the instance.

I enter the  raw `sudo su` endraw  command

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

changed to root@ip

  • Next, type the apt update command. This is an essential operation on Ubuntu-based EC2 instances that refreshes the local package index. It connects to the repositories listed in /etc/apt/sources.list and any files within /etc/apt/sources.list.d/, downloading the latest information about available packages, versions, and dependencies. Updating this metadata ensures that future package management commands such as apt upgrade or apt install can correctly access and install the most recent software versions.

type apt update

Conclusion

Deploying an Ubuntu EC2 instance on AWS offers a powerful and flexible cloud computing solution that eliminates the need to manage physical infrastructure. The process is simple, from choosing an Ubuntu AMI to configuring security settings and launching the instance. This approach provides scalable computing resources with a pay-as-you-go model, making it suitable for both development and production environments.

By following the outlined steps, you can quickly set up a secure Linux-based server that takes advantage of the broader AWS ecosystem. With appropriate security configurations and system hardening, your Ubuntu EC2 instance can serve as a reliable foundation for various cloud-native applications.

Top comments (1)

Collapse
 
realcloudprojects profile image
SKILL.SCH

Welldone!