The WPCloudDeploy WordPress fault-tolerant load-balancing scripts are designed exclusively for the AWS service. It is a combination of BASH scripts and a CLOUDFORMATION template. It does NOT require the use of Terraform!
The scripts does the following straight out of the box:
These scripts do NOT handle the following:
Additionally, these scripts do NOT use the AUTO SCALING GROUPS feature of AWS EC2. You can, of course, add it to the scripts but it’s not there out of the box.
Please ensure that these items are in place before proceeding with installing and using the scripts.
Copy all files (including all subfolders) to your Linux system (or, if on Windows, WSL). For the purposes of this document, we’ll assume the files are located in a folder called cfscripts. (If you’re wondering about the folder name, ‘cf’ is short for ‘CloudFormation’ – so the folder name just means ‘cloudformation scripts’.)
Make sure you have the dos2unix utility installed. if not, install it:
sudo apt-get dos2unix -y
If you get an error during installation, make sure you update your repos first:
sudo apt-get update -y
Then retry the sudo apt-get dos2unix -y command.
Once it’s installed, run the following inside the cfscripts folder – this will make sure the .sh scripts have the correct line endings and also make them directly executable.
sudo dos2unix *.sh && dos2unix install/*.sh && dos2unix scripts/*.sh && chmod +x *.sh && chmod +x scripts/*.sh && chmod +x install/*.sh
Now that the scripts have been prepared, all you have to do is run the following command inside the cfscripts folder.
sudo ./install.sh
You will be sequentially prompted for the following information:
You will then see the following message: Waiting for stack to be created.
Note: the stack name will be the domain name stripped of all periods, dashes and other non-alpha-numeric chars.
You MUST wait at your screen for at least 5 minutes until you see the prompt to create the CNAME record. If you miss that prompt and do not setup the CNAME record within the allotted time, you will not be able access the stack after it’s been created. If the domain has been used at least once before, you will not see this prompt.
Here is what the prompt looks like:
It should not take more than 5 minutes for this prompt to appear.
If you do not see it, then it means you’ve probably run the script at least once with the same domain name and so the SSL certificates already exist. It’s probably safe to walk away – it can take 30 mins or more for CloudFormation to do its thing.
If your stack is new, SSH keys for the new instances will be downloaded into the /.keys folder. The name of the file will be <stackname>.pem. i.e.: if your domain name is my.domain.com, the pem file will be /.keys/mydomaincom.pem
You will see a notation of this file and location just after you have answered all the prompts. But if the domain has been run once before, it is possible the key already exists in which case you will NOT see this notation again!
To add new servers to the cluster to increase capacity, run the ADD INSTANCE script inside the cfscripts folder.
sudo ./add_instance.sh
You will be prompted for the following:
When the process is complete, you should see the additional server instance in your account and the CloudFormation instance should be updated to include references to the new server. If the cleanup script is run, the new servers should be destroyed along with the others.
You can remove servers from the cluster by running the REMOVE INSTANCE script inside the cfscripts folder.
sudo ./remove_instance.sh
You will then be asked to choose from the list of instances.
When the process is complete, you should see that the server instance has been removed from your account and the CloudFormation instance should be updated to remove any references to the server.
To delete the cluster, run the CLEANUP script inside the cfscripts folder.
sudo ./cleanup.sh
You will be asked for the domain name after which ALL resources associated with the domain will be destroyed INCLUDING THE DATABASE and EFS volumes. Anything that was created outside of the scripts and moved to different buckets (eg: snapshots, backups etc.) will likely be retained.
Deleting the cluster can take 15 minutes or more. When it’s complete, you should check your account to make sure all major resources have been removed – you don’t want any surprise charges!