🕹After completing this lab, you should be able to: Connect to the AWS Cloud9 IDE on an existing EC2 instance Analyze the EC2 instance environment and confirm web server accessibility Install a web application on an EC2 instance that also uses AWS Systems Manager Parameter Store Test the web application Create an AMI Deploy a second copy of the web application to another AWS Region #AWS #ACA #ACF #CloudArchitecting #CloudFoundation
--~~~-- Please watch: “[AWS] Cloud Practitioner Essentials| Lesson 5: Networking and Content Delivery” • [AWS] Cloud Practitioner Essentials| … --~~~-- Join my course and get free access to all Labs, free AWS credit and 50% discount voucher
Content
13.6 -> okay guys so in this video we are going
to look to the challenge lab which is
18.96 -> creating a dynamic website for the cafe the
starting point we are going to do a cloud9
27.68 -> environment it is cloud-based ide where we have
an easy to er to access and that ec2 will be we
37.36 -> will be using it to deploy our application into a
multi-ac deployment with the aid of system manager
44.64 -> with the start of where we
are getting a start code
52.56 -> so the first thing we need to do is
to understand the first challenge
57.52 -> that the cafe staff they want to introduce
an online ordering for the customers and they
62 -> want to enable the cafe to staff to view their
submitted orders they have now a static website
69.68 -> and this is what we did in the previous video but
this is not enough and we need to get it working
76 -> in aws at the dynamic website so the first thing
i'm going to do is to basically go to the first
88 -> task where we need to go to the aws console i have
the idlers console here you could open it again
96.24 -> just to confirm that the session is currently
capturing all the resources in the lab you can
102.72 -> see now i need to experience or to test
that i have an ec2 called aws cloud9
110.8 -> so we need now to basically access the aws
cloud9 you could also access the questions
121.44 -> in the multiple choice questions in this
page as well in task 2 we need to go and
127.44 -> connect to the ide so you could go from
the console and access the cloud nine
135.04 -> and this is basically the instance the cafe
web server that we just saw in the ec2 tab
142.96 -> where's the cloud9 and we open the ide it's
basically a normal ide that we use for building
150.48 -> the cafe so that's cloud9 it has a batch terminal
which is here where we can write code linux
158.56 -> commands will do like ls and so on could also
open files in the file editor here in this screen
166.64 -> and this is the file structure or the folder
to your where we have to browse all our files
173.6 -> in the system few things we need to do in step
10 we need to basically um experience or test
182.64 -> that we have a batch running so we go and we do
this command cut proc slash and this is going to
192.96 -> be the version of cloud9 now we need to run
a few commands in step 11 to install uh the
201.6 -> ide the apache servers let me expand this
a bit so this is sudo http d minus three
213.92 -> so the apache is installed
now we just need to make sure
217.76 -> it is started by doing the command service http
224.48 -> status it is stopped and now we
need to check the mysql is installed
237.04 -> and then we need to check as well the service
246.8 -> php
249.52 -> of mysql
253.12 -> d which is the service running my sequel in linux
and these are all installed so we want to start
261.52 -> them and to start them is going to be activating
the autostart which is check config http d on
277.52 -> and then sudo service httpd we do start
and this is will start the server so you
288.16 -> can see it's giving us ok you could check the
service based on the command sudo or you can
294.48 -> just navigate to the history and this will give
you the previous command that we just taught
302 -> click me in sudo here
305.92 -> and it is running at process 4209 also
we want to do another check configuration
314.4 -> for the my sequel the on which means every
time i restart the ec2 i wanted to start the
322.32 -> instance as well sudo service and this is
going to start my sequel the service start
335.92 -> and it is ready you could also check using the
previous commands if you go with the upper arrow
343.2 -> guides and your keyboard you will be able to and
basically get the previous commands instead of
349.92 -> keep typing in so that's the step 12. now
in step 13 when you want to configure the
356.8 -> institutional sensor that can use the idlers
cloud9 editor to edit the web server files
361.92 -> and we need to put this command which is
basically creating a link file or a shortcut
369.84 -> and then we give a permission to the
ec2 user to access the for www.html
377.68 -> we will create now a symbol file from file
in you and we have this file new here so
387.04 -> we need to create it inside this folder and
this is basically this command created this
392.56 -> shortcut for the wwe or a link file for the
www and inside the html page we need to go and
401.04 -> create in you file so we are going to create a new
file like this and we call this file index html
413.44 -> inside it we will put in it a
dummy html code just a dummy tag
425.52 -> and save
429.84 -> and i think copy it in the wrong place let me
open this guy here double click paste and save
438.8 -> so we need to verify and update the
configuration to make our website
443.52 -> and this is basically done if you go back to
your easy tool you could do this simply by
450 -> going back to the ac tools and check that the
security group in that ec2 is opening port 80
458.64 -> as an inbound rule it seems to be there is a
no inbound rule here so we're going to edit
469.2 -> the security group edit
474.4 -> and we add the http
479.76 -> from anywhere and save now there is
a few tabs here they are going to be
486.24 -> about getting the address of the ac2 which already
we know going back to your ec2 and copy to the ip
497.44 -> of the public ip address and test that you can see
the hello message in the browser so hello from the
505.76 -> cafe web server we are done so our web server here
is ready to be launched now in the new business
513.2 -> requirements we want to install a dynamic website
application on the ec2 instance and this is going
517.92 -> to be the challenge for doing what we are going
to do in task four so we have configured the ec2
526.48 -> instance we have php installed we have my seat
one we have the apache and now we want to create
534.4 -> environment for basically the cafe website so i'm
going to do sudo or cd clone slash environment
543.44 -> and we are going to get the file set up uh for the
php code for the db as you can see here in step 16
555.28 -> and also for the actual cafe let me clear this
you can read and maybe i increase the font a bit
568.56 -> level you get is going to download the file in
the next command we are going to unzip the file
573.92 -> using this command i'm just copying and pasting
from the lab sheet so you can see there is now
578.8 -> a new folder here created for me setup then
we want to go and download the db file which
586.88 -> has the content of our db we basically
unzip it using the tar command
595.6 -> minus that x v f and then w get the actual
cafe website and then we need to and exhibit
610.4 -> so you will see now we have the cafe
we have the db which basically has some
616.96 -> sql for creating the sql data and even
for the cafe and we have the setup
626.64 -> file and the setup of the parameters files as
well you can also see them from the file a browser
635.84 -> now the first thing we need to do is to move
the cafe folder inside the html folder here and
644.8 -> basically we want to get rid from this index.html
um so it's going to be taking a place you can
653.36 -> do this by this command here which is
mv move folder cafe to slash www.html
665.6 -> so you can see now i have the cafe here there
671.2 -> now we need to see that we have inside the
cafe we have a new file called index.php
685.68 -> inside the cafe and this is
the file which is the index.php
690.88 -> we can open it there and this is what we
need to do in step 18. we just want to
697.76 -> observe the application for example in
line 18 we have a get parameters.php
705.84 -> and this is going to be the application
environment parameter from the parameter store
711.36 -> and the server info as well from the parameters
store we also include the aws sdk in line three
720.72 -> in the get parameter from the parameter store
so if you open this you can see we are going to
730 -> use the aws sdk as well now we need to go to the
aws system manager parameter store configuration
738.96 -> file in the application parameter inside
the setup so if you go to the folder setup
747.36 -> and sit at parameter store and you open this file
you'll find this is a script and this is basically
753.52 -> going to suit up the environment for us all we
need to do now is to navigate to this folder
764.8 -> and
767.6 -> let me go to the root directory
sorry and save the environment
778.32 -> so now i am inside the setup i could
see the file i'm looking for which is a
782.4 -> linux script all i need to do
is just to secure this file
786.48 -> and this is will set up the application
parameter value in the parameters
794.08 -> in step 20 now we need to go to the aws
console and we go to the system manager
806.48 -> in the system manager we need to go
to the parameter store from the left
814.72 -> and we can see there is all the parameters that we
need to the cafe for the cafe like a db name a db
822.48 -> password a dp url adp user show server info time
zone currency and so on and in this step here we
835.12 -> want to get the db password and we copy the value
which is r e clone start nine copy and we will
850.88 -> copy it to the clipboard going back to step 22
we want to configure the mysql database to use
859.28 -> the db password so we're going back to the cloud9
ide and we navigate back slash dot book slash db
868.32 -> that's going to exit the setup and take us to the
db folder and then we have a set root thousand
884.48 -> sh
888.8 -> now we need to create the db
put sh and this is will create
896.32 -> the db for us now to connect to mysql you can
use the batch command my sql minus u root ins p
911.2 -> which is minus u the user minus p the password
and now we paste the password that we just copy
917.52 -> from there so you should be able to see now my sql
you could also get now more information like show
926 -> database is and this will show you there is
a cafe db you can use it cafe underscore db
939.2 -> and we need to show tables
948.24 -> and we need to select the
start just to make sure we got
951.44 -> all the data we want for the cafe from product
965.6 -> and you can see we have data in
the table exit my sequence all good
972.88 -> and back now to step 24. we want to update the
time zone configuration in php and this command
980.8 -> will basically just flush something to the php.ini
the initial and we restart the httpd server
997.92 -> so we want now to test that the website
is running so from the public ip of your
1003.68 -> machine just to slash cafe and this should
take us to the main website of the cafe
1015.12 -> and as you can see the only the
banner of the cafe is loading the rest
1020.08 -> it's not loaded yet because we are going to
do and resolve them later on now instead 26
1030 -> we have at this stage so you know that the web
server is working and we know that the mysql
1036.16 -> database is working and containing all the data
1040.24 -> we need to fix now the issue with the cafe
and not fully loading all the content as well
1051.28 -> so to solve this issue we need to go to the iron
1056.8 -> okay and from the i am we need to go to rolls
and we select cafe because it seems to be that
1065.36 -> our ec2 has no access to my sql yet so if you will
open this role you will find there is a permission
1078.8 -> assigned to this
1083.44 -> poll
1086.8 -> to give this role to the ec2
we need to go back to the ec2
1094.24 -> and we select that ec2 and from action
1102.4 -> purity
1106.32 -> we need to look to the cafe roll and save
1111.44 -> now you should be able to refresh the page after
a few seconds and you will be able to see that the
1116.72 -> cafe is fully loaded with everything the issue
was that the cafe or the ac2 has no access to
1127.04 -> for the system manager to get
all the permission it needs
1136 -> now we want to test the cafe website
in step number 27 and we go to the menu
1146.48 -> and we need to i think submit an order so we
want one donut products let me add one here
1160.88 -> and chocolate and then submit an order
1166.32 -> so we have like an order successfully
submit we can go and check the order history
1171.68 -> which means we can't read everything from the
database we want to create a development and
1177.76 -> production website in different address region
and this is the third challenge for today
1184.32 -> so this website here in this ec2 is the
production and now we want to create a new one
1194.72 -> so we are going to go to the ec2 and from
the ec2 we are going to create an ami
1203.36 -> and now the name did they ask us for a
specific name do few things in step 28
1210 -> before we rush to create the mi just one second
we go to step number 28 and we set the hostname
1222.24 -> to cafe
1227.28 -> server
1231.44 -> and then we need to do ssh dash key gen for
generating minus t rs a key minus f slash dot ssh
1249.36 -> slash id rsa so we want now to generate
a new key pair for the ac2 instance and
1258.08 -> that key pair we will be using later on for our
second deployment then we need to cut that file
1270.8 -> and copy it to the authorized key so we want
to give it access to the authorized key and
1279.28 -> we need to select the ec2 that
we have in the instance and we
1283.44 -> create an image we want to call this cafe server
1292.96 -> and when we do finish just
click on create an image
1300.88 -> so this will take a while to create you can check
your progress here from the mi and meanwhile
1306.32 -> you can go and answer the multiple choice
questions that you can see them here in the logo
1316.48 -> once is this is finished we are going to copy the
ami d and we want to create a new cafe instance
1324.24 -> in the region oregon now be careful here because
it asks you to use the instance as a t2 small
1332.64 -> not t2 maker let us wait for this image to be
finished so basically now the image or the ami
1342.8 -> for the cafe server is ready for
us and as you can read in step 36
1349.92 -> this image should be in the region oregon
but the image currently in north virginia
1357.52 -> so what we do we need to copy the mic so once
you select the cafe image go and do copy ami
1365.68 -> select the region you want to copy it to
which is us west and make a note of the ami
1375.6 -> id and copy the ami now this is will take a few
minutes to finish so let me go now to us quest
1388.8 -> you can see now the copying of the ami is
an appending state so i will pause the video
1394.72 -> for two minutes to save time and then come
back to this data okay so the image is ready
1402.4 -> and part of the instruction we want to
launch from this image a new ec2 in the us
1410.24 -> west region of type t2 small now if you don't
select it too small you're going to get an error
1417.92 -> that's going to be in the
lab3pc region 2 in public subnet
1426.16 -> enable ip just in case and then we need to go and
add storage that tag and the tags will be named
1436.08 -> and the name is going to be pod
1442.08 -> cafe server click on security group
1449.44 -> we will call it cafe sg and
this is going to enable port 22.
1459.68 -> and then we need to open port http port 80
1466.56 -> from anywhere review and launch
1470.4 -> now we can proceed without a key pair as
the instruction is specified by the lab
1478.96 -> and we wait for this ec2 to be fully launched
and we check that we can see the public website
1488.72 -> now you will need to create another aws
parameters so we need to do this instead
1498.32 -> 39 so we need to go to the cloud 9 in the original
region in virginia and we go and we open the cafe
1513.36 -> web server setup file creator file in the text
editor and we edit the line and we make line 12
1523.04 -> basically equal to the region
that we are going to use
1533.2 -> so the region is going to be your swiss 2
and then in line 18 we are going to change
1540.96 -> the ip address with the ip address that we have
in the new cafe in the new public dns of the
1547.84 -> instance so we're going to check it now we have a
public dns server and this is going to be the cafe
1561.2 -> excellent so we need to go back to the this line
and we put the new ip address of the new cell
1571.68 -> and we save the file
1577.52 -> and we can run it from here just quickly run it
1581.52 -> to setup the new file now go back to your
a new production server until for once this
1592.64 -> script is finished and refresh
1600.8 -> sometimes this is take time so let
me go to the main website first
1608.88 -> and then i need to go to the slash cafe
site and there is one thing i missed
1616.48 -> and you know what i mean it is giving this easy
to the cafe roll as well so from action security
1627.12 -> modify and cafe roll and as you can see this is
a global now you can see i have the order history
1636.72 -> which means i'm accessing the mysql
database as well and that's pretty
1642.64 -> much what we need to do for this lab thank you
for seeing this video and see you in the next