Amazon EC2 (Elastic Compute Cloud)
- EC2 provides scalable virtual servers in the cloud.
- You can launch, configure, and manage instances (virtual machines).
- Supports various operating systems (Linux, Windows).
- Key components:
- Instances: Virtual machines.
- AMI (Amazon Machine Image): Preconfigured OS and software.
- Security Groups: Firewall rules to allow/deny access.
- Elastic IP: Static IP address for your instance.
- Auto Scaling: Automatically adjusts capacity based on demand.
Example Use Case: Hosting a web application.
Amazon S3 (Simple Storage Service)
- S3 is an object storage service.
- Stores files, backups, and static content.
- Highly durable and scalable.
- Key components:
- Buckets: Containers for objects.
- Objects: Files stored in S3.
- Versioning: Keeps multiple versions of an object.
- Lifecycle Policies: Automate data deletion or archiving.
Example Use Case: Storing website images and backups.
AWS CloudFormation
- Infrastructure as Code (IaC) service.
- Automates AWS resource creation using templates.
- Templates are written in JSON or YAML.
- Key components:
- Stacks: Group of AWS resources managed as a unit.
- Templates: Define resources (EC2, S3, IAM, etc.).
- Change Sets: Preview changes before applying.
Example Use Case: Deploying a complete infrastructure setup with EC2, S3, and IAM roles.
Lets go more detail :
Amazon EC2 (Elastic Compute Cloud) – Scalable Cloud Servers
What is EC2?
- Amazon EC2 provides virtual machines (VMs) in the cloud.
- You can run applications without buying physical servers.
- Offers flexibility in OS, instance types, and scalability.
Key Features
- Elasticity & Scalability: Easily increase or decrease instances.
- Multiple Instance Types: General-purpose, Compute-optimized, Memory-optimized, GPU instances.
- Security Groups: Control inbound/outbound traffic like a firewall.
- Elastic IPs: Static IPs for reliable access.
- Auto Scaling: Adjusts instances automatically based on traffic.
- AMI (Amazon Machine Images): Pre-configured OS with apps.
Use Case
- Hosting a web application with multiple users.
Hands-on: Launch an EC2 Instance
- Go to the AWS EC2 Console.
- Click on Launch Instance.
- Choose an Amazon Machine Image (AMI) (e.g., Ubuntu 22.04).
- Select an Instance Type (t2.micro for free tier).
- Configure security group (allow SSH, HTTP).
- Create a key pair for secure access.
- Click Launch and connect via SSH.
Amazon S3 (Simple Storage Service) – Secure Object Storage
What is S3?
- AWS S3 is a scalable object storage service.
- Used for storing files, backups, and static content.
- Provides high durability (99.999999999% reliability).
Key Features
- Buckets & Objects: Store files in containers called “buckets.”
- Access Control: Public/Private access and fine-grained permissions.
- Versioning: Maintain multiple versions of an object.
- Lifecycle Management: Automatically move files to cheaper storage (Glacier).
- S3 Transfer Acceleration: Speeds up file uploads.
Use Case
- Storing website assets (images, CSS, JavaScript) and backups.
Hands-on: Create an S3 Bucket
- Go to the AWS S3 Console.
- Click Create Bucket.
- Choose a unique name and AWS region.
- Configure access permissions (public/private).
- Upload files to your bucket.
- Access them via an S3 URL.
AWS CloudFormation – Infrastructure as Code (IaC)
What is CloudFormation?
- A service that allows you to define and provision AWS infrastructure using code.
- Uses JSON or YAML templates to automate AWS resource creation.
Key Features
- Infrastructure as Code (IaC): Automate deployments with scripts.
- Stacks: Manage related AWS resources as a single unit.
- Change Sets: Preview modifications before applying.
- Rollback Mechanism: Reverts to the last known good state if deployment fails.
Use Case
- Automating EC2 and S3 bucket creation for a web app.
Hands-on: Deploy an EC2 Instance with S3 using CloudFormation
- Go to the AWS CloudFormation Console.
- Click Create Stack → With New Resources.
- Upload the following YAML template:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0c55b159cbfafe1f0 # Change based on your region
InstanceType: t2.micro
SecurityGroups:
- !Ref MySecurityGroup
MyS3Bucket:
Type: AWS::S3::Bucket
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow SSH and HTTP access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
Click Next, review settings, and deploy the stack.
AWS will automatically create an EC2 instance and an S3 bucket.