1.
Launch an EC2 Instance
1. Log in to the AWS Management Console.
2. Navigate to the EC2 service and click Launch Instance.
3. Select an Amazon Linux 2 AMI.
4. Choose an instance type (e.g., t2.micro for free tier).
5. Configure the instance:
o Set the default VPC and subnet.
o Add a key pair for SSH access.
o Allow SSH (port 22) in the security group.
6. Launch the instance and SSH into it.
7. Install Apache and start the service:
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
8. Verify by accessing the instance's public IP in your browser.
2. Create a Custom Security Group
1. Create a security group that allows:
o HTTP (port 80)
o HTTPS (port 443)
o SSH (port 22)
2. Launch an EC2 instance with this security group.
3. Test by accessing the instance’s public IP for HTTP/HTTPS.
3. Create an Elastic IP
1. Allocate a new Elastic IP.
2. Associate it with an existing EC2 instance.
3. Test by accessing the instance using the Elastic IP in a browser.
4. Create and Attach an EBS Volume
1. Launch an EC2 instance.
2. Create a new EBS volume (e.g., 10 GB, gp2).
3. Attach the volume to the instance.
4. Log into the instance and mount the volume:
sudo mkfs -t ext4 /dev/xvdf
sudo mkdir /data
sudo mount /dev/xvdf /data
5. Verify by creating files in the /data directory.
5. Set Up a Web Server
1. Launch an EC2 instance and SSH into it.
2. Install and configure Nginx:
sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
3. Add a custom HTML file to /var/www/html/index.html.
4. Verify by accessing the instance's public IP in a browser.
6. Autoscaling and Load Balancer
1. Create a launch template or configuration for an EC2 instance with a web server.
2. Set up an Auto Scaling Group with at least two instances.
3. Create an Application Load Balancer (ALB) and attach the Auto Scaling Group.
4. Test by accessing the Load Balancer's DNS name in a browser.
7. Use EC2 Instance Metadata
1. Launch an EC2 instance.
2. SSH into the instance and access the metadata:
curl http://169.254.169.254/latest/meta-data/
curl http://169.254.169.254/latest/meta-data/instance-id
3. Understand the metadata and its uses.
Exercise 8: Create a Custom VPC with an Internet Gateway
1. Objective: Create a custom VPC and enable internet access using an Internet Gateway.
Steps:
o Create a VPC with a CIDR block (e.g., 10.0.0.0/16).
o Create a public subnet within the VPC (e.g., 10.0.1.0/24).
o Attach an Internet Gateway to the VPC.
o Update the route table for the public subnet to route internet traffic (0.0.0.0/0)
to the Internet Gateway.
o Launch an EC2 instance in the public subnet and associate it with a public IP.
o Test internet access by SSH-ing into the instance and pinging an external website.
Exercise 9: Create a NAT Gateway for Private Subnets
1. Objective: Allow instances in a private subnet to access the internet using a NAT
Gateway.
Steps:
o Create a private subnet (e.g., 10.0.2.0/24) in the same VPC.
o Launch a NAT Gateway in the public subnet and associate it with an Elastic IP.
o Update the route table for the private subnet to route internet traffic ( 0.0.0.0/0)
to the NAT Gateway.
o Launch an EC2 instance in the private subnet without a public IP.
o Test internet access by SSH-ing into the private instance through a bastion host in
the public subnet and attempting to ping an external website.
Exercise 10: Configure VPC Peering Between Two VPCs
1. Objective: Set up VPC Peering to enable communication between resources in two
VPCs.
Steps:
o Create two VPCs with non-overlapping CIDR blocks (e.g., 10.0.0.0/16 and
192.168.0.0/16).
o Create subnets in each VPC.
o Establish a VPC Peering connection between the two VPCs.
o Update the route tables in both VPCs to route traffic for the peer VPC's CIDR
block through the VPC Peering connection.
o Launch EC2 instances in each VPC.
o Verify connectivity by pinging the private IP of the instance in the peer VPC.
Exercise 11: Create a Fully Functional Two-Tier Architecture
1. Objective: Build a two-tier architecture with public and private subnets, using an Internet
Gateway and a NAT Gateway.
Steps:
o Create a VPC with a CIDR block (e.g., 10.0.0.0/16).
o Create two public subnets and two private subnets across two availability zones.
o Attach an Internet Gateway to the VPC.
o Launch NAT Gateways in each public subnet and associate Elastic IPs.
o Update route tables:
Public subnets: Route 0.0.0.0/0 to the Internet Gateway.
Private subnets: Route 0.0.0.0/0 to the NAT Gateways.
o Launch EC2 instances in both public and private subnets.
o Verify that public instances can access the internet directly and private instances
can access the internet via the NAT Gateway.
Exercise 11: Multi-VPC Peering Setup
1. Objective: Set up peering between three VPCs and enable transitive routing using a hub
VPC.
Steps:
o Create three VPCs with non-overlapping CIDR blocks:
Hub VPC: 10.0.0.0/16
VPC A: 192.168.0.0/16
VPC B: 172.16.0.0/16
o Establish VPC Peering connections:
Between Hub VPC and VPC A.
Between Hub VPC and VPC B.
o Update the route tables in VPC A and VPC B to route traffic to each other via the
Hub VPC.
o Verify connectivity between instances in VPC A and VPC B through the Hub
VPC.
Exercise 12: Cross-Region VPC Peering
1. Objective: Create a VPC Peering connection between VPCs in different AWS regions.
Steps:
o Create two VPCs in different regions with non-overlapping CIDR blocks.
o Establish a cross-region VPC Peering connection between the VPCs.
o Update route tables in both VPCs to route traffic for the peer VPC through the
VPC Peering connection.
o Test connectivity between EC2 instances in the peer VPCs.
Exercise 13 Create an S3 Bucket
1. Log in to the AWS Management Console.
2. Navigate to the S3 service and create a new bucket.
o Bucket name: my-first-s3-bucket-[unique-id].
o Region: Choose your preferred region.
o Enable Block Public Access settings.
3. Upload a file to the bucket.
4. Download the uploaded file.
Exercise 14: Manage Bucket Permissions
1. Enable public access to your S3 bucket (temporarily for this exercise).
2. Upload a public HTML file.
3. Test by accessing the file using the public URL.
4. Revert public access settings to private for the bucket.
Exercise 15: Static Website Hosting
1. Create an S3 bucket with a name matching your domain or a unique name.
2. Enable Static Website Hosting under bucket properties.
3. Upload an index.html file and (optional) error.html.
4. Test the static website using the provided endpoint URL.
Exercise 16: S3 Versioning
1. Enable Versioning for your S3 bucket.
2. Upload a file (e.g., example.txt).
3. Modify the file and re-upload it with the same name.
4. View the file versions under the Versions tab.
5. Restore an older version of the file.
Exercise 17: Create a Bucket Policy
1. Create an S3 bucket.
2. Write a bucket policy to allow read-only access to files for everyone. Example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-first-s3-bucket/*"
}
]
}
3. Apply the policy and test public access to a file.
Exercise 18: Lifecycle Policies
1. Create an S3 bucket and upload files to it.
2. Configure a Lifecycle Policy:
o Transition files to Standard-IA after 30 days.
o Archive files to Glacier after 90 days.
o Permanently delete files after 365 days.
3. Review the changes over time (wait for lifecycle actions or simulate using short durations).
Exercise 19:Transfer Acceleration
1. Enable Transfer Acceleration for an S3 bucket.
2. Use the provided accelerated endpoint to upload and download files.
3. Compare the upload/download speed with and without acceleration.
Exercise 20: Cross-Region Replication
1. Create two buckets in different regions (e.g., source-bucket and destination-bucket).
2. Enable Versioning on both buckets.
3. Set up Cross-Region Replication (CRR) from the source to the destination bucket.
4. Upload files to the source bucket and verify they replicate to the destination bucket.
Exercise 21: Pre-Signed URLs
1. Create a private S3 bucket.
2. Use the pre-signed URL to download the file.