DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

Lab: Build a Simple AWS Infrastructure

Objective

Deploy a Linux server, connect it to a MySQL database, create storage, and upload files to S3.

Services covered:

  • EC2
  • Linux
  • RDS MySQL
  • EBS
  • EFS
  • S3

Part 1 – EC2 (20%)

Task 1

Create an Ubuntu EC2 instance.

Requirements:

  • Name: student-ec2
  • Instance type: t2.micro
  • Create a new Security Group
  • Allow SSH (22)

Task 2

Connect using SSH.

Run:

hostname
whoami
pwd
df -h
free -h
lsblk
Enter fullscreen mode Exit fullscreen mode

Explain what each command shows.


Part 2 – EBS (20%)

Create a new EBS volume.

Requirements:

  • 5 GB
  • Same Availability Zone as EC2

Attach it.

On Ubuntu:

lsblk
sudo mkfs.ext4 /dev/nvme1n1
sudo mkdir /data
sudo mount /dev/nvme1n1 /data
df -h
Enter fullscreen mode Exit fullscreen mode

Create:

echo "JumpToTech" > /data/test.txt
cat /data/test.txt
Enter fullscreen mode Exit fullscreen mode

Part 3 – EFS (15%)

Create:

  • EFS
  • Mount Target

Mount it on EC2.

Create:

sudo mkdir /efs
Enter fullscreen mode Exit fullscreen mode

Mount.

Create:

echo "Hello EFS" > /efs/file1.txt
Enter fullscreen mode Exit fullscreen mode

Verify.


Part 4 – S3 (15%)

Create bucket:

student-firstname-lastname
Enter fullscreen mode Exit fullscreen mode

Upload

resume.pdf
Enter fullscreen mode Exit fullscreen mode

OR

hello.txt
Enter fullscreen mode Exit fullscreen mode

Create another file on EC2.

Upload using AWS CLI.

Example:

aws s3 cp hello.txt s3://bucket-name/
Enter fullscreen mode Exit fullscreen mode

List objects.


Part 5 – RDS MySQL (20%)

Create:

  • MySQL
  • admin user

Connect EC2 to RDS.

Install MySQL Client.

Connect.

Run:

SHOW DATABASES;
Enter fullscreen mode Exit fullscreen mode

Create:

CREATE DATABASE school;
Enter fullscreen mode Exit fullscreen mode

Use it:

USE school;
Enter fullscreen mode Exit fullscreen mode

Create table:

CREATE TABLE students(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
course VARCHAR(50)
);
Enter fullscreen mode Exit fullscreen mode

Insert:

INSERT INTO students(name,course)
VALUES
('John','DevOps'),
('Emma','AWS');
Enter fullscreen mode Exit fullscreen mode

Verify:

SELECT * FROM students;
Enter fullscreen mode Exit fullscreen mode

Part 6 – Linux (10%)

Create user:

sudo adduser devops
Enter fullscreen mode Exit fullscreen mode

Create group:

sudo groupadd engineers
Enter fullscreen mode Exit fullscreen mode

Add user:

sudo usermod -aG engineers devops
Enter fullscreen mode Exit fullscreen mode

Create:

mkdir project
Enter fullscreen mode Exit fullscreen mode

Create:

touch project/app.log
Enter fullscreen mode Exit fullscreen mode

Change owner:

sudo chown devops:engineers project
Enter fullscreen mode Exit fullscreen mode

Verify.


Deliverables

Students should submit screenshots of:

  • EC2 Running
  • SSH Connected
  • df -h
  • lsblk
  • Mounted EBS
  • Mounted EFS
  • S3 Bucket
  • Uploaded Object
  • RDS Available
  • MySQL Connection
  • SHOW DATABASES;
  • SELECT * FROM students;

Bonus Questions (Interview Style)

  1. What is the difference between EBS and EFS?
  2. Why can't we SSH into RDS?
  3. Why did we install MySQL Client on EC2?
  4. Why is port 3306 used?
  5. What is the purpose of a Security Group?
  6. Why is RDS a managed service?
  7. What is the difference between S3 and EBS?
  8. Why must the EBS volume be in the same Availability Zone as the EC2 instance?
  9. Can two EC2 instances use the same EBS volume simultaneously?
  10. When would you choose EFS instead of EBS?

This lab is realistic, reinforces all the services they've learned, and introduces the way a DevOps engineer connects compute, storage, networking, and databases in a simple production-like environment.

Top comments (0)