🚀Smarter Scaling: Automating EC2 with CloudWatch🚀
Published on July 28, 2025 | By AHP
1. Create an EC2 Instance (OS: Windows 2012 R2 Base)
This initial step involves launching your foundational Windows Server instance on Amazon's Elastic Compute Cloud (EC2).
- Go to EC2 Console: Log in to your AWS Management Console and navigate to the EC2 dashboard.
- Launch Instance: Click on the "Launch instance" button.
- Choose AWS AMI: Select "AWS AMIs" and search for "Windows Server 2012 R2 Base". Choose the most suitable AMI provided by AWS.
- Choose Instance Type: Select an instance type (e.g.,
t2.micro
for basic testing or development). - Configure Instance Details:
- Network: Choose a custom VPC and a subnet, for example, in
us-east-1a
. - Keep other settings as default unless your specific architecture requires changes.
- Network: Choose a custom VPC and a subnet, for example, in
- Add Storage: The default storage (30GB GP2) is usually sufficient for a basic web server. You can adjust as needed.
- Add Tags: Add a tag with "Key:
Name
" and "Value:windows webserver
". - Configure Security Group:
- Create a new security group (e.g.,
webserver-sg
). - Add the following Inbound Rules:
- Type: HTTP | Protocol: TCP | Port Range: 80 | Source: 0.0.0.0/0
- Type: HTTPS | Protocol: TCP | Port Range: 443 | Source: 0.0.0.0/0
- Type: RDP | Protocol: TCP | Port Range: 3389 | Source: Your IP (for enhanced security, restrict to your specific public IP)
- Create a new security group (e.g.,
- Review and Launch: Carefully review all your configurations.
- Create a New Key Pair: When prompted, choose "Create a new key pair". Give it a name (e.g.,
windows-webserver-key
) and download the.pem
file. Store this file securely, as it's essential for connecting via RDP. - Launch Instances: Click "Launch Instances" to start your EC2 instance.
Your "windows webserver" instance should now be launching and will enter the "running" state shortly.
2. Install IIS Server Role
After your Windows server is up and running, the next step is to install Internet Information Services (IIS) to serve web content.
- Connect to your EC2 Instance (RDP):
- In the EC2 console, select your "windows webserver" instance.
- Click "Connect", then "RDP client".
- Click "Get Password", upload your
.pem
key file, and decrypt the password. - Download the Remote Desktop File and use it with the decrypted password to connect.
- Go to Server Manager Dashboard: Once connected, the Server Manager will typically open automatically.
- Add Roles and Features: Under "Configure this local server", select "Add Roles and Features". Proceed through the wizard until you reach "Server Roles".
- Select Server Roles: Check the box for "Web Server (IIS)". A pop-up will appear; click "Add Features" to include necessary management tools.
- Click Next: Continue through the "Features" and "Web Server Role (IIS)" information pages.
- Confirmation and Install: Review your selections on the "Confirmation" page and click "Install".
- Installation Completed: Once the installation finishes, click "Close".
IIS is now successfully installed on your Windows EC2 instance.
3. Create a Static Website and Check on Localhost
To verify IIS functionality, we'll create a simple HTML page and test its accessibility.
- Navigate to Web Root: On your EC2 instance, open "File Explorer" and go to
This PC
>Local Disk (C:)
>inetpub
>wwwroot
. - Create
index.html
:- Delete any existing default files (e.g.,
iisstart.htm
) from thewwwroot
directory. - Right-click, choose "New" > "Text Document". Rename it to
index.html
(ensure file extensions are visible). - Open
index.html
with Notepad and paste the following HTML:<!DOCTYPE html> <html> <head> <title>My First IIS Website</title> </head> <body> <h1>Hello from my Windows Web Server!</h1> <p>This is a static website hosted on EC2.</p> </body> </html>
- Save the file.
- Delete any existing default files (e.g.,
- Check on Localhost: Open Internet Explorer (or any browser) on your EC2 instance and type
http://localhost
in the address bar. You should see your custom webpage. - Check using Public IP: From your local machine, copy the Public IPv4 address of your EC2 instance from the AWS console (e.g.,
54.242.121.30
) and paste it into your browser. Your webpage should be visible publicly.
Your static website is live and accessible via IIS.
4. Create an Image of the Machine and Save the AMI
Creating an Amazon Machine Image (AMI) allows you to quickly launch new instances with the same pre-configured software and settings.
- Go to EC2 Console: Return to the EC2 Instances dashboard.
- Select Your Instance: Select your "windows webserver" instance.
- Action Menu: Click the "Actions" button.
- Image and Templates: Hover over "Image and templates" and select "Create image."
- Configure Image:
- Image name: Provide a descriptive name (e.g.,
N.vargina-windows-webserver-ami
). - Image description: Add a brief description of what the AMI contains.
- (Optional) Consider allowing the instance to reboot during AMI creation for better data consistency.
- Image name: Provide a descriptive name (e.g.,
- Create Image: Click "Create image".
Your custom AMI is being created. You can monitor its status under the "AMIs" section.
5. Create a New Instance Using the AMI You Have Saved
Now, we'll demonstrate the power of AMIs by launching a second identical web server quickly.
- Go to AMI Page: In the EC2 dashboard, navigate to "AMIs" under "Images".
- Select Your AMI: Select the AMI you just created (e.g.,
N.vargina-windows-webserver-ami
). - Launch Instance from AMI: Click on "Launch instance from AMI".
- Configure New Web Server:
- Instance Type: Select the desired instance type.
- Network: Choose the same VPC, but select a different subnet (e.g.,
us-east-1b
) to ensure high availability across different Availability Zones. - Tags: Give it a name like "
webserver2 (us-east-1b)
". - Security Group: Select the *existing* security group you created earlier (
webserver-sg
) that allows RDP, HTTP, and HTTPS. - Key Pair: Select the *same* key pair used for the first instance (
windows-webserver-key
).
- Review and Launch: Review your settings and click "Launch instances".
- RDP Connection to New Webserver: Once the new instance is running, connect via RDP using the same method. Verify IIS and your website by accessing
http://localhost
. - Verify Public IP Access: Copy the Public IPv4 address of your new webserver (e.g.,
34.229.226.120
) and paste it into your local browser to confirm accessibility.
Your second web server is successfully launched from the AMI, pre-configured with IIS and your website.
6. Create a Load Balancer and Attach the Instances
To distribute incoming web traffic and improve fault tolerance, we'll set up an Application Load Balancer (ALB).
- Create Target Group:
- In the EC2 dashboard, navigate to "Target Groups" under "Load Balancing".
- Click "Create target group".
- Target type: Select "Instances".
- Target group name: Enter a name (e.g.,
nvarginiaa12-targetgroup
). - Protocol: HTTP, Port: 80.
- VPC: Select the VPC where your instances reside.
- Keep default health check settings (HTTP, path
/
). - Click "Next".
- Register targets: Select both your "windows webserver" and "webserver2 (us-east-1b)" instances.
- Click "Create target group".
- Create Load Balancer:
- In the EC2 dashboard, go to "Load Balancers" under "Load Balancing".
- Click "Create Load Balancer".
- Choose Load Balancer type: Select "Application Load Balancer".
- Name: Give it a name (e.g.,
n.vargina-web-alb
). - Scheme: "Internet-facing".
- IP address type: "IPv4".
- VPC: Select the same VPC as your instances.
- Mappings: Select the subnets in the Availability Zones where your instances are (e.g.,
us-east-1a
andus-east-1b
). - Security groups: Create a new security group for the Load Balancer, allowing inbound HTTP (port 80) and HTTPS (port 443) from
0.0.0.0/0
.
About Us
We are a community of cloud architects and DevOps professionals dedicated to sharing practical knowledge and deep insights into modern cloud infrastructure. Our articles cover a wide range of topics from core AWS, Azure, and GCP services to containerization with Docker and Kubernetes, ensuring you have the resources to build scalable, resilient, and cost-effective solutions. Our mission is to empower developers and system administrators with the skills needed to navigate the complexities of today's cloud landscape. We believe in continuous learning and the power of a strong community to foster innovation.
Stay Connected 📧
Join our community and stay up-to-date with the latest in cloud architecture and DevOps. Subscribe to our newsletter to receive our newest articles and insights directly in your inbox.