Let's briefly review how to set up Terraform — leveraging Infrastructure as Code (IaC) — on the hosting platform run by Liquid Web. For starters, as one example, deploying WordPress on Terraform using the Liquid Web command line interface (CLI), is done in a manner similar to using any other CLI.
Let’s see how we can set up Terraform on Liquid Web servers using the LW CLI to make use of the robust Liquid Web Application Programming Interface (LW API v2). This Terraform setup would then be used to establish other cloud-based web applications — such as WordPress — on our hosting service.
What is Terraform?
Terraform is a tool targeted at a Infrastructure as Code (IaC) approach to managing asset inventory. It offers a declarative language to create configurations describing infrastructure. Given the configurations, you can rapidly create, remove, and recreate infrastructure. Since the configurations are plaintext, it allows easy versioning of the infrastructure state with Version Control Software (VCS) as has been done with Liquid Web on GitHub.
Background Terms for Working with Terraform
Some helpful terminology to know for this effort include the following
- Version Control Software (VCS) — like git, a tool that lets you track files over time and compare differences (of note, most developers put their source code in VCS, which has many benefits).
- Infrastructure as Code (IaC) — managing servers via config files, often which you can commit to a repository.
- Declarative Syntax / Language — describing what an system should be.
- Asset Inventory — what assets you have — where VPSs are an asset, but SSL certificates, load balancers, and block storage are also assets.
configuration files end in .tf and determine what is needed.
- State — the current way a system is, the actual live snapshot of it, not the way it should be.
- Lockfile — a file tracking what things terraform currently has.
Terraform Basic Commands
The focus of Terraform is create and recreate what is needed — and the to destroy what is not needed. Terraform can be used alone, and assets recreated as your schema changes. But most of the time, multiple IaC tools are used to better describe a system. The major background pieces it will create are:
- the lock file — which resides at ./.terraform.lock.hcl
- the state file — which resides at ./terraform.tfstate
- a backup state file — which at ./terraform.tfstate.backup
- providers — typically, which reside in ./terraform.d
The major commands that Terraform provides are:
- init — download required providers and set up state and lockfile
- validate — make sure configs are valid
- plan — show changes to modify state to match configs
- apply — run plan, then prompt to make those changes
- destroy — show changes to remove everything, prompt, then remove everything
- show— display the current assets
- taint — mark an asset currently deployed, on next apply will be recreated
- refresh — update the state of assets (not supported with LiquidWeb's provider)
- import — add existing assets into current state (not supported with LiquidWeb's provider)
Helpful Terraform modules and providers exist. A, for example, there is wordpress provider (yyamanoi1222/terraform-provider-wordpress). There are also other IaC tools that can be used with Terraform. The idiomatic approach to IaC typically involves multiple tools used in combination. However for the purposes of these examples, the focus is on a Terraform example with WordPress on Infrastructure as Code (IaC) on Liquid Web hosting.
Installing and Examples
The Hashicorp official instructions for installing Terraform are well written. You are likely best off going there. Do note, you will likely have a better time if you use the package install for your OS. In other words, on macOS use homebrew, on Windows use choco, and on Linux use your package manager.
The liquidweb provider on Terraform (liquidweb/terraform-provider-liquidweb) does not require special installation. If it is used in your configs, it should be automatically installed with terraform init. Documentation for the liquidweb provider is published on the provider's page in the documentation area:
You will need to provide credentials to a Liquid Web account in order to use the LiquidWeb provider. These credentials should be in the following environment variables:
There is also an acme SSL provider. If your domain is hosted with LiquidWeb, you can use this to get an SSL. The documentation gives a basic example. If you wish to get an SSL with the acme provider with a DNS server, you must provide the following credentials:
- LIQUID_WEB_ZONE="zone" — # the DNS zone where the ACME challenge record must be created
For examples, please look at the following areas from Liquid Web on GitHub:
Eventually, these will be found in the repository for the liquidweb provider and will be automatically published to other locations.
More examples will also be available. More features will also likely be added to the provider in the future as well. Requests for specific examples will also be opened in the future. However, first, the focus is on simplifying some of the tools.
Taking everything into account, for companies and individuals looking for dynamic and scalable infrastructure, the deployment and management of WordPress using our LW CLI, and IaC represents a flexible solution. With various options for different types of enterprises, including dedicated servers and specialized managed WordPress hosting, Liquid Web ensures dependability and scalability. The combined offerings of Liquid Web's hosting options and Terraform's infrastructure-as-code capabilities create a powerful synergy, allowing users to manage, deploy, and scale applications with ease.
When Will You Launch Your WordPress Website?
Based on your budget and website needs, Liquid Web hosting has a breadth of solutions for hosting your WordPress website, including, cloud-based options. To ensure a flawless hosting experience, we provide a secure, high-performance hosting environment that is optimized for WordPress, along with and amazing support team.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.