Getting Started with Linux on Amazon EC2
This lab will walk you through launching, configuring, and customizing a web server on Amazon EC2 Linux using the AWS Management Console.
In this lab, you will create an EC2 instance as your web server. To manage the instance, you need to be able to connect to it via SSH. The following steps outline how to create a unique SSH keypair for this purpose.
Navigate to the Amazon EC2 Service
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]-[Last Name]-ImmersionDay into the Key Pair Name text box. Select the “pem” file format and click Create key pair.

The key pair you created should automatically download to your laptop. Follow any browser instructions to save the file to the default download location. Verify that the file has downloaded and you can locate it. Remember the full path to this .pem file you just downloaded. This file contains your private key for future SSH connections.
You will see a message appear at the top of the screen that says “Successfully created key pair”. You will see the key pair you created listed.

You will use the Key Pair you just created to manage your EC2 instances for the rest of the lab.
You will create an IAM role to use as an EC2 Instance Profile. This allows the server to assume a role that has access to other AWS services, in this case we want to give it access to Amazon S3 (will be used in a later lab).
Go to the IAM Console at https://console.aws.amazon.com/iam/home#/home
Select “Roles” from the left hand menu, and then choose “Create Role”.

Select “AWS Service”, EC2 and select “Next: Permissions”

Type “S3Full” into the filter box, and then select the checkbox next to “AmazonS3FullAccess”. Select “Next: Tags”

Choose “Next:Review” and then enter the Role name as “S3EC2AccessRole”. Click “Create Role”.

In this example, we will launch an Amazon Linux 2 instance, bootstrap Apache/PHP, and install a basic web page that will display information about our instance.
Upon logging into your AWS Console, you should ALWAYS check which region you are operating in. This can be found in the top right of your Console window.



If it isn’t labeled “Free Tier Eligible”, you may incur a charge!
On Step 3. Configure Instance Details - Select “S3EC2AccessRole” from the “IAM Role” dropdown.

Expand the Advanced Details section located at the bottom of the page, then, copy/paste the script below into the User Data field. This shell script will install Apache & PHP, start the web service, and deploy a simple web page. Click Next: Add Storage.
‘User data’ is a method for bootstrapping your instance - Any code placed here will be executed the first time an instance is launched.
Copy and Paste the script in the User Data box:
#include https://s3.amazonaws.com/immersionday-labs/bootstrap.sh







If you don’t see the web page (and you’ve waited a sufficient time for the instance to boot), try rebooting the instance via the console. Can you find it??
Great Job! You have deployed a server and launched a web site in a matter of minutes!!
Typically you would delete the EC2 instance once you no longer need it, but we will use it in a later lab.