Hands-on Activities: Launch an EC2 instance, Host a website, Set up auto-scaling group

Hands-on Activities: Launch an EC2 Instance, Host a Website, Configure Auto Scaling Group

Hands-on Activities: Launch an EC2 Instance, Host a Website, and Set Up an Auto Scaling Group

This detailed hands-on guide covers three of the most essential cloud engineering tasks in Amazon Web Services (AWS): launching an EC2 instance, hosting a website, and configuring an Auto Scaling Group. Whether you are learning AWS for certification, preparing for a cloud engineering job, or simply exploring cloud computing fundamentals, these activities provide a solid foundation. The document is structured in simple, digestible sections and includes step-by-step explanations, relevant best practices, and useful commands. All code blocks are formatted using the required HTML structure.

Introduction to AWS EC2 and Scaling Concepts

Before jumping into hands-on work, it's important to understand the core AWS services involved. Amazon EC2 (Elastic Compute Cloud) is one of the most widely used cloud services for deploying applications, running servers, hosting websites, or creating test environments. EC2 instances function similarly to virtual machines but offer high scalability, flexibility, and integration with AWS’s global infrastructure.

Auto Scaling Groups (ASG) are a powerful feature that automatically adjusts the number of running EC2 instances based on demand, ensuring optimal performance and cost efficiency. Hosting a website on EC2 is a practical and common activity that deepens understanding of security groups, instance types, networking, web servers, and storage.

In the following sections, you will learn how to launch an EC2 instance, deploy a basic website, and configure an Auto Scaling Group step-by-step.

Launching an Amazon EC2 Instance

Launching an EC2 instance is the foundational task for most AWS cloud activities. It involves selecting an AMI (Amazon Machine Image), choosing an instance type, configuring storage, setting up networking, and connecting to the virtual machine. Following these steps helps beginners understand AWS compute services handling and prepares them for more advanced workloads.

Step 1: Log in to the AWS Management Console

The AWS Management Console is the web-based interface used for managing all AWS services. Once logged in, navigate to the EC2 dashboard using the search bar. EC2 includes resources such as instances, security groups, key pairs, load balancers, volumes, and AMIs.

Step 2: Choose β€œLaunch Instance”

Clicking β€œLaunch Instance” opens a configuration workflow. Here you define the specifications of your server. Ensure you select relevant settings according to your use case or as part of the learning activity.

Step 3: Select an Amazon Machine Image (AMI)

Amazon Machine Images serve as templates for EC2 instances. The most commonly used AMIs include Amazon Linux, Ubuntu Server, Red Hat Enterprise Linux, and Windows Server. For this hands-on activity, Amazon Linux 2 AMI is a reliable and free-tier eligible choice.

Step 4: Select an Instance Type

Choose an instance type based on CPU, memory, storage, and networking requirements. For basic testing or website hosting, the t2.micro or t3.micro instance type works well as part of the AWS Free Tier.

Step 5: Configure Key Pair for Secure Login

Key pairs allow secure login to your instance using SSH (Secure Shell). Create a new key pair if you don't already have one. Store the private key (.pem file) securely, as it cannot be re-downloaded.

Step 6: Configure Security Groups

Security groups control inbound and outbound traffic to your instances. To host a website or log in via SSH, add the following rules:

  • SSH – Port 22 (for Linux login)
  • HTTP – Port 80 (for web hosting)
  • HTTPS – Port 443 (if using secure web traffic)

These rules ensure your instance can be accessed remotely and can serve web pages to users.

Step 7: Launch the Instance

After reviewing all settings, click β€œLaunch Instance.” Within a few seconds to minutes, your instance becomes active. Check the Instance ID, Public IP address, and status checks before connecting.

Step 8: Connect to the EC2 Instance

Use SSH to connect to your Linux instance from a terminal. Below is an example of the connection command format:


ssh -i "your-key.pem" ec2-user@public-ip-address

Once connected, you have full terminal access to your virtual machine. From here, you can install software, configure services, deploy a website, or perform administrative tasks.

Hosting a Website on an EC2 Instance

After launching and connecting to your EC2 instance, the next hands-on activity is hosting a basic website. This involves installing a web server, configuring files, testing access, and verifying permissions. Hosting a website on EC2 is a common requirement for AWS Cloud Practitioner, Solutions Architect, and Developer learning paths.

