Lab 10 - Elastic Beanstalk
Overview
This week's lab will cover the following:
- Creating a new RDS
- Modifying the wordpress source code in preparation for deployment using Elastic Beanstalk
- Creating a public Simple Storage Service (S3) bucket
- Uploading your wordpress source code to a Simple Storage Service (S3) bucket
- Configuring Elastic Beanstalk
- Installing and configuring Wordpress
When you have installed Wordpress previously, you simply uploaded the source code and the first time you load the webpage, provided the database connector information. However, Elastic Beanstalk applications are meant to be disposable.
Normally, when you add that database connector info, it is saved in a file called wp-config.php on the webserver VM. This is fine for a traditional setup. However, 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 reload from the source zip file and the original, empty connector file. If you did this the traditional way, 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 directly. That way, every time the application restarts and reloads from the source code zip, it'll then read our saved connector information from AWS itself. 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 data will remain intact.
Investigation 1: Creating a RDS instance
Start your session in the Learner Lab by clicking on the Start Lab button. Once the red dot has turned green, click on it to enter the Learner Lab and access the AWS Console interface. You are going to create a new RDS instance.
From the Console Home navigate to Database > RDS. See the following screenshot for reference.

Click Create database (part way down the screen). Use the following options.
- Standard create
- Engine type: MariaDB
- Engine Version: MariaDB 11.4.4 (or current latest version available)
- Templates: Dev/Test
- DB instance identifier: wordpress-elasticbeanstalk
- Master username: admin
- Credentials management: Self Managed
- Auto generate a password: Checked
- DB instance class: db.t3.micro
- Allocated storage: 5 GiB
- Enable storage autoscaling: Unchecked
- Virtual private cloud (VPC): Wordpress VPC
- DB subnet group: Create new DB Subnet Group (if you're redoing your database creation, there will already be an entry here. Make sure you're using the Wordpress VPC in the setting above!)
- Public access: No
- VPC security group: Choose existing
- Existing VPC security groups:
- Remove default VPC
- Add Wordpress Database SG (look to see that it's there below the dropdown after you select it)
- Availability Zone: us-east-1a
- Monitoring > Enable Enhanced monitoring: Unchecked
- Below the Monitoring section, Additional configuration > Initial database name: wordpress (Write the database name down! You will need this later.)
- Enable automated backups: Unchecked
- Enable encryption: Unchecked
Click Create database.
This will take a few minutes to create. Once the database has finished creating, click on the View connection details button by the green success message at the top of the page. This gives you your database password.
Store the following connection information about your RDS instance in your lab logbook or a saved document. You'll need it later:
- Endpoint
- Initial database name
- Master username
- Master password
Connecting to your database from www
Login to your www instance, and issue the following command to connect to your database. Be sure to substitute the credentials you wrote down earlier.
mysql -u admin -h **endpoint** -p
Enter your Master password when prompted. You should see the following screen indicating a successful connection.

Issue the following command to display the databases.
show databases;
Disconnect from the database.
quit;
Investigation 2: Wordpress Source Code Modification
Download and Unzip - Local Computer
- On your local computer, download the current Wordpress source code from here: https://wordpress.org/latest.zip
- Unzip the file. You should end up with a wordpress directory. (Do not delete the original .zip file)
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
- Open wp-config.php in a text editor. You will want something that supports syntax highlighting., such as the default (graphical) text editor in Ubuntu, or something fancier like Visual Studio Code.
Adding Database Connector Info as Environment Variables
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_PASSWORD', getenv('DB_PASSWORD'));
- 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 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_KEY', getenv('LOGGED_IN_KEY'));
- define('NONCE_KEY', getenv('NONCE_KEY'));
- define('AUTH_SALT', getenv('AUTH_SALT'));
- define('SECURE_AUTH_SALT', getenv('SECURE_AUTH_SALT'));
- define('LOGGED_IN_SALT', getenv('LOGGED_IN_SALT'));
- define('NONCE_SALT', getenv('NONCE_SALT'));
Figure 1: Adding database connector information to wp-config.php.
Save the file.
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.7.2-modded.zip (Use whatever version the source zip file has.)
Investigation 3: Creating an Simple Storage Service (S3) Bucket
In this investigation, you are going to create an S3 bucket and upload your wordpress configuration files.
From the Console Home navigate to Storage > S3.
- Navigate to Amazon S3
- Click Create bucket
General configuration
- General purpose: selected
- Bucket name: senecausername-wordpress
Object Ownership
- ACLs disabled (recommended): selected
Block Public Access settings for this bucket
- Block all public access: unchecked
- I acknowledge that the current settings might result in this bucket and the objects within becoming public: checked
Bucket versioning
- Enable
Default encryption
- Accept the defaults
Bucket key
- Enable
Scroll down and click Create bucket
Once your bucket has created, click on your bucket's name (ie: jmcarman-wordpress).
- Click Upload
- Click Add files
- Select your wordpress-modded zip file
Make note of the Destination location: ie: s3://jmcarman-wordpress. You will need this for the next investigation.
- Click Upload
Investigation 4: Elastic Beanstalk
Navigate to Compute > Elastic Beanstalk. See the following screenshot for reference.

Click Create application, and use the following settings:
Environment Tier
Select: Web server environment
Main settings
- Application name: wordpress
- Environment name: Wordpress-env
- Platform: PHP
- Platform branch: PHP 8.4 (or current latest)
- Application code: Upload your code
- Version label: wordpress-6.7.2 (Use the version from your zip filename)
- Local file: wordpress-6.7.2-modded.zip (From your local computer)
- Presets: Single instance (free tier eligible)
Click next
Configure Service Access
Select: Use an existing service role
- Service role: LabRole
- EC2 key pair: vockey
- IAM instance profile: LabInstanceProfile
Click next
Set up networking, database and tags
- VPC: Wordpress VPC
Instance Settings
- Public IP address: Checked
- Instance subnets: Public Subnet 1, Public Subnet 2 (both checked)
Click next
Database settings
- Database subnets: Private Subnet 1, Private Subnet 2 (both checked)
Click Enable database
- Username: admin
- Password: The password you copied and wrote down earlier
Click next
Configure instance traffic and scaling
- EC2 Security Groups: Wordpress Website SG & Wordpress Database SG (both checked)
- Leave the rest default
Click next
Configure updates, monitoring and logging
Monitoring
- System: Basic
Managed platform updates
- Managed updates: Unchecked
Email notifications
- Email notification: Add your Seneca email
Platform Software
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)
Container Options
- Proxy server: Apache
- Document root: /wordpress
- Click Add environment property and add the following Environment properties
- DB_HOST: your RDS database URL
- DB_NAME: wordpress
- DB_USER: admin
- DB_PASSWORD: your auto-generated database password
- AUTH_KEY: (use gathered info from salt page)
- SECURE_AUTH_KEY: (use gathered info from salt page)
- LOGGED_IN_KEY: (use gathered info from salt page)
- NONCE_KEY: (use gathered info from salt page)
- AUTH_SALT: (use gathered info from salt page)
- SECURE_AUTH_SALT: (use gathered info from salt page)
- LOGGED_IN_SALT: (use gathered info from salt page)
- NONCE_SALT: (use gathered info from salt page)
Hint: None of these values should have single quotes in them. (i.e. ')
Figure 2: Adding database connector information, auth keys and salts to your Elastic Beanstalk application as static Environment Variables.
Click next.
Review options
Review all settings and ensure they match the instructions above. Once you hit Submit, the application will take several minutes to create.
Create the application.
click Submit when ready.
While you wait for the creation to complete, check your e-mail to confirm your notification subscription.
Investigation 5: Accessing Wordpress
Open the URL presented in the Wordpress EBS instance and begin the site setup.
Site Information
Set the following site information:
- Site Title: Your name's blog
- Username: yourSenecaUsername
- Password: Choose a strong password (do not reuse the DB password!)
- Your Email: yourSenecaEmailAddress
- Search engine visibility: Unchecked
If you get a message indicating a failure to connect, make sure you zipped the wordpress folder and it's contents only. You can rezip the file and click Upload and deploy if necessary.
Blog Post:
Add a blog post detailing the following:
- What did you think of this lab?
- What was the most difficult part for you?
- What was the easiest part for you?
- How did you find this course?
Temporarily shutting down your database:
- Navigate to Aurora and RDS > Databses.
- Select the radio button beside wordpress-db
- Click on Actions > Stop temporarily
This will shutdown your database for 7 days and pause billing. You may need to repeat this.
Note: You will need to have your database running to access your Wordpress site.
Lab 10 Sign-Off (Show Instructor)
Show your professor the following:
- Your blog post.
Exploration Questions
- What is Elastic Beanstalk
- How is this lab similar to the wordpress install in Lab 9 and Assignment 1? How is it different?