This project is from one of my Lab sections in my Amalitech AWS reStart Certified Cloud Practitioner Program. It’s the perfect project to get your hands dirty with real-world cloud infrastructure.
What We’re Building
By the end of this tutorial, you’ll have:
- A Virtual Private Cloud (VPC) with public and private subnets
- A web server running on an EC2 instance
- Basic security configurations
Prerequisites
- An AWS account (you can create one for free)
- Basic understanding of networking concepts (IP addresses, subnets)
- Patience and curiosity!
Let’s Get Started!
Step 1: Creating Your Virtual Private Cloud (VPC)
Think of a VPC as your own private section of the AWS cloud. It’s where all your resources will live.
- Log into the AWS Management Console
- Search for ‘VPC’ in the search bar and navigate to the VPC dashboard
- Click “Create VPC” and use these settings:
- Resources to create: VPC and more
- Name tag auto-generation: Uncheck
- IPv4 CIDR: 10.0.0.0/16
- IPv6 CIDR block: No IPv6 CIDR block
- Tenancy: Default
- Number of Availability Zones (AZs): 1
- Number of public subnets: 1
- Number of private subnets: 1
- Customize subnet CIDR blocks:
- Public subnet in us-west-2a: 10.0.0.0/24
- Private subnet in us-west-2a: 10.0.1.0/24
- Set NAT gateways to “In 1 AZ” and VPC endpoints to “None”
- Review and create your VPC
Congratulations! You’ve just set up your own private cloud network.
Step 2: Expanding Your Network
Now, let’s add some more subnets to make our network more resilient.
- In the VPC dashboard, navigate to “Subnets”
- Create two new subnets:
- Public Subnet 2 (CIDR: 10.0.2.0/24)
- Private Subnet 2 (CIDR: 10.0.3.0/24)
- Associate these new subnets with the appropriate route tables:
- Public Subnet 2 with the Public Route Table
- Private Subnet 2 with the Private Route Table
Pro tip: Multiple subnets across different Availability Zones increase your application’s fault tolerance!
Step 3: Securing Your Infrastructure
Security is crucial in the cloud. Let’s set up a basic firewall.
- In the VPC dashboard, go to “Security Groups”
- Create a new security group:
- Name: Web Security Group
- Description: Enable HTTP access
- VPC: Choose your newly created VPC
- Add an inbound rule:
- Type: HTTP
- Source: Anywhere IPv4
This security group will control access to your web server.
Step 4: Launching Your Web Server
Now for the exciting part – launching your web server!
- Navigate to the EC2 dashboard
- Click “Launch Instance” and use these settings:
- Name: Web Server 1
- AMI: Amazon Linux 2 AMI (HVM)
- Instance type: t3.micro
- Key pair: Create a new key pair or use an existing one
- Network: Your new VPC, Public Subnet 2
- Security group: Web Security Group
- In the “Advanced details” section, paste this user data script:
#!/bin/bash
yum install -y httpd mysql php
wget https://aws-tc-largeobjects.s3.us-west-2.amazonaws.com/CUR-TF-100-RESTRT-1/267-lab-NF-build-vpc-web-server/s3/lab-app.zip
unzip lab-app.zip -d /var/www/html/
chkconfig httpd on
service httpd start
- Launch your instance!
This script installs and starts a web server automatically when your instance launches.
The Moment of Truth
Once your instance is running and has passed its status checks:
- Select your instance in the EC2 dashboard
- Copy the “Public IPv4 DNS” value
- Paste this into a new browser tab
If you see a welcome page, congratulations! You’ve successfully set up your first cloud web server!
Discover more from Coursity
Subscribe to get the latest posts sent to your email.