Skip to main content
Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console. Open IP Lab Portal

Overview

Lab details

  1. This lab walks you through the steps to launch and configure a virtual machine in the Amazon cloud.
  2. You will practice using Amazon Machine Images to launch Amazon EC2 Instances
  3. You will Stop, Start, Reboot and Terminate the Instance.
  4. Duration: 45 minutes
  5. AWS Region: US East (N. Virginia) us-east-1

Introduction

What is EC2?

  • AWS defines it as Elastic Compute Cloud.
  • It’s a virtual environment where “you rent” to have your environment created, without purchasing.
  • Amazon refers to these virtual machines as Instances.
  • Preconfigured templates can be used to launch instances. These templates are referred to as images. Amazon provides these images in the form of AMIs (Amazon Machine Images).
  • Allows you to install custom applications and services.
  • Scaling of infrastructure i.e., up or down is easy based on the demand you face.
  • AWS provides multiple configurations of CPU, memory, storage etc., through which you can pick the flavor that’s required for your environment.
  • No limitation on storage. You can pick the storage based on the type of the instance that you are working on.
  • Temporary storage volumes are provided, which are called Instance Store Volumes. Data stored in this gets deleted once the instance is terminated.
  • Persistent storage volumes are available and are referred to as EBS (Elastic Block Store) volumes.
  • These instances can be placed at multiple locations which are referred to as Regions and Availability Zones (AZ).
  • You can have your Instances distributed across multiple AZs i.e., within a single Region, so that if an instance fails, AWS automatically remaps the address to another AZ.
  • Instances deployed in one AZ can be migrated to another AZ.
  • To manage instances, images, and other EC2 resources, you can optionally assign your own metadata to each resource in the form of tags.
  • A Tag is a label that you assign to an AWS resource. It contains a key and an optional value, both of which are defined by you.
  • Each AWS account comes with a set of default limits on the resources on a per-Region basis.
  • For any increase in the limit you need to contact AWS.
  • To work with the created instances, we use Key Pairs.

Architecture diagram

Task details

  1. Sign in to AWS Management Console
  2. Launching an EC2 Instance
  3. SSH into EC2 Instance
  4. Install an Apache Server
  5. Create and publish page
  6. Stopping the Running Instance
  7. Starting the Stopped Instance
  8. Rebooting the Running Instance
  9. Validation of the Lab
  10. Terminating the Running Instance

Launching the lab environment

  1. To launch the lab environment, Click on the Launch lab button.
  2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
  3. Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time

Lab guide

Lab steps

Task 1: Sign in to AWS Management Console

  1. Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
  2. On the AWS sign-in page,
    • Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
    • Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button.
  3. Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
  4. Select Maybe later in New AWS Console Home page pop-up
If you face any issues, please go through FAQs and Troubleshooting.

Task 2: Launching an EC2 Instance

  1. Make sure you are in the N.Virginia Region.
  2. Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in the Compute section.
  3. Navigate to Instances on the left panel and click on Launch Instances
  4. Name : Enter MyEC2Server
  5. For Amazon Machine Image (AMI): Select Amazon Linux 2023 kernel-6.1 AMI in the search box and click on it.
  6. For Instance Type: select t2.micro
  1. For Key pair: Select Create a new key pair Button
    • Key pair name: MyEC2Key
    • Key pair type: RSA
    • Private key file format: .pem
  2. Select Create key pair Button.
  3. In Network Settings Click on Edit:
  • Auto-assign public IP: Enable
  • Security group name: Enter whizlabs_SG
  • Description: Enter a description of Security group for the whizlabs_SG
    • To add SSH:
      • Choose Type: SSH
      • Source: Anywhere
    • For HTTP:
      • Click on Add security group rule
      • Choose Type: HTTP
      • Source: Anywhere
    • For HTTPS:
      • Click on Add security group rule
      • Choose Type: HTTPS
      • Source: Anywhere
  1. Keep Rest thing Default and Click on Launch Instance Button.
  2. Select View all Instances to View Instance you Created
  3. Launch Status: Your instance is now launching. Click on View Instances. In the dashboard find your instance and wait for complete initialization of the instance until the instance state changes to running.
  1. Select the instance which you have created and then below in Details, note the IPv4 Public IP Address of the EC2 instance. A sample is shown in the screenshot below.

Task 3: SSH into EC2 Instance

  1. Please follow the steps in SSH into EC2 Instance.

