DEV Community

Cover image for AWS: Launch an EC2 Instance from the Web Console
Deepak Porwal
Deepak Porwal

Posted on

AWS: Launch an EC2 Instance from the Web Console

You are a Systems Adminstrator at Globomantics corporation. You have been asked to investigate the IaaS (Infrastructure as a Service) offerings in Amazon Web Services. To do this, you've been asked to launch an EC2 instance so that you and your team can test out the Virtual Machine capabilities on AWS.

  1. Click Open AWS console to access the lab environment, then use the provided credentials to log in.

    Note: Ensure you are in the US West (Oregon) region in the top-right corner of your screen.

  2. Use the search bar at the top to navigate to the EC2 service.

  3. Click the Launch instance button and then click Launch instance.

  4. At the top of the list of AMIs on the Choose an Amazon Machine Image start page, click the Select button for the option labeled Amazon Linux 2 AMI (HVM), SSD Volume Type. Keep the radio button for 64-bit (x86) selected.

✅ Note

This Quick Start page allows you to choose from a variety of different Amazon approved Quick Start images. Options include: Amazon Linux, Red Hat, Suse, Ubuntu, and Windows. Amazon curates this selection of Quick Start options and vendors must agree to continually update the images that appear here, to ensure they are kept up-to-date with security patches.

✅ Note

If you wanted to launch an EC2 option from an AMI (Amazon Machine Image) that does not appear in the limited Quick Start list, you could select from the other tabs on the left hand side. These options include My AMI's (for images your organization has built themselves), AWS Marketplace (which includes AMI's from many different vendors, often using a pay per minute model), and Community AMI's, where you can find images for additional operating systems, such as CentOS and Debian.

  1. On the Choose an Instance Type page, keep the t2.micro instance type selected, then click the Next: Configure Instance Details button at the bottom right. This instance type creates a virtual machine with 1 vCPU (virtual CPU) and 1 GiB of memory.

✅ Note

Notice that the t2.micro instance type has a green label for "Free tier eligible." AWS offers a free tier that allows you to launch and run a t2.micro instance for 1 year without incurring any charges. Be aware that, if this were your own AWS account, other AWS services may cause your account to incur charges – but it is possible to run some things in AWS for a year without paying anything, thanks to the generous Free tier.

  1. On the Configure Instance Details page, review the available options, but keep the defaults selected. Scroll down to the Advanced Details section and expand it if it is collapsed.

  2. In the User data section, keep As text selected, and then paste the following lines into the text box:

#!/bin/bash -xe
yum install -y ruby
cd /opt
curl -O
chmod +x ./install
./install auto
Enter fullscreen mode Exit fullscreen mode

Then click the Next: Add Storage button at the bottom right.

✅ Note

The above script will download and install the AWS CodeDeploy agent immediately after the EC2 instance is launched. The usage of EC2 User data scripts is the most common way to initialize or bootstrap EC2 virtual machines.

  1. On the Add Storage page, review the EBS (Elastic Block Store) Volume attributes, keep the default 8 GiB size, and then click the Next: Add Tags button at the bottom right.

  2. On the Add Tags page, click the Add Tag button, enter a Key of env and set its Value to test.

  3. Add another tag with the Key Name and the Value webserver1.

✅ Note

The Name tag (case sensitive) is a special tag that AWS uses to display the user-defined instance name on the Instances web console page. Notice that these tags will be applied to both the EC2 instance and the EBS volume.

  1. Click the Next: Configure Security Group button.

  2. On the Configure Security Group page, keep the Create a new security group radio button selected, keep the default Security group name of launch-wizard-1, and keep the auto generated Description.

ℹ️ Note

Notice that the launch wizard has populated a single Security Group Rule with Type: SSH, Protocol: TCP, Port Range: 22, and Source: (this means any IP address). This rule opens up access for the entire internet to SSH into the EC2 instance on port 22.

  1. Click the Review and Launch button.

✅ Note

For any AWS account and EC2 instance of real importance, you should never use a Security group named after the launch-wizard, and you should not allow SSH access from the entire internet. Instead, you should give your Security Group a name that is descriptive of its purpose or function, and you should use a VPN or a Bastion host for SSH access into your EC2 instances.

  1. On the Review page, you can review all of the options that you have selected throughout the Launch wizard process. Click the Launch button at the bottom right.

  2. You will now see a Select an existing key pair or create a new key pair modal. Click on the Choose an existing key pair dropdown and select Proceed without a key pair, then add a checkmark to the acknowledgement box that informs you that you will not be able to connect to the instance.

  3. Click the Launch Instances button.

✅ Note

Typically when launching an EC2 instance you would create and select an existing key pair that you've already added to your AWS account. This key pair allows you to SSH into the EC2 instance using the default user.

After a brief Initiating Instance Launches page, you'll be taken to a Launch Status page, and you should see a green box at the top of the page that says Your instances are now launching. You should also see a unique instance identifier, which looks like i-XXXXXXXXXX.

Congratulations! You have successfully used the EC2 Launch Wizard to create an EC2 instance on a t2.micro instance type, using the Amazon Linux 2 operating system, with a User data script that installs the AWS Code Deploy agent.

Verify the Instance Status

Now that your EC2 Instance has been launched, you will verify its status.

  1. You should still be on the Launch Status page from the last challenge. Click the View Instances button on the bottom right, which will take you to the Instances page.

  2. You should see your instance named webserver1 in the Instances list.

    Under the Instance state column, your instance should say Running.

  3. Check the box to the left of webserver1. You should now see details for the instance.

  4. Click on the Status checks tab. You should see green checkmarks and a passed message under both System status checks and Instance status checks. This indicates that your instance is viewed as 100% healthy and is ready for use.

✅ Note

If both of these statuses are not yet green, you may need to wait a few minutes for the status checks to complete their runs, which can take some time after the initial instance launch. The "System status checks" monitor the underlying AWS systems on which your instance runs. Only AWS can resolve "System Status check" issues, although you can Stop and then Start your instance to move it to new underlying hardware. The "Instance status checks" monitor the software and network configuration of your individual instance. If there is an issue with the Instance status check, and not an issue with the System status checks, then you can often resolve the issue on your own.

  1. Click on the Monitoring tab and you should see some activity in the graphs for CPU and Network activity. This activity confirms that your EC2 instance is using its vCPU and that it is communicating on the network.

    Note: If no activity is shown on the graphs, wait a few minutes and then click the refresh button at the top right, above the graph boxes, inside the Monitoring tab.

Congratulations! You have verified the status checks on your new EC2 instance and have verified that it is using its CPU and network.

Your team can now begin experimenting with this EC2 instance and others, in order to evaluate the IaaS capabilities of AWS. Nice work!

Launch an EC2

Top comments (0)