Step 1: Update the System Packages

Keeping packages updated ensures security and compatibility. Use the following command:


sudo yum update -y

Step 2: Install a Web Server

Apache (httpd) is one of the most popular web servers. Install it using:


sudo yum install httpd -y

Step 3: Start and Enable the Web Server

Run the following commands to start Apache and enable it on boot:

sudo systemctl start httpd
sudo systemctl enable httpd

Step 4: Create a Website Homepage

Create an index.html file inside the Apache directory. This will serve as the homepage of your hosted website.

Step 5: Open Port 80 in Security Groups

If you haven't already, ensure that the instance security group has an inbound rule allowing HTTP (port 80). This allows users to access your website publicly via the instance’s public IP address.

Step 6: Test the Website

Open any browser and enter the public IP of your EC2 instance. If everything is configured correctly, your webpage will load successfully.

This activity teaches essential web hosting concepts, file permissions, server administration, security, and infrastructure testingβ€”skills highly valuable for cloud engineers, developers, and students.

Setting Up an Auto Scaling Group

An Auto Scaling Group (ASG) automatically adjusts the number of EC2 instances based on demand. This ensures that your applications maintain performance during high traffic and reduce costs during low traffic periods. Learning ASG configuration is important for implementing fault tolerance, scalability, elasticity, and high availability in AWS architectures.

Step 1: Create a Launch Template

A Launch Template defines configuration settings such as AMI, instance type, key pair, security groups, and user data. It acts as a blueprint for creating instances inside the ASG.

You can create a simple Launch Template using the AWS Console. Include user data to automatically install a web server on newly launched instances. Example user data:

#!/bin/bash
yum update -y
yum install httpd -y
systemctl start httpd
systemctl enable httpd
echo "Welcome from Auto Scaling Instance" > /var/www/html/index.html

Step 2: Create an Auto Scaling Group

After creating the launch template, proceed to create an ASG. Define the following parameters:

  • VPC and Subnets – Choose multi-AZ subnets for high availability
  • Load Balancer (optional but recommended)
  • Health Checks – EC2 or ELB health checks
  • Desired Capacity – Number of instances you want running initially
  • Minimum Capacity – Minimum allowed instances
  • Maximum Capacity – Upper limit for scaling

Step 3: Configure Scaling Policies

Scaling policies determine when the ASG should add or remove instances. Common policies include:

  • CPU utilization threshold (e.g., add instance when CPU > 70%)
  • Network traffic metrics
  • Target tracking scaling policy
  • Scheduled scaling

Step 4: Attach a Load Balancer (Optional but Recommended)

ALBs (Application Load Balancers) distribute traffic across multiple EC2 instances. When used with ASGs, this helps ensure traffic reaches healthy instances only.

Step 5: Test Auto Scaling Behavior

To test scaling, you can artificially increase CPU load. For example:


sudo yum install stress -y
stress --cpu 4

If the CPU usage crosses your scaling threshold, the ASG launches new instances automatically. Similarly, when load reduces, it terminates unneeded instances.

EC2, Website Hosting, and Auto Scaling

Following best practices improves performance, security, and reliability:

  • Always use IAM roles instead of hard-coded credentials.
  • Keep AMIs and packages updated.
  • Use Elastic IP for persistent IP mapping.
  • Enable CloudWatch monitoring for better visibility.
  • Store logs in S3 for long-term retention.
  • Use Load Balancers in production setups.
  • Enable detailed monitoring for scaling accuracy.
  • Automate using Infrastructure as Code (CloudFormation, Terraform).

This comprehensive hands-on activity guide helps learners gain practical experience in launching EC2 instances, hosting websites, and configuring Auto Scaling Groups in AWS. It not only enhances understanding of cloud infrastructure but also prepares users for real-world cloud engineering tasks and AWS certifications. The structured workflow and best practices described here will help you build scalable, reliable, and cost-efficient applications in AWS.

logo

AWS

Beginner 5 Hours
Hands-on Activities: Launch an EC2 Instance, Host a Website, Configure Auto Scaling Group

Hands-on Activities: Launch an EC2 Instance, Host a Website, and Set Up an Auto Scaling Group