Task 4: Install an Apache Server

  1. Switch to root user
  2. Now run the updates using the following command:
  3. Once completed, let’s install and run an apache server
    1. Install the Apache web server:
    2. When prompted, press “Y” to confirm.
    3. Start the web server
    4. Enable httpd:
    5. Check the web server status
    6. You can see Active status is running.
    7. You can test that your web server is properly installed and started by entering the public IP address of your EC2 instance in the address bar of a web browser. If your web server is running, you will see the Apache test page. If you don’t see the Apache test page, then verify whether you followed the above steps properly and check your inbound rules for the security group that you created.

Task 5: Create and publish page

  1. Navigate to the HTML folder where we will put our html page to be published.
  2. Create a sample test.html file using nano editor:
  3. Enter sample HTML content provided below in the file and save the file with Ctrl+X, click Y to confirm the save then press Enter to confirm filename.
  4. Restart the web server by using the following command:
  5. Now enter the file name after the public IP from when you created ec2 instance in the browser, and you can see your HTML content.
    • Sample URL: 52.90.56.138/test.html

Task 6: Stopping the Running Instance

  1. Select your EC2 Instance, click on Instance state and select Stop instance.
  2. The instance performs a normal shutdown and stops running. Its status changes to stopping and then stopped.
  3. Any Amazon EBS volumes remain attached to the instance and their data persists.
  4. Any data stored in the RAM of the host computer or the instance store volumes of the host computer is gone.
  5. You can change the instance type, user data, and EBS-optimization attributes of a stopped instance.
  6. AWS doesn’t charge usage for a stopped instance, or data transfer fees, but they do charge for the storage of any Amazon EBS volumes. This feature is helpful for instances unused for awhile.
  7. If you go to the web page and refresh, there will be aTimeOut as the IPv4 Public IP does not exist if an instance is stopped.

Task 7: Starting the Stopped Instance

  1. Select your EC2 instance, click on Instance state and select Start instance.
  2. The status changes from stopped to pending. After few minutes, the status changes to running
  3. A new IPv4 Public IP will be assigned to the Instance.
  4. If you open a web page with that IP address, you can see your HTML content
    • Sample URL: 3.86.82.65/test.html

Task 8: Rebooting the Running Instance

  1. An instance reboot is equivalent to an operating system reboot. In most cases, it takes only a few minutes to reboot your instance.
  2. When you reboot an instance, it remains on the same physical host so your instance keeps its public DNS name (IPv4), private IPv4 address, IPv6 address (if applicable), and any data on its instance store volumes.
  3. To Reboot, select the EC2 instance, click Instance state and select Reboot instance.
  4. Choose Yes, Reboot when prompted for confirmation.
Do you know?When you create an EC2 instance in AWS, the instance is assigned a unique identifier known as an Instance ID. This Instance ID is generated by AWS and is used to uniquely identify and track the instance throughout its lifecycle.

Task 9: Validation of the Lab

  1. Once the labs steps are completed, please click on Check my work button on right side panel.
  2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
  3. Sample Output:

Task 10: Terminating the Running Instance

  1. You can delete your instance when you no longer need it. This is referred to as terminating your instance.
  2. To Terminate, select the EC2 instance, click Instance state and select Terminate instance.
  3. As soon as the state of an instance changes to terminating or terminated, you stop incurring charges for that instance.
  4. You can’t connect to or start an instance after you’ve terminated it.

Completion and conclusion

  1. You have successfully created and launched an EC2 Instance.
  2. You have logged into the EC2 instance by SSH, installed the Apache server and published a page.
  3. You have Stopped, Started, Rebooted and Terminated the Instance
  4. You have checked the web page with all the conditions.

End lab

  1. Sign out of the AWS Account.
  2. You have successfully completed the lab.
  3. Once you have completed the steps, click on End lab in the IP Lab Portal.

What gets checked

When you press Check my work, the platform verifies each of these:
  • Launch an EC2 Instance — Check whether an EC2 Instance is launched or not.
  • Validate EC2 Instance Type t2.micro — Check whether the EC2 instance type is t2.micro.
  • Launch EC2 AMI type Amazon Linux — Check whether the EC2 instance is launched using an Amazon AMI.
  • Check EC2 Web Application Status — Check whether an EC2 Web Application is Deployed in the EC2 Instance or not.