← Back to Labs
Fundamental00:30:00

Introduction to Amazon Elastic Compute Cloud (EC2)

Task 1

Task 1: Sign in to AWS Management Console

↑ Top
  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,
  3. 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.
  4. 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.
  5. Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2

Task 2: Provision Default VPC

↑ Top
  1. Navigate to VPC by clicking on the Services menu in the top, then click on VPC or Open the Amazon VPC console via https://console.aws.amazon.com/vpc/.
  2. Delete the default VPC by following the below steps:
  3. In the navigation pane, choose Your VPCs.
  4. Select the VPC with value as yes in default VPC column.
  5. Go to actions button and click on delete VPC button.
  6. Check I acknowledge that I want to delete my default VPC option.
  7. Type default delete VPC and click on Delete button.
  8. Now to provision Default VPC again, Refresh your console go to actions and click Create default VPC
  9. Click Create default VPC button and your default VPC will get created
Task 3

Task 3 : Launch an EC2 Instance with desired specifications

↑ Top
  1. Ensure you are in the US East (N. Virginia) us-east-1 Region to begin launching an EC2 instance in the Amazon cloud.
  2. Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in the Compute section.
  3. Click on the Instances option on the left panel, and then click on the Launch Instances button.
  4. Name : Enter MyEC2Server
  5. Select Amazon Linux 2023 AMI from the dropdown.
  6. Note: if there are two AMI's present for Amazon Linux 2o23 kernel-6.1 AMI.
  7. An instance type in AWS refers to a virtual server configuration that determines the computing resources, such as CPU, memory, and storage, available to an instance. It is the basic building block for creating an EC2 instance in the AWS cloud.
  8. For Instance Type: Select t2.micro
  9. t2.micro is an instance type in AWS that comes with 1 vCPU, and 1GB memory and is suitable for low-traffic web servers, small development environments, and other lightweight applications.
  10. AWS key pair is a secure pair of keys used for login and access to EC2 instances. It includes a public key placed on the instance and a private key kept on the user's local computer, used for authentication to prevent unauthorized access.
  11. For Key pair(login): Select Create a new key pair Button
  12. Key pair name: WhizKey
  13. Key pair type: RSA
  14. Private key file format: .pem
  15. In Network Settings, Click on Edit Button:
  16. Auto-assign public IP: Enable
  17. Select Create security group
  18. Security group name: Enter MyEC2Server_SG
  19. Description: Enter Security Group to allow traffic to EC2.
  20. We will now add the security group rules. SSH will already be present there.
  21. For HTTP, Select Add security group rule Button
  22. Choose Type: Select HTTP
  23. Source: Select Anywhere
  24. A security group is a virtual firewall that controls the inbound and outbound traffic for instances in a particular network in a cloud computing environment. Here we have selected SSH and HTTP rules that will allow incoming SSH and HTTP traffic to instances that are associated with the security group.
  25. Proceed with launching the instance while leaving all other settings as default. Simply click on the Launch Instance without modifying any other configuration.
  26. To view the instance that you have created, choose the View all Instances option.
  27. Launch Status: Once you have initiated the instance launch process, Go to the Instances page from the left menu and wait for your EC2 instance to become "Running" while ensuring the health check status is 2/2 checks passed for optimal performance.
  28. Select the instance that you have created and copy the public IPv4 address within the details section and paste it into the editor for later use. An example of this process is depicted in the screenshot provided.
Task 4

Task 4 : SSH into EC2 Instance using the key pair

↑ Top
  1. Select your EC2 instance (MyEC2Server) and click on the Connect button.
  2. Select EC2 Instance Connect option and click on Connect button. Keep everything else as default.
  3. A new tab will open in the browser where you can execute the Linux Commands.
  4. Please follow the steps in SSH into EC2 Instance for more options to SSH.
Task 5

Task 5: Install an Apache Server on the instance

↑ Top
  1. In this task, our goal is to configure an Amazon EC2 instance to run an Apache Web Server and verify its functionality by accessing the web server via a web browser using the instance's public IPv4 address.
  2. Switch to root user:
  3. sudo su
  4. Now run the updates using the following command:
  5. dnf update -y
  6. Once completed, lets install and run an apache server
  7. Install the Apache web server:
  8. dnf install httpd -y
  9. Start the web server:
  10. systemctl start httpd
  11. Now Enable httpd:
  12. systemctl enable httpd
  13. Check the webserver status
  14. systemctl status httpd
  15. You can see Active status is running.
  16. You can test that your web server is properly installed and started by entering the public IPv4 address of your EC2 instance in the address bar of a web browser. If your web server is running, then you 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 6

Task 6 : Create a web page and publish it on the instance

↑ Top
  1. In this task, you will add content to the index.html file using the "echo" command and restart the webserver. Then, you can view the content by entering the public IPv4 address followed by "/index.html" in a web browser, ensuring that the URL protocol is HTTP.
  2. To add the contents into index.html file using echo, copy and paste the below command to shell.
  3. echo "<html>Hi Lab, I am a public page</html>" > /var/www/html/index.html
  4. Restart the webserver by using the following command:
  5. systemctl restart httpd
  6. Now enter the file name, /index.html after the public IPv4 Address which you got when you created the ec2 instance in the browser, and you can see your HTML content.
  7. Make sure URL Protocol is http not https.
  8. Syntax: http://<Your_Public_IPv4_Address>/index.html
  9. Sample URL: http://52.87.50.168/index.html
  10. Note: If the index.html page is not loading, try removing s from the link, it should be HTTP.
  11. If you can see the above text in the browser, then you have successfully completed the lab.
  12. Do You Know?
  13. The Amazon EC2 P4d instance is the most powerful EC2 instance type available, with eight NVIDIA A100 Tensor Core GPUs, 1.1 TB of NVMe storage, and 400 Gbps network bandwidth, making it ideal for large-scale machine learning and HPC workloads.
Task 7

Task 7 : Validation of the Lab

↑ Top
  1. Once the lab steps are completed, please click on the Validation button on the left 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 :
  4. Completion and Conclusion
  5. You have successfully created and launched an Amazon EC2 instance
  6. You have successfully logged into the EC2 instance using SSH
  7. You have successfully installed an Apache server on the instance
  8. You have successfully created a webpage and published it.
  9. You have successfully validated the lab.
  10. End Lab
  11. Sign out of AWS Account.
  12. You have successfully completed the lab.
  13. Once you have completed the steps, click on End Lab from your lab lab console and wait till the process gets completed.
← Back to Labs