Introduction to devops

An introduction to devops by a seasoned dba.

Here I will attempt to guide readers through the many pitfalls I have encountered over the years trying to learn and understand compuer systems and more specifically the vagaries of Devops.

One of the most consistent issues I have experienced in so much of the  documentation, whether in a Chef recipe or a Git repository, is the assumption that the reader already knows the answers to half of what they are asking.

I, like most people, don’t know everything and it is so frustrating to be trying to learn how to install and use one product when you encounter simple statements such as install the database software on the os environment and then find that this prerequisite won’t install or work because the latest version of the OS you are using doesn’t automaticaly include the software needed or the author just says install libx9876hhgPAS or whatever without providing some indication of where that software might be.

In this rapidly changing world I do understand how hard it is to include everything in the instructions but I do believe the level of documentation in the public realm needs to improve.

I do know I’m not going to be presenting perfect documentation but I will attempt to document every step and show where everything comes from.

I’m a little late putting my experiences onto the web and in Git but over the next few months, time permitting, I hope to rewrite, check and then add the documentation I have gathered over the years.

The following pages will predominantly center on AWS configurations only because it provides the longest available free tier.

WP + Elastic Beanstalk

Aurora Serverless Database

Create an RDS Amazon Aurora Serverless database

S3 Bucket

Now we create an S3 bucket where wordpress will store all uploaded files, e.g. images, photos etc

Select Next until we hot the permissions popup

Select Next and then Create

IAM policy and user

Policy Creation

Which produc es the following json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:PutBucketAcl",
"s3:ListBucket",
"s3:DeleteObject",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::wpisitdevopsfiles",
"arn:aws:s3:::wpisitdevopsfiles/*"
]
}
]
}

Add IAM user

Once created you will be presented with the access key and secret access key, save these as they will be required later.

Prepare WordPress

On your laptop/PC get the wordpress site up and running locally; I use wordpress in XAMPP.

Add the following plugins to wordpress

Amend or create wp-config

IF this is an existing website then save a copy of wp-config.php before editing.

Modify the wp-config.php file to contain the following lines; the variables will be defined by the elastic beanstalk configuration file.

 
// AWS configuration for WP OffloadS3.
define('DBI_AWS_ACCESS_KEY_ID',     $_SERVER['AWS_ACCESS_KEY_ID']);
define('DBI_AWS_SECRET_ACCESS_KEY', $_SERVER['AWS_SECRET_ACCESS_KEY']);
 
// MySQL configuration.
define('DB_NAME',     $_SERVER['RDS_DB_NAME']);
define('DB_USER',     $_SERVER['RDS_USERNAME']);
define('DB_PASSWORD', $_SERVER['RDS_PASSWORD']);
define('DB_HOST', $_SERVER['RDS_HOSTNAME'] . ':' . $_SERVER['RDS_PORT']);
define('DB_CHARSET',  'utf8');
define('DB_COLLATE',  '');
 
// Authentication keys and salts.
define('AUTH_KEY',         $_SERVER['WP_AUTH_KEY']);
define('SECURE_AUTH_KEY',  $_SERVER['WP_SECURE_AUTH_KEY']);
define('LOGGED_IN_KEY',    $_SERVER['WP_LOGGED_IN_KEY']);
define('NONCE_KEY',        $_SERVER['WP_NONCE_KEY']);
define('AUTH_SALT',        $_SERVER['WP_AUTH_SALT']);
define('SECURE_AUTH_SALT', $_SERVER['WP_SECURE_AUTH_SALT'])
define('LOGGED_IN_SALT',   $_SERVER['WP_LOGGED_IN_SALT']);
define('NONCE_SALT',       $_SERVER['WP_NONCE_SALT']);
 
// Other WordPress defaults.$table_prefix = 'wp_';
define('WP_DEBUG', false);
if (!defined('ABSPATH'))
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');

Elastic Beanstalk configuration files

Create a new folder wordpress/.ebextensions.  
Create a new file wordpress/.ebextensions/env.config with the following contents:

option_settings:
aws:elasticbeanstalk:application:environment:
AWS_ACCESS_KEY_ID: 'Your Value'
AWS_SECRET_ACCESS_KEY: 'Your Value'
WP_AUTH_KEY: 'Your Value'
WP_SECURE_AUTH_KEY: 'Your Value'
WP_LOGGED_IN_KEY: 'Your Value'
WP_NONCE_KEY: 'Your Value'
WP_AUTH_SALT: 'Your Value'
WP_SECURE_AUTH_SALT: 'Your Value'
WP_LOGGED_IN_SALT: 'Your Value'
WP_NONCE_SALT: 'Your Value'

RDS_DB_NAME: 'Your Value'
RDS_HOSTNAME: 'Your Value
RDS_PORT: '3306'
RDS_USERNAME: 'Your Value'
RDS_PASSWORD: 'Your Value'

The WP_ keys will be the values from the original wp_config.php file.

The AWS_ and RDS_ values are those used/provided when you created the user and the database.

Upload WordPress

Create a zip bundle of the wordpress files created from inside the wordpress top level directory i.e. do this from inside the directory and do not include the actual directory file itself.

If you are migrating a wordpress site

This section should be followed if you are migrating a wordpress site rather than creating a new one. 
We will need to import the database into AWS.
Run a cmd window as the Administrator and enter:

mysqldump -u localuser --databases world --single-transaction --compress --order-by-primary -plocalpassword | mysql -u rdsuser --port=3306 --host=myinstance.123456789012.us-east-1.rds.amazonaws.com -prdspassword