Open main menu

CDOT Wiki β

Changes

OPS705 Assignment 2

2,638 bytes added, 13:47, 13 April 2023
Task 2: Database
In this assignment, you will install a WordPress blog in AWS using Elastic Beanstalk and RDS. '''You will construct this assignment in our ''AWS Academy Learner Lab'' classroom.'''The purpose of this assignment is to demonstrate your knowledge of Amazon Web Services gathered from our lectures and assigned labs and to show you how you can leverage PaaS to build a web application easily.
Unlike labs, assignments have minimal instructions. You are given specifications on what the assignment needs, and you must rely on your previous work in the course. If the assignment doesn't have the command you need, you can find it in your labs. As with Assignment 1, don't be afraid to do a little research!
# Public access: '''No'''
# VPC security group: Choose existing
# Existing VPC security groups: Remove default VPC, add '''Wordpress Database VPCSG''' (look to see that it's there below the dropdown after you select it)
# Availability Zone: '''us-east-1a'''
# Monitoring > Enable Enhanced monitoring: '''Unchecked'''
= Task 3: Wordpress Source Code Modification =
'''Explanation:''' From your work with Wordpress in Assignment 1, you know you can simply upload the source code and the first time you load the webpage, you'll be asked for database connector information. However, Elastic Beanstalk applications are meant to be disposable. In A1, when you were adding that database connector info, it was being saved in a file called ''wp-config.php'' on the webserver VM. This is fine for that kind of setup, but in Elastic Beanstalk, changes made to static HTML or PHP ''are not saved if the Beanstalk application restarts'', which it will do often. Whenever the application restarts, it will load from the source zip file. If you did as in A1, you'd have to constantly re-enter your DB connector info every time you started up your Learner Lab environment.
 
We ''could'' add the DB connector info to '''wp-config.php''' manually before we upload the source code, but there's a much better way. We use environment variables to allow us to put all the info in the Elastic Beanstalk application wizard. That way, every time the application restarts and reloads from the source code zip, it'll then read our connector information from AWS. Read below for details and steps.
 
'''Note:''' All other information, like the Wordpress website name, users, theme settings, blog posts, etc., are saved in the actual database you created in RDS. This database does not get reset when the Elastic Beanstalk application restarts, so your actual blog will remain intact.
== Download and Unzip - Local Computer ==
== Modify Wordpress Configuration File ==
 
=== Duplicate and Open Configuration File ===
# In the local ''wordpress'' folder, find a file called: '''wp-config-sample.php'''
# Duplicate this file, and call it: '''wp-config.php'''
=== Adding Database Connector Info as Environment Variables ===
[[Image:Ops705_a2_wp-config-example.png|thumb|right|450px|Figure 1: Adding database connector information to ''wp-config.php''.]]In this file (wp-config.php), you will be adding database connector information as '''environment variables''', not the actual connector information. (We'll add that information later.) Find the following lines and add the bolded values:
# define('DB_NAME', '''getenv('DB_NAME'))''';
# define('DB_USER', '''getenv('DB_USER'))''';
# define('DB_HOST', '''getenv('DB_HOST'))''';
=== Adding Authentication Unique Keys and Salts as Environment Variables ===In the same file (wp-config.php), you'll be adding the authentication keys and salts from the previous section as '''environment variables'''. Find the following lines and add the bolded values:
# define('AUTH_KEY', '''getenv('AUTH_KEY'))''';
# define('SECURE_AUTH_KEY', '''getenv('SECURE_AUTH_KEY'))''';
# define('LOGGED_IN_SALT', '''getenv('LOGGED_IN_SALT'))''';
# define('NONCE_SALT', '''getenv('NONCE_SALT'))''';
 
== Zip As New File and Rename - Local Computer ==
# Find the '''wordpress''' folder on your local computer.
# Zip the ''entire wordpress directory'', not just the files inside. (Use the zip compression protocol. Don't use something else like .rar.)
# Rename your new zip file: '''wordpress-6.2-modded.zip''' (Use whatever version the source zip file has.)
= Task 4: Elastic Beanstalk =
== Main settings ==
# Application name: '''wordpress'''
# Environment name: '''Wordpress-env'''# Domain: ''' ''yourSenecaUsername''-assignment2''' (Click on the ''Check availability'' button to verify the URL is free.)
# Platform: '''PHP'''
# Platform branch: '''PHP 8.1''' (or current latest)
# Application code: '''Upload your code'''
# Choose file: '''Downloaded wordpress source code -6.2-modded.zip file''' (You can download the wordpress source code here: https://wordpress.org/latest.zipFrom your local computer)# Version label: ''wordpress-versionnumber'' (Example: wordpress-6.1.1)2'''
== Configure more options ==
=== Software ===
[[Image:Ops705_a2_beanstalk-environment-variables-example.png|thumb|right|650px|Figure 2: Adding database connector information, auth keys and salts to your Elastic Beanstalk application as static Environment Variables.]]
Before beginning this section, you will need two things:
# Your database connector information (you saved this, right?)
# Randomly generated auth keys and salts from here: https://api.wordpress.org/secret-key/1.1/salt/ (it's a good idea to save these in a text file, too)
 
Settings:
# Document root: '''/wordpress'''
# Environment properties
## DB_USER: '''admin'''
## DB_PASSWORD: ''your auto-generated database password''
## AUTH_KEY: ''(use gathered info from previous stepsalt page)''## SECURE_AUTH_KEY: ''(use gathered info from previous stepsalt page)''## LOGGED_IN_KEY: ''(use gathered info from previous stepsalt page)''## NONCE_KEY: ''(use gathered info from previous stepsalt page)''## AUTH_SALT: ''(use gathered info from previous stepsalt page)''## SECURE_AUTH_SALT: ''(use gathered info from previous stepsalt page)''## LOGGED_IN_SALT: ''(use gathered info from previous stepsalt page)''## NONCE_SALT: ''(use gathered info from previous stepsalt page)''#* ''(Hint: None of these values should have single quotes in them. i.e. ')
=== Security ===
# EC2 Security Groups: '''Wordpress Website SG''' (both checked)
'''Create the application.'''
While you wait for the creation to complete, check your e-mail to confirm your notification subscription.
# A single screenshot showing your active and complete Wordpress blog.
Once submitted, you can leave your resources Elastic Beanstalk application running, but '''shutdown your Learner Lab environment'''.
[[Category:OPS705]]
[[Category:OPS705 Assignment]]
[[Category:Digital Classroom]]