EC2 101: Understanding the Basics of Amazon's Elastic Compute Cloud
Tags: aws, beginners, tutorial, cloud
Published: 2023-01-11 08:27:57

Learn how to use AWS EC2 efficiently with this blog post. In this post, we'll cover connecting to your instance using the AWS Management Console or using ssh which allows you to connect directly to your instance through its private IP address


![ec2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jfokh10kzz39o39rqeh.jpg)

## What is EC2(Elastic Compute Cloud)?
AWS EC2 is a cloud service that allows you to run virtual servers in Amazon's elastic infrastructure. It's a powerful way to create your own server infrastructure without any need for configuration or management. With AWS EC2, you'll have access to fast and reliable computing power, backed with the service's 99.999999% uptime guarantee.

AWS EC2 is a cloud computing service for running applications that can be accessed from anywhere with internet access.


## Features

- Elastic

EC2 allows users to quickly and easily scale the number of virtual machines (known as "instances") they are using up or down, depending on the needs of their application.

- Pay-as-you-go

Users are only charged for the resources they actually consume, with a granular per-second billing.

- Customizable

EC2 instances can be customized with different combinations of CPU, memory, storage, and networking resources, allowing users to choose the configuration that best meets the needs of their application.

- Secure

EC2 instances can be launched in a virtual network that the user defines, and security groups can be used to control inbound and outbound network traffic.

- Support for multiple operating systems

including Amazon Linux, Ubuntu, Windows Server, and many others

- Integration with other AWS services

EC2 instances can easily be configured to work with other AWS services, such as Amazon RDS for database services, Elastic Block Store (EBS) for persistent storage, and Elastic Load Balancing for distributing incoming traffic among multiple instances.

- Auto Scaling and Load balancing

They can automatically increase or decrease the number of instances in response to changes in demand for the application, and automatically distribute incoming traffic among multiple instances.

- Spot Instance

an option which allows to bid for spare EC2 instances capacity. 

---

## Components of EC2 service

`There are several components that are used when launching an Amazon Elastic Compute Cloud (EC2) service:`

1. Virtual private cloud (VPC): A VPC is a virtual network that allows you to launch AWS resources in a logically isolated area.
 
2. Subnet: EC2 instances are launched within a subnet, which is a range of IP addresses within a VPC.
 
3. Security groups: Security groups are used to control inbound and outbound network traffic to and from an EC2 instance.
 
4. Key pair: A key pair is used to securely connect to an EC2 instance using SSH.
 
5. Elastic IP: Elastic IP address is a static public IP address, that can be allocated, associated, and disassociated to instances as required.
 
6. Block Storage: It allows to create storage volumes that can be attached to instances as additional storage or it can be used to create snapshots for backups
 
7. Instance: An EC2 instance is a virtual server that runs on Amazon's infrastructure. The instance type determines the CPU, memory, storage, and network resources that are made available to the instance.
 
8. Images: They are pre-configured machine images that include the operating system, software, and any necessary configuration settings. These images can be used to launch new instances.
 
9. Auto Scaling group: This group allows you to automatically scale the number of instances in response to changes in demand for your application.
 
10. Load balancer: A load balancer distributes incoming traffic among multiple instances, helping to ensure that your application is highly available and can handle a large amount of traffic.
 
11. Elastic Container Service(ECS) or Elastic Kubernetes Service(EKS) : Used for launching containerized applications.

--- 

## Use Case of EC2 service

- **Hosting web applications:** You can use EC2 instances to host web applications, by installing a web server (such as Apache or Nginx) and deploying your application code on the instances.

- **Running batch jobs:** You can use EC2 instances to run batch jobs, such as data processing or image rendering, by creating custom AMIs (Amazon Machine Images) with the necessary software installed and then launching instances from those AMIs.

- **Building a test and development environment:** You can use EC2 instances to build a test and development environment, by creating custom AMIs with the necessary software and configuration, and then launching instances from those AMIs.

- **Creating a Virtual Desktop Infrastructure (VDI):** With EC2 you can create a virtual desktop infrastructure that allows users to access their desktops remotely.

- **Building a High Performance Computing(HPC) clusters:** EC2 instances can also be used to build high performance computing clusters to perform complex calculations.

- **Running containerized applications:** you can use EC2 service to launch containerized applications using Elastic Container Service (ECS) or Elastic Kubernetes Service (EKS)

- **Hosting databases:** You can use EC2 instances to host databases, such as MySQL or PostgreSQL, either by installing the database software on the instances directly or by using a service like Amazon RDS.

- **Building a data pipeline:** You can use EC2 instances to build a data pipeline, using tools such as Apache Kafka or Apache NiFi, to collect, process, and analyze large amounts of data.

---

## Steps to launch EC2 Service

- Sign in to the AWS Management Console:

![signin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vv3wvpmg4lkv3i0q7s8w.png)

- Choose the region:

![region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4sq64aeec1xgvwfk38ei.png)

- Search for EC2 service:

![ec2 search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8sa5hcvt1v5156b4k9b.png)

- Click on Launch instance:

![Launch Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e5m8pii99tjybzpwdsi.png)

- Give name to your instance and choose an image:

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agjsh2h0pxvz0sblr39e.png)

- Select instance type and choose key pair if created:

![type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xs3rois276w2ifp1lyji.png)

- Configure your network rules:

![nw](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/umj8iek22wwfltzbctyq.png)

- Launch the instance:

![launch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqlbbcc7ummvymnm3oy3.png)

- Connect to the instance:

![connect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xmwdrvn9j37hujzjpou3.png)


![Img](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfzljdw40udfrdauspgg.png)

- Connect using SSH

![ssh](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qn8igd17t94i8q2vn4xn.png)

`Now you can see our instance is connected`

![conections](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vt3xum5dpqwh7mllwht.png)


`Hope this blog helped you to learn something about AWS EC2`

Happy Learning✨