My Journey to AWS Certified Cloud Practitioner: Day 3 β Introduction to EC2 and Security Groups
As I continue my journey toward the AWS Certified Cloud Practitioner certification, Day 3 dives into one of the most widely used and essential services in AWS: Amazon Elastic Compute Cloud (EC2). EC2 is central to understanding cloud infrastructure as it provides the scalable compute capacity that powers many cloud applications. Alongside EC2, weβll also explore security groups, which are critical for securing EC2 instances.
Things to Know Before Diving into EC2
Before getting hands-on with EC2, there are a few key concepts that you need to understand. These concepts will help you manage your EC2 instances and secure them properly.
1. IP Addresses
IP addresses are identifiers for devices on a network. AWS assigns public IP addresses for internet-facing instances and private IP addresses for internal communication within a Virtual Private Cloud (VPC). Youβll encounter both IPv4 and IPv6 formats in your AWS environment.
2. Ports
Ports are communication endpoints in networked applications. Here are some commonly used ports:
SSH (Port 22): Used for secure remote login.
HTTP (Port 80): Used for serving web pages over the internet.
HTTPS (Port 443): Used for secure web pages.
FTP (Port 21): File transfer protocol.
SFTP (Port 22): Secure file transfer.
3. Web Servers
Web servers, such as Apache or Nginx, serve content over the internet and respond to requests from clients. EC2 instances are frequently used to host web servers in the cloud, offering scalable, reliable infrastructure.
Introduction to EC2: What is EC2?
Amazon EC2 (Elastic Compute Cloud) is AWS's virtual machine service that provides resizable compute capacity in the cloud. It allows you to launch virtual servers known as instances with customizable hardware configurations. EC2 gives developers the flexibility to scale resources up or down based on their application needs.
EC2 Instance Types
EC2 offers a variety of instance types, which are virtual server configurations optimized for different use cases:
General Purpose: Balances compute, memory, and networking resources (e.g., t2.micro, t3a.large).
Compute Optimized: Optimized for high-performance compute applications (e.g., c5.large).
Memory Optimized: Ideal for memory-intensive workloads (e.g., r5.large).
Storage Optimized: For workloads requiring high, sequential read and write access (e.g., i3.large).
More About EC2
EC2 instances are highly flexible, allowing you to:
Choose the operating system (Linux, Windows, etc.).
Attach different types of storage (EBS, Instance Store).
Use Elastic IPs for static addresses.
Take advantage of Auto Scaling to automatically adjust the number of instances based on demand.
EC2 Use Cases
Some of the common use cases for EC2 include:
Web Applications: Hosting websites, web apps, or APIs.
Batch Processing: Running large-scale batch jobs that require massive compute power.
Dev/Test Environments: Quick deployment of development or test environments.
Machine Learning: Leveraging powerful compute resources for ML workloads.
Good to Know About EC2
On-Demand Instances: Pay for compute capacity by the hour or second without long-term commitment.
Reserved Instances: Save up to 75% over on-demand prices by committing to a long-term usage plan.
Spot Instances: Leverage unused EC2 capacity at steep discounts (up to 90% off).
EC2 Security Groups
Security groups (SGs) are essential when it comes to securing your EC2 instances. They act as a virtual firewall for your instance to control inbound and outbound traffic.
Security Groups Only Contain Allow Rules: Unlike traditional firewalls, security groups only allow you to define rules that permit traffic; all other traffic is implicitly denied.
Security Group Rules: These rules can reference IP addresses (both IPv4 and IPv6) or even other security groups for more granular control.
What Do Security Groups Control?
Access to Ports: You can control access to ports like SSH (22), HTTP (80), and others based on your application's needs.
Authorized IP Ranges: Control who can access your EC2 instance by specifying IP ranges (e.g., only allow access from your company's office IP).
Inbound Network Control: By default, all inbound traffic is blocked.
Outbound Network Control: By default, all outbound traffic is allowed, but this can be restricted.
Key Points About Security Groups
Security Groups Are Regional: Security groups are tied to a specific region and Virtual Private Cloud (VPC).
Can Be Attached to Multiple Instances: You can apply the same security group to multiple instances for easy management.
Operate Outside the EC2 Instance: If traffic is blocked by a security group, the instance will never see it.
Separate SSH Security Groups: Best practice suggests creating a dedicated security group for SSH access and locking it down to specific IP addresses.
Troubleshooting Tip: If your application isn't accessible, check your security group rules. If you're getting a connection refused error, it's likely an application error, not a security group issue.
Default Behavior
All inbound traffic is blocked by default, which means you'll need to specifically allow any incoming traffic (e.g., HTTP or SSH).
All outbound traffic is allowed by default, giving your instance permission to initiate outbound communication.
SSH: Securely Connecting to EC2 Instances
SSH (Secure Shell) is a protocol used to securely log in and manage your EC2 instances. Itβs the default method for connecting to Linux-based EC2 instances.
How to SSH into an EC2 Instance
For Linux/Mac: Use the terminal and an SSH command.
ssh -i /path/to/key.pem ec2-user@<instance-public-ip>
For Windows 10+: Windows now includes an OpenSSH client. You can use the
same command as Linux/Mac in PowerShell or Command Prompt.
For Older Versions of Windows: Use tools like PuTTY to connect via SSH.
EC2 Instance Connect: AWS also offers EC2 Instance Connect, which allows you to SSH directly from the AWS Management Console without the need for an SSH key.
EC2 Instance Roles
IAM roles can be attached to EC2 instances to securely allow them to access other AWS services (e.g., S3, DynamoDB) without the need for storing credentials on the instance itself.
Shared Responsibility Model for EC2
AWS operates on a Shared Responsibility Model:
- AWSβs Responsibility: Securing the infrastructure, including the hardware, networking, and facilities that run EC2 instances.
Your Responsibility: Securing the data, configurations, and applications running on the instances. This includes setting up security groups, managing IAM roles, and patching the operating system.
Conclusion
Day 3 of my journey toward AWS Certified Cloud Practitioner has been packed with learning about EC2 and security groups. EC2 offers the flexibility to scale compute resources, while security groups ensure that your instances remain secure. Understanding these components is crucial for anyone working in the cloud.
Stay tuned for more insights as I continue my AWS CCP prep! π
#AWS #CloudPractitioner #AWSCCP #EC2 #SecurityGroups #CloudSecurity #LearningJourney #TechBlog #Hashnode
Subscribe to my newsletter
Read articles from Krishna Prasanth Gurram directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Krishna Prasanth Gurram
Krishna Prasanth Gurram
π Welcome to my blog, I'm a dedicated and passionate web developer with a strong commitment to creating exceptional online experiences. π» π As a technology enthusiast, I thrive on staying at the forefront of web development trends and harnessing the latest tools and technologies to build engaging and dynamic websites. My mission is to turn digital dreams into reality. π€ Collaboration and communication are at the core of my work philosophy. I thrive in team environments and value the power of cross-functional collaboration, always seeking opportunities to learn and grow from my peers. π If you're looking for a passionate web developer who can transform your ideas into captivating online solutions, let's connect! I'm excited to explore new opportunities and create digital experiences that make a lasting impact. Let's build the web of the future together! π #WebDevelopment #PassionForCode #DigitalExperiences #WebDeveloper #Innovation