Provision an Ubuntu WordPress server using Terraform
The below Terraform files will create a new IONOS VDC and server instance, as part of the provisioning process we are also base64 encoding the cloud-init-wp-install.yaml file and setting that for our cloud-init or user_data which will run on first boot only.
Prerequisites:
- You will need terraform installed Hashicorp how to install Terraform
- You will need to set your IONOS username and password locally as environment variables (see export in deploy to the right) if you do not set these variables, you will be prompted for them when you run the terraform build process.
- You will need to create a directory and have an SSH key that you would like to use, this key path will need to be entered on line 38
- You will need to clone the repository, or copy the contents below and create the 3 files locally
- wp-terraform.tf = main terraform file
- variables.tf = sets terraform variables and sensitivity for IONOS credential variables
- cloud-init-wp-install.yaml = cloud init yaml configuration that configures initial boot to: – Install apache2 – git clone https://github.com/ionoslabs/wp-install to /tmp/wp-install – change wp-install.sh script to executable – run the wp-install script
wp-terraform.tf
Copy to Clipboard
variables.tf
Copy to Clipboard
cloud-init-wp-install.yaml
Copy to Clipboard
Download
Copy to Clipboard
Deploy
Copy to Clipboard
Cleanup
Copy to Clipboard