Hosting a Static Webpage on Windows Instance
Tags: aws, website, html, cloud
Published: 2023-09-12 15:35:38

**Introduction**

Amazon Elastic Compute Cloud (Amazon EC2) provides on-demand, scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 reduces hardware costs so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. You can add capacity (scale up) to handle compute-heavy tasks, such as monthly or yearly processes, or spikes in website traffic. When usage decreases, you can reduce capacity (scale down) again.

Static webpages are the simplest form of web content and a fundamental building block of the internet. Unlike dynamic webpages, which are generated on the fly in response to user interactions or database queries, static webpages consist of fixed, unchanging HTML, CSS, and JavaScript files.

**Scenario**:

A software development team needs a flexible environment for developing, testing and deploying Windows-based applications. They require a solution that allows them to quickly create and manage virtual machines with various Windows configurations.

**Solution**:

The team uses Amazon EC2 Windows instances to create development and testing environments. They can easily provision Windows instances with specific software stacks, conduct testing, and scale resources as needed. This enables efficient software development, testing, and deployment processes, accelerating time-to-market and reducing infrastructure overhead.

**Prerequisites**:
1. An AWS account
2. Basic knowledge of AWS services
3. A provisioned Windows EC2 instance

**Step-by-Step Guide**:
 
**Step 1: Launching a Windows EC2 Instance**

1. Click the "**Launch Instance**" button.
2. Select a "**Windows Server**" AMI based on your requirements.
3. In the instance type, set as "**t2.micro**" as a free tier eligible.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjauqq3tfkay41p00bra.png)

**Step 2: Choose an existing key pair or create a new key pair.**

1. If you already have an EC2 "**key pair**", select it.
2. If not, create a "**new key pair**". You'll use this key pair to securely connect to your Windows EC2 instance.
3. "**Save the file**" on your local device. Make sure it is safe.

**Step 3: Configure the Security Group and Virtual Private Cloud (VPC):**

1. Automatically "**assigned public IP**" should be "**enabled**".
2. Create a "**new security group**" or select an "**existing one**".
3. Define rules to allow **HTTP** (port 80), **RDP** (port 3389), and **HTTPS** (port 443) traffic for a web server.
4. Click "**Launch**" to proceed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/391u3ciqq65l4fi9fwvu.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us4lsfniruyo9k67j2vc.png)

**Step 4: Connect your EC2 instance.**

1. In the RDP Client Tab, click on "**Download Remote Desktop File**" on your local machine.
2. Click on "**Get Password**" and "**Upload the Private Key**".
3. Click on "**Decrypt Password**", then copy your decrypted password.
4. Open the RDP file and "**paste**" your copied decrypted password.
5. You are successfully connected to your Windows EC2 instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/724xew67k2oemfa611r9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxbr5bnigio8rqi6v1ms.png)

**Step 5: Windows Instance:**

1. Navigate to the search bar for "**Server Manager**" and double-click to open.
2. On the dashboard, on the left panel, click on "**Add Roles and Features**."
3. Click on "**next**" following Server Roles."
4. Click on the "**web server (IIS)**" and click on "**Add feature**."
5. Finally, click on "**Install**."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re341iq9uszcns786il6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgvbt4uo2mwiq44rfk57.png)

**Step 6: Make a webpage file**

1. Navigate to "Local Drive (C:)" --> "inetpub" --> "wwwroot". **Delete** all the files.
2. Create a **new text document** and write, "This is my first static webpage."
3. Save it as "**index.html**".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i677abnguaw5eunuwrs4.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68axi3njpk5xo3gfqogc.png)

**Step 7: Testing Your Static Website**

1. Copy the "**public IPv4 address**" and paste it into a new tab in your browser.
2. The static webpage has been loaded successfully and can see, "This is my first static webpage."

**Congratulations**! You've successfully launched a Windows EC2 instance on AWS. You can now customize and use it for various purposes, including hosting a static webpage.

**Conclusion**:

Hosting a static webpage on a Windows EC2 instance is a versatile and powerful solution. It provides users with control, scalability, security, and global reach. With the flexibility to configure web servers, leverage AWS's infrastructure, and ensure cost-effectiveness, Windows EC2 instances are an excellent choice for hosting static web content. By following the steps and best practices outlined in this guide, you can create a reliable web hosting environment that serves your content to a global audience efficiently. Whether you're running a personal website, a small business site, or any other static web application, AWS EC2 for Windows offers the tools and resources you need to succeed.