There are various components within the application that need some final configuration. The basics, such as the VPC, the Application Load Balancer, the Auto-Scaling Group and resultant EC2 images, are all good to go, but some configuration is necessary on the Django application framework that is hosting the application. This needs to be done by connecting into the instance using SSH.
There are many ways to connect to a remote machine using SSH. Feel free to follow the instructions from the prerequisites. This Lab Guide will continue with using SSH at the command line on an Apple Mac computer - your own method for establishing a connection may be different, but once connected the instructions are the same regardless of your platform combination.
In order to connect you need to have your downloaded key-pair from earlier in an accessible location. It also must not be publicly readable, so if you are on a Mac or Linux system you can fix this with the following command, remembering to replace myLabKey.pem with your key name!
$ chmod 400 myLabKey.pem
$ ssh -i myLabKey.pem ec2-user@3.87.13.157
The authenticity of host '3.87.13.157 (3.87.13.157)' can't be established.
ECDSA key fingerprint is SHA256:hFLzWhKWXwSevk14ulMwyLJqM7LN7j3Yt5w7NcnNwow.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '3.87.13.157' (ECDSA) to the list of known hosts.
Last login: Sun May 5 20:51:33 2019 from 72-21-198-64.amazon.com
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-10-192-11-223 ~]$
Navigate to the root of the Django project, and configure the single-line run script to use the private IP address of the EC2 instance. This is on the previous EC2 details screen just underneath the Public IP - you will need this again, so keep it handy. Simply replace the IP address with yours, keeping the trailing :8000 - my server’s private IP is 10.192.11.223.
$ cd personalize-video-recs/videorecs/
$ nano runmyserver
--- {editor screen} ---
python manage.py runserver 10.192.11.223:8000
$ nano videorecs/settings.py
--- {ALLOWED_HOSTS line - server private IP and ALB DNS} ---
ALLOWED_HOSTS = ['10.192.11.151', 'TestS-Appli-ADS60FMCKPMG-1862985075.us-east-1.elb.amazonaws.com']
--- {DATABASES HOSTS line - RDS DNS} ---
'HOST': 'summitpersonalizelab.c0azewoaia5d.us-east-1.rds.amazonaws.com',
Finally, the RDS database is postgres, and we have included the pgcli tool with this deployment. If you wish to use it then you need to edit the startup script for the utility to point to the RDS DNS entry. You also need to know the password, which you may have noticed in the settings.py file, and it’s recPassw0rd
$ nano pgcli
--- {editor screen} ---
/home/ec2-user/.local/bin/pgcli -h summitpersonalizelab.c0azewoaia5d.us-east-1.rds.amazonaws.com -u vidrecdemo -d videorec
$ ./runmyserver
System check identified no issues (0 silenced).
May 06, 2019 - 14:53:03
Django version 1.11.18, using settings 'videorecs.settings'
Starting development server at http://10.192.11.223:8000/
Quit the server with CONTROL-C.
[06/May/2019 14:53:14] "GET /recommend/ HTTP/1.1" 200 2893
[06/May/2019 14:53:32] "GET /recommend/ HTTP/1.1" 200 2893
[06/May/2019 14:53:44] "GET /recommend/ HTTP/1.1" 200 2893
The URL of the server is your ALB followed by the ‘/recommend/’ path, although there is also an ‘/admin/’ path that we’ll use later. For now connect to your server - in my example the server can be found at http://TestS-Appli-ADS60FMCKPMG-1862985075.us-east-1.elb.amazonaws.com/recommend
You should see the following screen in your browser - no Model Precision Metrics are available, as we haven’t added any models yet to the application. You can also see that documentation for this is present, but be aware that it may not be 100% up to date with coding changes on the demo.
If you hit Select Random User then you’ll be taken to the main Recommendation screen, which starts by showing you a random user’s top-25 movie review titles. However, you’ll see on the Model dropdown on the left that there are no models available, and if you change the Personalize Mode to either Personal Ranking or Similar Items then it’s the same story - you can see the movie reviews, and most-popular titles in a genre, but no recommendations. We need to get the solutions and campaigns built in the notebook, then you can come back and plug in the models.
At this point your application server doesn’t actually have any credentials to call the APIs - up until this point we haven’t had to call any, but we soon will. At the beginning of this Lab you were asked to copy a block of credentials from the Console Login screen - please retrieve these, and in your SSH session window hit CTRL-C to stop the web server, and paste them in, which will look something like the following. Don’t forget to press [RETURN] after the AWS_DEFAULT_REGION line in case it didn’t copy
$ export AWS_ACCESS_KEY_ID=******
$ export AWS_SECRET_ACCESS_KEY=******
$ export AWS_SESSION_TOKEN=************************************
$ export AWS_DEFAULT_REGION=us-east-1
At this point we require the solution that is being built in the notebook to complete - until that time we cannot move forward, so you may wish to get some refreshments if you are still waiting for that to complete.