This detailed hands-on guide covers three of the most essential cloud engineering tasks in Amazon Web Services (AWS): launching an EC2 instance, hosting a website, and configuring an Auto Scaling Group. Whether you are learning AWS for certification, preparing for a cloud engineering job, or simply exploring cloud computing fundamentals, these activities provide a solid foundation. The document is structured in simple, digestible sections and includes step-by-step explanations, relevant best practices, and useful commands. All code blocks are formatted using the required HTML structure.

Introduction to AWS EC2 and Scaling Concepts

Before jumping into hands-on work, it's important to understand the core AWS services involved. Amazon EC2 (Elastic Compute Cloud) is one of the most widely used cloud services for deploying applications, running servers, hosting websites, or creating test environments. EC2 instances function similarly to virtual machines but offer high scalability, flexibility, and integration with AWS’s global infrastructure.

Auto Scaling Groups (ASG) are a powerful feature that automatically adjusts the number of running EC2 instances based on demand, ensuring optimal performance and cost efficiency. Hosting a website on EC2 is a practical and common activity that deepens understanding of security groups, instance types, networking, web servers, and storage.

In the following sections, you will learn how to launch an EC2 instance, deploy a basic website, and configure an Auto Scaling Group step-by-step.

Launching an Amazon EC2 Instance

Launching an EC2 instance is the foundational task for most AWS cloud activities. It involves selecting an AMI (Amazon Machine Image), choosing an instance type, configuring storage, setting up networking, and connecting to the virtual machine. Following these steps helps beginners understand AWS compute services handling and prepares them for more advanced workloads.

Step 1: Log in to the AWS Management Console

The AWS Management Console is the web-based interface used for managing all AWS services. Once logged in, navigate to the EC2 dashboard using the search bar. EC2 includes resources such as instances, security groups, key pairs, load balancers, volumes, and AMIs.

Step 2: Choose “Launch Instance”

Clicking “Launch Instance” opens a configuration workflow. Here you define the specifications of your server. Ensure you select relevant settings according to your use case or as part of the learning activity.

Step 3: Select an Amazon Machine Image (AMI)

Amazon Machine Images serve as templates for EC2 instances. The most commonly used AMIs include Amazon Linux, Ubuntu Server, Red Hat Enterprise Linux, and Windows Server. For this hands-on activity, Amazon Linux 2 AMI is a reliable and free-tier eligible choice.

Step 4: Select an Instance Type

Choose an instance type based on CPU, memory, storage, and networking requirements. For basic testing or website hosting, the t2.micro or t3.micro instance type works well as part of the AWS Free Tier.

Step 5: Configure Key Pair for Secure Login

Key pairs allow secure login to your instance using SSH (Secure Shell). Create a new key pair if you don't already have one. Store the private key (.pem file) securely, as it cannot be re-downloaded.

Step 6: Configure Security Groups

Security groups control inbound and outbound traffic to your instances. To host a website or log in via SSH, add the following rules:

  • SSH – Port 22 (for Linux login)
  • HTTP – Port 80 (for web hosting)
  • HTTPS – Port 443 (if using secure web traffic)

These rules ensure your instance can be accessed remotely and can serve web pages to users.

Step 7: Launch the Instance

After reviewing all settings, click “Launch Instance.” Within a few seconds to minutes, your instance becomes active. Check the Instance ID, Public IP address, and status checks before connecting.

Step 8: Connect to the EC2 Instance

Use SSH to connect to your Linux instance from a terminal. Below is an example of the connection command format:

ssh -i "your-key.pem" ec2-user@public-ip-address

Once connected, you have full terminal access to your virtual machine. From here, you can install software, configure services, deploy a website, or perform administrative tasks.

Hosting a Website on an EC2 Instance

After launching and connecting to your EC2 instance, the next hands-on activity is hosting a basic website. This involves installing a web server, configuring files, testing access, and verifying permissions. Hosting a website on EC2 is a common requirement for AWS Cloud Practitioner, Solutions Architect, and Developer learning paths.

Step 1: Update the System Packages

Keeping packages updated ensures security and compatibility. Use the following command:

sudo yum update -y

Step 2: Install a Web Server

Apache (httpd) is one of the most popular web servers. Install it using:

sudo yum install httpd -y

Step 3: Start and Enable the Web Server

Run the following commands to start Apache and enable it on boot:

sudo systemctl start httpd sudo systemctl enable httpd

Step 4: Create a Website Homepage

Create an index.html file inside the Apache directory. This will serve as the homepage of your hosted website.

