Module 4 Challenge
Module 4 Challenge
In this task, you will note details about an existing EC2 instance that was created
for you in the AWS account.
5. In the search box next to Services, search for and select EC2, to go to the
EC2 console. Then choose Instances.
By using the AWS Cloud9 environment, you don't need to download a key pair
and connect to the EC2 instance by using PuTTY or similar Secure Shell (SSH)
software. By using AWS Cloud9, you also don't need to use command line text-
editing tools (like vi or nano) to edit files on the Linux instance.
8. In the search box next to Services, search for and select Cloud9, to go to
the AWS Cloud9 console.
9. Choose Open.
You are now connected to the AWS Cloud9 IDE that is running on the EC2
instance that you observed earlier.
cat /proc/version
11.Observe the web server, database, and PHP details and server state.
sudo httpd -v
service httpd status
mysql --version
service mysqld status
php --version
The output should show the versions of the web server and the database,
and also show that they are not currently running.
12.Start the web server and the database, and also set them to start
automatically after any future EC2 instance restart.
13.Configure the EC2 instance so that you can use the AWS Cloud9 editor to
edit web server files.
Notice that the AWS Cloud9 file browser currently does not display the
Apache web server default web directory.
ln -s /var/www/ /home/ec2-user/environment
sudo chown ec2-user:ec2-user /var/www/html
The first command you ran created a symlink from the default AWS
Cloud9 editor workspace to the /var/www directory that contains your web
server files.
o Choose File > Save, and save the file in the html directory as
index.html.
In this step, you will need to verify and update the configurations that
make the webpages (which are hosted on the web server) accessible from
the internet.
Notice how the file browser now shows the three .tar.gz files that you
downloaded.
You also extracted these archive files, which created the cafe , db , and setup
directories in your work environment.
17.Copy the café files over to the web server document root.
mv cafe /var/www/html/
o Notice that this file has HTML code in it, but it also contains sections
that are enclosed in elements. These elements make calls to other
systems and resources.
o For example, on line 18, you see that the PHP code references a file
named getAppParameters.php.
19.In the AWS Systems Manager Parameter Store, configure the application
parameters.
cd setup
./set-app-parameters.sh
The shell script that you just ran issued AWS Command Line Interface
(AWS CLI) commands. These commands added the parameters that the
application will use to the Parameter Store.
20.In the AWS Management Console, from the Services menu, choose
Systems Manager.
Back in the AWS Cloud9 bash terminal, run the following commands:
cd ../db/
./set-root-password.sh
./create-db.sh
mysql -u root -p
When you are prompted for the database password, paste the
dbPassword parameter value that you copied.
You should now see a mysql> prompt, which indicates that you are now
connected to the MySQL database that runs on this EC2 instance.
To observe the contents of the database (specifically, the tables that support the
café web application), enter the following commands:
show databases;
use cafe_db;
show tables;
select * from product;
exit;
The first command that you ran configured the time zone in the PHP
software.
The second command that you ran restarted the web server so that the
web server notices the configuration update.
25.Test whether the café website is working and can be accessed from the
internet.
You will see that only the title banner of the website loads. The rest of the
webpage is not loading correctly.
26.Resolve an issue with the website.
In this step, you will need to figure out how to make the café website
function correctly.
o The test page at http://<public-ip>/ loads, so you know that the web
server works, and is accessible from the internet
o You also know that the MySQL database is running, and contains
tables and data to support the application
Note: you may need to scroll down to find the Submit Order
button.
o Return to the menu page and place another order, then go to the
Order History page to see the order details for all the orders that
you placed.
You will continue to take on the role of Sofía for this task. Before you create an
AMI out of this instance, you should create a new key pair, which might be
important to have later in this lab.
28.Set a static internal hostname and create a new key pair on the EC2
instance.
For the two times that you are prompted for a passphrase, press the
ENTER key.
To make the new key available to the SSH utilities, in the Bash terminal,
run the following command:
29.In the AWS Management Console, browse to the EC2 service area and
select the instance.
Tip: Leave the Create Image dialog open in the browser tab while you
answer some questions about AMIs.
In this step, your objective is to create a new EC2 instance from the AMI
that you just captured. However, you must create the new instance in the
Oregon (us-west-2) AWS Region.
36.Create the new café instance from your AMI. The new instance that you
create must match the following criteria.
o Region: Oregon
o Instance Size: t2.small
o Network: Lab VPC Region 2 , Public Subnet
o IAM Role: CafeRole
o Tag:
Key: Name
Value: ProdCafeServer
o Security Group:
Create a new one named cafeSG, with TCP port 22 open to
anywhere
Set TCP port 80 so that it's open to anywhere as well
o Proceed without a key pair (the key pair that you created earlier
in this lab should work to connect to it, if necessary)
37.Wait for the new instance to have a Public DNS value assigned to it, even if
the status of the instance is still not Available.
region="us-west-2"
publicDNS="<public-dns-of-ProdCafeServer-instance>"
40.Note: The line should still contain the quotation marks, but it should not
contain the angle brackets (< >).
This example shows what line 12 should look like and how line 18 should be formatted. However, the value of
your public DNS will be different.
Note: By changing the AWS Region details and running this script again, you
created the same parameters that you created earlier in the us-east-1 Region of
the AWS Systems Manager Parameter Store. However, this time, you created
these parameters in the Oregon Region.
The Hello from the cafe web server! message should display.
The full Menu page should load, and the order-placing functionality should
work.
The grading script can provide additional tips for parts of the lab that you
didn't complete successfully. You can submit your work as many times as
you like—only the score that you achieve on the last submission will be
retained.
Also, if you want to connect to the new EC2 instance in Oregon (us-west-2)
to do some troubleshooting, run this command from the AWS Cloud9 IDE
in us-east-1: