Hey everyone, this is the third article in the series on AWS for DevOps. In this article, we are going to learn about EC2 Instances.
Introduction:
EC2 stands for Compute Cloud, it provides on-demand, scalable computing capacity in AWS. Using this, the hardware costs help you develop and deploy applications faster.
Using EC2, we can launch as many instances as you want. Using this, we can configure security and networking, as well as manage storage. It helps us scale up or down easily to handle compute-heavy tasks.
The architecture of EC2:
The EC2 instance is always secured with a security group, which is a virtual firewall that controls incoming and outgoing traffic. A private key is stored on the local computer, and a public key is stored on the instance. Both keys are specified as a key pair to prove the identity of the user.
Amazon Virtual Private Cloud (VPC):
A VPC is a logically isolated section of the AWS cloud where you can launch your AWS resources. It provides network segmentation, allowing you to define your own private IP address space, subnets, and routing tables. The EC2 instance resides within the VPC.
Availability Zone:
These are distinct data centers within a region. They provide redundancy and fault tolerance. Placing an EC2 instance in a specific AZ ensures high availability.
Security Group:
A security group acts as a virtual firewall that controls inbound and outbound traffic to the EC2 instance. You define rules in the security group to permit or deny traffic based on protocols, ports, and IP ranges.
Key Pair:
To access the EC2 instance securely, you use a key pair. A private key is stored on your local computer, and a corresponding public key is stored on the EC2 instance. This key pair is used for authentication when connecting to the instance.
Amazon EBS Volumes:
The EC2 instance is backed by an Amazon Elastic Block Store (EBS) volume. EBS provides durable block storage that can be attached to EC2 instances. You can think of it as a virtual hard drive where your data is stored.
Internet Gateway:
An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet. It enables outgoing traffic from your EC2 instance to the Internet and incoming traffic from the Internet to your instance if you've configured it to allow that traffic.
How do these work internally?
When you launch the EC2 instance, you specify which VPC it belongs to and which subnet within that VPC it should reside in.
The security group associated with the instance controls the traffic allowed in and out of the instance, acting as a firewall.
You use the private key stored on your local computer to securely connect to the instance via SSH (for Linux) or RDP (for Windows).
The Amazon EBS volume provides storage for the instance's operating system, applications, and data.
The internet gateway allows the EC2 instance to communicate with the internet if necessary, making it accessible from the outside world.
Set up EC2 Instance
Step 1: Sign up for or log in to your AWS account.
Step 2: Enter "EC2 instance" in the search bar and enter
Step 3: Now, you'll get the dashboard of Instances. Click on Create instance now.
Step 4: Now, give a name to your instance. In my case, I've given it 'Test-EC2."
Step 5: In the Application and OS Images section, select the image that you are familiar with. I've chosen the default AWS Linux.
Step 6: Scroll down and select the "Create Keypair" option.
Step 7: Give the name as you wish, keep the remaining settings as default, and click on the Create Key Pair button.
Step 8: After clicking the button, the keypair gets downloaded automatically. Then click on the launch instance button.
Step 9: Now, go to the directory where the keypair file has been downloaded and open the terminal.
Step 10: On the AWS instances dashboard, you can see the number of instances running. On that, click your present instance's 'Connect option" and go to the "SSH client" option.
Step 11: Copy the code that you see in the ssh section and paste it into the terminal. Yes, give input, and it gets connected to the instance.
I hope you've got some basic knowledge about the instances in AWS (EC2). In an upcoming article, we are going to learn about the life cycle of EC2, VPC, Security Group, Route 53, S3 Buckets, and so on.
I request that you please follow me to get further updates and comment if you have any doubts.