Step 5: Open Port 80 in Security Groups

If you haven't already, ensure that the instance security group has an inbound rule allowing HTTP (port 80). This allows users to access your website publicly via the instance’s public IP address.

Step 6: Test the Website

Open any browser and enter the public IP of your EC2 instance. If everything is configured correctly, your webpage will load successfully.

This activity teaches essential web hosting concepts, file permissions, server administration, security, and infrastructure testing—skills highly valuable for cloud engineers, developers, and students.

Setting Up an Auto Scaling Group

An Auto Scaling Group (ASG) automatically adjusts the number of EC2 instances based on demand. This ensures that your applications maintain performance during high traffic and reduce costs during low traffic periods. Learning ASG configuration is important for implementing fault tolerance, scalability, elasticity, and high availability in AWS architectures.

Step 1: Create a Launch Template

A Launch Template defines configuration settings such as AMI, instance type, key pair, security groups, and user data. It acts as a blueprint for creating instances inside the ASG.

You can create a simple Launch Template using the AWS Console. Include user data to automatically install a web server on newly launched instances. Example user data:

#!/bin/bash yum update -y yum install httpd -y systemctl start httpd systemctl enable httpd echo "Welcome from Auto Scaling Instance" > /var/www/html/index.html

Step 2: Create an Auto Scaling Group

After creating the launch template, proceed to create an ASG. Define the following parameters:

  • VPC and Subnets – Choose multi-AZ subnets for high availability
  • Load Balancer (optional but recommended)
  • Health Checks – EC2 or ELB health checks
  • Desired Capacity – Number of instances you want running initially
  • Minimum Capacity – Minimum allowed instances
  • Maximum Capacity – Upper limit for scaling

Step 3: Configure Scaling Policies

Scaling policies determine when the ASG should add or remove instances. Common policies include:

  • CPU utilization threshold (e.g., add instance when CPU > 70%)
  • Network traffic metrics
  • Target tracking scaling policy
  • Scheduled scaling

Step 4: Attach a Load Balancer (Optional but Recommended)

ALBs (Application Load Balancers) distribute traffic across multiple EC2 instances. When used with ASGs, this helps ensure traffic reaches healthy instances only.

Step 5: Test Auto Scaling Behavior

To test scaling, you can artificially increase CPU load. For example:

sudo yum install stress -y stress --cpu 4

If the CPU usage crosses your scaling threshold, the ASG launches new instances automatically. Similarly, when load reduces, it terminates unneeded instances.

EC2, Website Hosting, and Auto Scaling

Following best practices improves performance, security, and reliability:

  • Always use IAM roles instead of hard-coded credentials.
  • Keep AMIs and packages updated.
  • Use Elastic IP for persistent IP mapping.
  • Enable CloudWatch monitoring for better visibility.
  • Store logs in S3 for long-term retention.
  • Use Load Balancers in production setups.
  • Enable detailed monitoring for scaling accuracy.
  • Automate using Infrastructure as Code (CloudFormation, Terraform).

This comprehensive hands-on activity guide helps learners gain practical experience in launching EC2 instances, hosting websites, and configuring Auto Scaling Groups in AWS. It not only enhances understanding of cloud infrastructure but also prepares users for real-world cloud engineering tasks and AWS certifications. The structured workflow and best practices described here will help you build scalable, reliable, and cost-efficient applications in AWS.

Related Tutorials

Frequently Asked Questions for AWS

An AWS Region is a geographical area with multiple isolated availability zones. Regions ensure high availability, fault tolerance, and data redundancy.

AWS EBS (Elastic Block Store) provides block-level storage for use with EC2 instances. It's ideal for databases and other performance-intensive applications.



  • S3: Object storage for unstructured data.
  • EBS: Block storage for structured data like databases.

  • Regions are geographic areas.
  • Availability Zones are isolated data centers within a region, providing high availability for your applications.

AWS pricing follows a pay-as-you-go model. You pay only for the resources you use, with options like on-demand instances, reserved instances, and spot instances to optimize costs.



AWS S3 (Simple Storage Service) is an object storage service used to store and retrieve any amount of data from anywhere. It's ideal for backup, data archiving, and big data analytics.



