How To Set Up An EC2 Instance on AWS
Tags: aws, beginners
Published: 2024-05-18 15:28:48

## INTRODUCTION

**WHAT IS EC2**
Amazon Elastic Compute Cloud (Amazon EC2) is a pivotal service within the Amazon Web Services (AWS) suite of products. It functions as a scalable and highly secure virtual server, enabling users to effortlessly host applications without the need for upfront hardware investments. Operating EC2 is convenient, as it can be easily launched and managed from the AWS dashboard. The service encompasses a wide array of computing capabilities and grants users the flexibility to customize specifications such as RAM, ROM, and more. EC2 significantly streamlines the development process by facilitating easy scalability and seamless integration with other services, making it a highly valuable tool for developers and businesses.

**WHY USE EC2**

1. Easy to scale up and down.
2. Remote Access to your assets from anywhere in the world.
3. Very Secure.
4. Pay-As-You use i.e. you only pay for what you use.
5. Easy to set up as no hardware is required.

## SETTING UP AN EC2 INSTANCE

Let's take a step-by-step look at how to set up an EC2 instance

**Step 1:** Log in to your AWS account or create an account [Here](https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26src%3Dheader-signin%26state%3DhashArgsFromTB_eu-north-1_9fb81d06e959ff9c&client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&forceMobileApp=0&code_challenge=snfNMqkvUZ2G0-vL_jcNR2eA2NLzd-E-IDeErxM_Xlk&code_challenge_method=SHA-256)

**Step 2:** Click on services by the top left corner or EC2 as shown in the image below, if you click on services, you will need to click on EC2 in the next screen.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8as6bqqapvolrf7x51l.jpg)

**Step 3:** Click on _launch instance_ button as shown below.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mqrmzl36bkwu2sgq23hn.jpg)

**Step 4:** Configure the instance, examples are given below
- Name the instance

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bdcg2ud2pustis5dzp82.jpg)
- Select the type of OS you want and also the AMI(Amazon Machine Image) you want, take note, and take advantage of the AMI eligible for free-tier if your account is less than a year old. Also, select the Architecture you want.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oesfepm5bfl0ksw69861.jpg)
- Select the instance type you want, and also take note of the free-tier eligible ones.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9joif63jdvplx15n6cu.jpg)
- Create a new key pair or select an existing one if you already have one. This key pair will allow you to securely connect to the instance using SSH agents. Click on the _create new key pair_ button.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ia3azqae4fl00ycw5gyj.jpg)
- Input a name, select the key type and key format then click on the _Create Key Pair_ button shown below.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqs5l1d4r8t35mo784dy.jpg)
- Configure the network settings, select an existing security group, or create a new one and specify the rules.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egwjf74q87plh0hnsy1x.jpg)
- Configure the storage you want or leave the default one

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2w6pxzwjnd6fimhzgzu.jpg)
- Click on the _Launch Instance_ button at the bottom left corner.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpck7u6au32h1gheongw.jpg)

**Step 5:** The next screen will take a moment and then show you a success message, click on the instance ID shown in the message to see the state of your instance.


![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mrtxtnb32bl2re4sxcn2.jpg)
**Step 6:** Wait for some moments for the instance to initiate, click on the reload button shown below to refresh, and when the status check turns green, your instance is up and running.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbavnc4panpw52x4q7jk.jpg)

**Step 7:** Click on the instance ID from the screen above, this will take you to the instance summary shown below. Click on the connect button to connect to your instance CLI, you can also connect to the instance using any SSH agent with the key pair we created earlier.

![AWS Console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1c7qsumnryd8gm2y3bh5.jpg)

## CONCLUSION
This comprehensive article provides a step-by-step guide to simplify the process of launching an EC2 instance. By following the detailed instructions, you will not only be able to launch the instance but also learn how to configure it according to your specific needs and requirements.