Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. Amazon EC2"s simple web service interface allows you to obtain and configure capacity with minimal friction. Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing you to quickly scale capacity, both up and down, as your computing requirements change. Amazon EC2 changes the economics of computing by allowing you to pay only for capacity that you actually use.
This lab will walk you through launching, configuring, and customizing an EC2 virtual machine to run a web server. It will walk you though successfully provisioning and starting an EC2 instance using the AWS Management Console.
In this lab, you will need to create an EC2 instance using an SSH keypair. The following steps outline creating a unique SSH keypair for you to use in this lab.
-
Sign into the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2.
-
In the upper-right corner of the AWS Management Console, confirm you are in the desired AWS region (e.g., Oregon).
-
Click on Key Pairs in the NETWORK & SECURITY section near the bottom of the leftmost menu. This will display a page to manage your SSH key pairs.
-
To create a new SSH key pair, click the Create Key Pair button at the top of the browser window.
-
In the resulting pop up window, type [First Name]-[LastName]-ImmersionDay into the Key Pair Name: text box and click Create.
-
The page will download the file "[Your-Name]-ImmersionDay.pem" to the local drive. Follow the browser instructions to save the file to the default download location.
-
Remember the full path to the file .pem file you just downloaded.
NOTE: You will use the Key Pair you just created to manage your EC2 instances for the rest of the lab.
In this example we will launch a default Amazon Linux Instance with an Apache/PHP web server installed on initialization.
-
Click EC2 Dashboard towards the top of the left menu.
-
Click on Launch Instance
-
In the Quick Start section, select the first Amazon Linux AMI and click Select
-
Select the General purpose t2.micro instance type and click Next: Configure Instance Details
-
On the Configure Instance Details page, expand the Advanced Details section at the bottom of the page, and type the following initialization script information (you can use Shift-Enter to create the necessary line break, or alternatively you could type this into Notepad and copy & paste the results) into the User Data field (this will automatically install and start the Apache web server on launch) and click Next: Add Storage :
#include https://awstechbootcamp.s3.amazonaws.com/bootstrap.sh
-
Click Next: Tag Instance to accept the default Storage Device Configuration.
Next, choose a "friendly name" for your instance. This name, more correctly known as a tag, will appear in the console once the instance launches. It makes it easy to keep track of running machines in a complex environment. Named yours according to this format: "[Your Name] Web Server.
Then click Next: Configure Security Group.
-
You will be prompted to create a new security group, which will be your firewall rules. On the assumption that we are building out a Web server, name your new security group "[Your Name] Web Tier", and confirm an existing SSH rule exists which allows TCP port 22 from anywhere. Click Add Rule:
-
Select HTTP from the Type dropdown menu, and confirm TCP port 80 is allowed form anywhere. Click Add Rule.
-
Click the Review and Launch button after configuring the security group.
-
Review your choices, and then click Launch.
-
Select the [YourName]-ImmersionDay key pair that you created in the beginning of this lab from the drop and check the "I acknowledge" checkbox. Then click the Launch Instances button.
-
Click the View Instances button in the lower righthand portion of the screen to view the list of EC2 instances. Once your instance has launched, you will see your web Server as well as the Availability Zone the instance is in and the publicly routable DNS name.
-
Click the checkbox next to your web server name to view details about this EC2 instance.
-
Wait for the instance to pass the Status Checks to finish loading.
Finished initializing
-
Open a new browser tab and browse the Web Server by entering the EC2 instance"s Public DNS name into the browser. The EC2 instance"s Public DNS name can be found in the console by reviewing the "Public DNS" name line highlighted above.
You should see a website that looks like the following:
Great Job! You have deployed a server and launched a web site in a matter of minutes!!