Hey Cloud Builders π
Welcome to Day 26 of the #100DaysOfCloud Challenge!
Today, we are assisting the Nautilus Development Team with a critical request: launching a web server that is fully configured and live from the very first second. Weβll be using EC2 User Data to bootstrap an Ubuntu instance into a functional Nginx web server.
This task is part of my hands-on practice on the KodeKloud Engineer platform, which I highly recommend for anyone looking to master real-world DevOps scenarios.
π― Objective
- Launch an Ubuntu EC2 instance named
datacenter-ec2. - Use a User Data script to automate Nginx installation and startup.
- Configure a Security Group to allow public HTTP traffic on Port 80.
- Verify the server is accessible via the internet.
π‘ Why User Data is a DevOps Essential
In a fast-paced environment, manual configuration is the enemy.
πΉ Key Concepts
Bootstrapping The process of automatically installing software and configuring services during the initial boot of an instance.
Cloud-Init The technology behind User Data. It runs as the
rootuser, meaning you don't need to typesudofor every command in your script.Port 80 (HTTP) The standard gate for web traffic. Without a Security Group rule allowing this, your Nginx server will be "invisible" to the world.
π οΈ Step-by-Step: Web Server Provisioning
Weβll follow a logical flow from Network Security β Instance Configuration β Validation.
πΉ Phase A: Define the Security Group
Before launching, we need to ensure the world can actually see our website.
-
Create Security Group: Name it something descriptive like
web-server-sg. - Inbound Rule: Add a rule for HTTP (Port 80) with source Anywhere (0.0.0.0/0).
- Outbound Rule: Ensure the default "All Traffic" rule exists so the server can download Nginx from the internet.
πΉ Phase B: Launch EC2 with User Data
- Select AMI: Choose any modern Ubuntu LTS (e.g., 22.04 or 24.04).
-
Instance Details: - Name:
datacenter-ec2-
Instance Type:
t2.micro(Free-tier eligible).
-
Instance Type:
- Advanced Details: Scroll to the User Data field and paste the following script:
#!/bin/bash
apt-get update -y
apt-get install nginx -y
systemctl start nginx
systemctl enable nginx
πΉ Phase C: Verification
- Status Check: Wait for the instance state to show Running and the 2/2 status checks to pass.
- Get Public IP: Copy the Public IPv4 address from the instance details tab.
β Verify Success
- Browser Test: Paste the Public IP into your web browser's address bar.
- Confirm: π If you see the "Welcome to nginx!" page, mission accomplished! Your automation worked perfectly.
π Key Takeaways
- π Root Execution: User Data scripts run with administrative privilegesβno
sudorequired! - π One-Time Run: The script only executes on the very first launch. Reboots will not trigger it again.
- π¦ Package Updates: Always include
apt-get updateto ensure your server knows where to find the latest Nginx package.
π« Common Mistakes
-
Missing Shebang: Forgetting the
#!/bin/bashat the top of your script can cause it to fail silently. - Firewall Issues: Forgetting to open Port 80 in the Security Group is the #1 reason web servers seem "down."
- Wait Time: Nginx takes a few seconds to install after the instance hits "Running." Give it a minute before refreshing your browser!
π Final Thoughts
Youβve just built a fully automated web server! This foundational skill is used for everything from launching simple landing pages to scaling complex microservices. Next, you could try customizing the index.html page directly within the User Data script!
π Practice Like a Pro
If you want to try these tasks yourself in a real AWS environment, check out:
π KodeKloud Engineer - Practice Labs
Itβs where Iβve been sharpening my skills daily!
π Letβs Connect
- π¬ LinkedIn: Hritik Raj
- β Support my journey on GitHub: 100 Days of Cloud




Top comments (0)