Day 3 - EC2 Deep Dive

Day 3 - EC2 Deep Dive

What is AWS EC2 ?

An EC2 instance refers to a virtual server provided as part of Amazon Web Services (AWS) Elastic Compute Cloud (EC2) service. EC2 instances are resizable compute capacity in the cloud, designed to make web-scale cloud computing easier for developers.

Why is AWS EC2 used on such large scale?

Developers often choose to use EC2 instances for several compelling reasons:

  1. Scalability: EC2 instances allow developers to scale computing capacity up or down based on demand. This elasticity is crucial for handling varying workloads efficiently without over-provisioning or under-provisioning resources.

  2. Flexibility: AWS offers a wide range of EC2 instance types optimized for different use cases, such as general-purpose computing, memory-intensive applications, compute-optimized tasks, and more. Developers can choose an instance type that best suits their specific application requirements.

  3. Cost-effectiveness: EC2 instances operate on a pay-as-you-go pricing model, where developers only pay for the compute capacity they use. This model helps in optimizing costs by scaling resources based on actual demand and workload.

  4. Reliability: AWS EC2 provides high availability and reliability by offering Service Level Agreements (SLAs) for uptime and redundant infrastructure across multiple Availability Zones (AZs). This ensures that applications hosted on EC2 instances can maintain high availability and resilience.

  5. Integration with AWS Services: EC2 instances can easily integrate with other AWS services, such as Amazon S3 for storage, Amazon RDS for databases, AWS Lambda for serverless computing, and more. This integration simplifies building and deploying complex architectures within the AWS ecosystem.

  6. Development and Testing: Developers often use EC2 instances for development, testing, and staging environments. EC2 instances can be quickly provisioned and configured to mimic production environments, allowing developers to test applications thoroughly before deployment.

  7. Global Reach: AWS EC2 is available in multiple regions worldwide, allowing developers to deploy instances closer to end-users for reduced latency and better performance.

  8. Security: EC2 instances can be secured using AWS Identity and Access Management (IAM) for access control, Security Groups for firewall rules, Virtual Private Clouds (VPCs) for network isolation, and other AWS security features. This ensures that applications and data hosted on EC2 instances are protected from unauthorized access and cyber threats.

In summary, developers choose EC2 instances for their scalability, flexibility, cost-effectiveness, reliability, integration capabilities with other AWS services, and robust security features. These factors make EC2 instances a preferred choice for hosting a wide range of applications and workloads in the cloud.

Steps to Launch your First EC2 instance on AWS

Launching your first EC2 instance involves several steps. Below is a step-by-step guide to help you get started with launching an EC2 instance using AWS Management Console. This assumes you have an AWS account already set up.

Step 1: Sign in to the AWS Management Console

  1. Go to the AWS Management Console: Open your web browser and navigate to AWS Management Console.

  2. Sign in: Enter your credentials to sign in to your AWS account.

Step 2: Launch an EC2 Instance

  1. Navigate to EC2 Dashboard:

    • Once logged in, find and select "EC2" from the AWS services menu. You can also search for "EC2" in the AWS Management Console search bar.
  2. Launch Instance:

    • Click on the "Instances" link in the left-hand sidebar under the "Instances" heading.

    • Click the "Launch Instance" button to start the process.

Step 3: Choose an Amazon Machine Image (AMI)

  1. Select an AMI:

    • Choose an Amazon Machine Image (AMI) that suits your needs (e.g., Amazon Linux, Ubuntu Server, Windows Server, etc.).

    • Click "Select" to choose your AMI.

Step 4: Choose an Instance Type

  1. Choose Instance Type:

    • Select the instance type that meets your application requirements (For now select t2.micro as this fall under the Free tier Category)

    • Click "Next: Configure Instance Details" to proceed.

Step 5: Configure Instance Details (Optional)

  1. Configure Instance Details:

    • Configure additional settings such as Network, Subnet, IAM role, etc. This step is optional for basic setups.

    • Click "Next: Add Storage" to proceed.

Step 6: Add Storage (Optional)

  1. Add Storage:

    • Specify the size and type of the root volume (EBS) for your instance (By Default the Size is been selected as 8 Gb , AWS allows 30Gb of Storage for the First initial year)

    • Click "Next: Add Tags" to proceed.

Step 7: Add Tags (Optional)

  1. Add Tags:

    • Add any tags (key-value pairs) to your instance for better organization and identification.

    • Click "Next: Configure Security Group" to proceed.

Step 8: Configure Security Group

  1. Configure Security Group:

    • Create a new security group or select an existing one. A security group acts as a virtual firewall controlling inbound and outbound traffic to your instance.

    • Configure rules to allow necessary access (e.g., SSH, HTTP, HTTPS).

    • Click "Review and Launch" to proceed.

Step 9: Review Instance Launch

  1. Review Instance Launch:

    • Review all the configurations you have selected for your instance.

    • Click "Launch" to start the process of launching your instance.

Step 10: Create a Key Pair (if needed)

  1. Create a Key Pair:

    • If you don't have an existing key pair, you will be prompted to create a new key pair. This key pair is used to securely access your instance via SSH (for Linux instances) or RDP (for Windows instances).

    • Download the key pair file (.pem) and store it securely. You'll need this file to connect to your instance.

Step 11: Launch Instance

  1. Launch Instance:

    • After creating or selecting your key pair, click "Launch Instances".

    • Your instance will now be launching. You will see a confirmation message indicating that your instance is launching.

Step 12: Accessing Your Instance

  1. Connect to Your Instance:

    • Once your instance is running, you can connect to it using SSH (for Linux instances) or RDP (for Windows instances) using the public DNS or IP address assigned to your instance. (I personally Prefer MobaXterm as my SSH client as it is too reliable and provide additional features as well )

    • Use the key pair (.pem) file downloaded earlier to authenticate the connection.

Step 13: Terminate Your Instance (when not needed)

  1. Terminate Your Instance:

    • Remember to terminate your instance when you no longer need it to avoid incurring unnecessary charges.

    • Go to the EC2 Dashboard, select your instance, and click "Actions" -> "Instance State" -> "Terminate".

Following these steps should help you successfully launch your first EC2 instance on AWS. Adjust configurations and settings based on your specific requirements and application needs.

Congratulations You have Successfully Launched your First EC2 instance !