Building Your First AWS Web Server: A Beginner’s Guide to Cloud Computing

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

Image description

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.

  1. Log into the AWS Management Console
  2. Search for ‘VPC’ in the search bar and navigate to the VPC dashboard
  3. 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
  4. 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
  5. Set NAT gateways to “In 1 AZ” and VPC endpoints to “None”
  6. 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.

  1. In the VPC dashboard, navigate to “Subnets”
  2. Create two new subnets:
    • Public Subnet 2 (CIDR: 10.0.2.0/24)
    • Private Subnet 2 (CIDR: 10.0.3.0/24)
  3. 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.

  1. In the VPC dashboard, go to “Security Groups”
  2. Create a new security group:
    • Name: Web Security Group
    • Description: Enable HTTP access
    • VPC: Choose your newly created VPC
  3. 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!

  1. Navigate to the EC2 dashboard
  2. 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
  3. 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
Enter fullscreen mode Exit fullscreen mode
  1. 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:

  1. Select your instance in the EC2 dashboard
  2. Copy the “Public IPv4 DNS” value
  3. 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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top