Amazon RDS (Relational Database Service) is a managed database service supporting engines like MySQL, PostgreSQL, Oracle, and SQL Server. It automates tasks like backups and updates.



  • Scalability: Resources scale based on demand.
  • Cost-efficiency: Pay-as-you-go pricing.
  • Global Reach: Availability in multiple regions.
  • Security: Advanced encryption and compliance.
  • Flexibility: Supports various workloads and integrations.

AWS Auto Scaling automatically adjusts the number of compute resources based on demand, ensuring optimal performance and cost-efficiency.

The key AWS services include:


  • EC2 (Elastic Compute Cloud) for scalable computing.
  • S3 (Simple Storage Service) for storage.
  • RDS (Relational Database Service) for databases.
  • Lambda for serverless computing.
  • CloudFront for content delivery.

AWS CLI (Command Line Interface) is a tool for managing AWS services via commands. It provides scripting capabilities for automation.

Amazon EC2 is a web service that provides resizable compute capacity in the cloud. It enables you to launch virtual servers and manage your computing resources efficiently.

AWS Snowball is a physical device used for data migration. It allows organizations to transfer large amounts of data into AWS quickly and securely.

AWS CloudWatch is a monitoring service that collects and tracks metrics, logs, and events, helping you gain insights into your AWS infrastructure and applications.



AWS (Amazon Web Services) is a comprehensive cloud computing platform provided by Amazon. It offers on-demand cloud services such as compute power, storage, databases, networking, and more.



Elastic Load Balancer (ELB) automatically distributes incoming traffic across multiple targets (e.g., EC2 instances) to ensure high availability and fault tolerance.

Amazon VPC (Virtual Private Cloud) allows you to create a secure, isolated network within the AWS cloud, enabling you to control IP ranges, subnets, and route tables.



Route 53 is a scalable DNS (Domain Name System) web service by AWS. It connects user requests to your applications hosted on AWS resources.

AWS CloudFormation is a service that enables you to manage and provision AWS resources using infrastructure as code. It automates resource deployment through JSON or YAML templates.



AWS IAM (Identity and Access Management) allows you to control access to AWS resources securely. You can define user roles, permissions, and policies to ensure security and compliance.



  • EC2: Provides virtual servers for full control of your applications.
  • Lambda: Offers serverless computing, automatically running your code in response to events without managing servers.

Elastic Beanstalk is a PaaS (Platform as a Service) offering by AWS. It simplifies deploying and managing applications by automatically handling infrastructure provisioning and scaling.



Amazon SQS (Simple Queue Service) is a fully managed message queuing service that decouples and scales distributed systems.

AWS ensures data security through encryption (both at rest and in transit), compliance with standards (e.g., ISO, SOC, GDPR), and access controls using IAM.

AWS Lambda is a serverless computing service that lets you run code in response to events without provisioning or managing servers. You pay only for the compute time consumed.



AWS Identity and Access Management controls user access and permissions securely.

A serverless compute service running code automatically in response to events.

A Virtual Private Cloud for isolated AWS network configuration and control.

Automates resource provisioning using infrastructure as code in AWS.

A monitoring tool for AWS resources and applications, providing logs and metrics.

A virtual server for running applications on AWS with scalable compute capacity.

Distributes incoming traffic across multiple targets to ensure fault tolerance.

A scalable object storage service for backups, data archiving, and big data.

EC2, S3, RDS, Lambda, VPC, IAM, CloudWatch, DynamoDB, CloudFront, and ECS.

Tracks user activity and API usage across AWS infrastructure for auditing.

A managed relational database service supporting multiple engines like MySQL, PostgreSQL, and Oracle.

An isolated data center within a region, offering high availability and fault tolerance.

A scalable Domain Name System (DNS) web service for domain management.

Simple Notification Service sends messages or notifications to subscribers or other applications.

Brings native AWS services to on-premises locations for hybrid cloud deployments.

Automatically adjusts compute capacity to maintain performance and reduce costs.

Amazon Machine Image contains configuration information to launch EC2 instances.

Elastic Block Store provides block-level storage for use with EC2 instances.

Simple Queue Service enables decoupling and message queuing between microservices.

A serverless compute engine for containers running on ECS or EKS.

Manages and groups multiple AWS accounts centrally for billing and access control.

Distributes incoming traffic across multiple EC2 instances for better performance.

A tool for visualizing, understanding, and managing AWS costs and usage over time.

line

Copyrights © 2024 letsupdateskills All rights reserved