ec2 icon

Challenge Objectives:

  1. Launch EC2
  2. Update Security Groups
  3. Resize Instance Type and EBS Volume
  4. Test Termination Protection

Launching EC2

Objective:

  • This hands-on exercise is designed to familiarize you with the Launching, Resizing, and terminating an EC2 instances.
  • To learn how to use the AWS console and its services.

Task 1: Launch an EC2 instance.

  1. Log in to the AWS management console
  2. management console
  3. Go to Compute Services and click on EC2. Then, EC2 -> Instances
  4. ec2 dashboard
  5. Click on "Launch Instance".
  6. launch instance
  7. Name the instance type: Web Server.
  8. Click on Additional Tags. Configure tags:
    • Key: Name
    • Value: Web Server
  9. name tags
  10. Choose an AMI: Select "Amazon Linux 2 AMI" under Application and OS Images. Make sure it is free tier eligible.
  11. ami
  12. Choosing an Instance type: Select t2.micro instance. Make sure it is pointed to "free tier eligible".
  13. In key pair (login), Select Create a new key pair.
  14. Give the name of your choice for the key pair (examplekey).
  15. Download the key pair.
  16. In Network Settings, edit and create a security group and keep the rest as default.
    • Security group name: Web Server Security Group
    • Description: Security Group for my Web Server
    • Delete the existing SSH rule.
  17. network settings
  18. In Configure Storage leave settings as default.
  19. In Advanced details, enable termination protection.
  20. Scroll down further in Advanced details to the User Data field. Copy the following commands and paste them in the User data field.

                      #!/bin/bash
                      yum -y install httpd
                      systemctl enable httpd
                      systemctl start httpd
                      echo '<html><h1>Hello From Your Web Server!</h1></html>' > /var/www/html/index.html
                    

  21. Under Summary click Launch Instance
  22. summary and launch
  23. The Instance will show as successfully initiated.
  24. Now, scroll down to click View Instance.
  25. Wait until the instance state changes from pending to running.
  26. running instance
  27. In the Description panel below, observe the right column which has Public DNS received by the instance from the Internet.
  28. public dns
  29. You have successfully launched a EC2 Web Server


Task 2: Update your security group and access the web server

  1. Select your EC2 and in the details section copy the IPv4 Public IP of your instance to your clipboard.
  2. public dns
  3. Open a private tab in your web browser, paste the IP address you just copied, then press Enter.
  4. Note: Are you able to access your web server? Why not? You are not currently able to access your web server because the security group is not permitting inbound traffic on port 80, which is used for HTTP web requests. This is a demonstration of using a security group as a firewall to restrict the network traffic that is allowed in and out of an instance. To correct this, you will now update the security group to permit web traffic on port 80.

    error page
  5. Keep the browser tab open, but return to the EC2 Management Console tab.
  6. In the left navigation pane, Under Network & Security, click Security Groups.
  7. Select Web Server Security Group.
  8. Click the Inbound rules. The security group currently has no rules.
  9. inbound rules
  10. Click Edit Inbound rules, then Add rule.
  11. Configure:

    • Type: HTTP
    • Source: Anywhere Ipv4
  12. Click Save rules
  13. Return to the web server tab that you previously opened and refresh the page. You should see the message "Hello from Your Web Server."
  14. hello world
  15. You have successfully modified your security group to permit HTTP traffic into your Amazon EC2 Instance.


Task 3: Resize Your Instance: Instance Type and EBS Volume

  1. Open the EC2 Management Console, in the left navigation pane, click Instances. Web Server should already be selected.
  2. ec2 dashboard
  3. Stop Your Instance: Next to the Actions button, select Instance State then in the menu select Stop Instance.
  4. Wait for the Instance State to display stopped.

    stopped instance
  5. Change The Instance Type: In the Actions menu, select Instance Settings then Change Instance Type, then configure:
    • Instance Type: t2.small
  6. Click Apply.
  7. actions menu

    change instance type
  8. Resize the EBS Volume: In the left navigation menu, click Volumes.
  9. Select the Volume then In the Actions menu, select Modify Volume. The disk volume currently has a size of 8 GiB. You will now increase the size of this disk. Change the size to 10 then click Modify.
  10. modify volume
  11. Start the Resized Instance: In the left navigation pane, click Instances. select Instance State In the menu, select Start Instance.
  12. You have successfully resized your Amazon EC2 Instance. In this task, you changed your instance type from t2.micro to t2.small. You also modified your root disk volume from 8 GiB to 10 GiB.


Task 4 Test Termination Protection

  1. In the left navigation pane, click Instances.
  2. Select Instance State, then select Terminate Instance.
  3. failed termination

    Note: These instances have Termination Protection and will not be terminated. Use the Change Termination Protection option from the Instances settings in the Actions menu to allow termination of these instances. Also, the Yes, terminate button is dimmed and cannot be clicked.

    actions menu

    termination
  4. Attempt to terminate the instance again.
  5. Now you have successfully tested termination protection and terminated your instance.
  6. successful termination