Launch DB Using Terraform Provider
This walkthrough explains how to launch database services and manage the lifecycle of database services using the Terraform provider.
For users who prefer other interfaces, MariaDB Cloud offers the following alternatives:
This walkthrough demonstrates a service configuration that is suitable for a quick test. A more customized configuration should be selected for performance testing or for alignment to the needs of production workloads.
The procedure uses Terraform. HashiCorp officially supports Terraform on several Linux distributions, but HashiCorp also provides binaries for Microsoft Windows, macOS, and other operating systems.
For a list of operating systems that are officially supported for Terraform, see "HashiCorp Terraform Documentation: Supported Operating Systems".
For a list of operating systems that have binaries available for Terraform, see "HashiCorp Terraform Documentation: Install Terraform".
Dependencies
This procedure requires Terraform to be installed. For information about how to install Terraform, see HashiCorp Terraform Documentation: Install Terraform.
The examples in this procedure also use
jq, a JSON parsing utility. jq is available for Linux, macOS, and MS Windows. Installjq, then proceed.The examples in this procedure also use
curl, a data transfer utility. curl is available for Linux, macOS, and MS Windows. Installcurl, then proceed.The examples in this procedure also use
wget, a file download utility. GNU Wget is available for Linux, macOS, and MS Windows. Installwget, then proceed.The examples in this procedure also use exported environment variables that are compatible with Bourne-like shells (such as
sh,bash, andzsh).
Launch a Service
Generate API Key
Go to the Generate API Key page.
Fill out a name for the API key.
Click the "Create" button.
Click the copy button to copy the API key.
Store the API key somewhere safe as it is shown only once during the creation. The MariaDB Cloud platform does not store it anywhere.
Create main.tf
main.tfIn the Terraform project directory, create a main.tf file that contains the following:
Create outputs.tf
outputs.tfIn the Terraform project directory, create an outputs.tf file that contains the output values used to display metadata about the MariaDB Cloud service:
Create variables.tf
variables.tfIn the Terraform project directory, create a variables.tf file that contains the input variables used to configure the MariaDB Cloud service:
The variables are configured in the next step.
Configure Service in a .tfvars File
.tfvars FileA .tfvars file can be used to configure the service using the input variables.
For example:
The input variables should be customized for your own needs:
For
api_key, set it to the API key previously created in "Step 1: Generate API Key"For
service_type, choose a Service Type SelectionFor
topology, choose a Topology SelectionFor
cloud_provider, choose a Cloud Provider SelectionFor
region, choose a Region SelectionFor
availability_zone, choose an Availability Zone Selection or leave itnullto use the default availability zone for the cloud provider and regionFor
architecture, choose a Hardware Architecture SelectionFor
size, choose an Instance Size SelectionFor
storage, choose a Transactional Storage Size SelectionFor
nodes, choose a node countFor
sw_version, choose the Software Version Selection or leave itnullto use the default version for the topologyFor
name, choose a name between 4-24 characters for the new serviceFor
deletion_protection, choose whether the service can be deleted via Terraform (false) or whether trying to do so raises an error (true)For
ip_address, choose an IP address to allow through the firewallFor
ip_address_comment, provide a description for the IP address
The following steps assume that the file is called skysql-nr-quickstart.tfvars.
Run terraform init
terraform initInitialize the Terraform project directory and download the Terraform provider from the Terraform Registry by executing the terraform init command:
If you need to download the provider manually, see "Manually Install Provider from Binary Distribution".
Run terraform plan
terraform planCreate a Terraform execution plan by executing the terraform plan command and specifying the path to the .tfvars file:
Run terraform apply
terraform applyExecute the Terraform execution plan and create the MariaDB Cloud service by executing the terraform apply command and specifying the path to the .tfvars file:
Terraform prints the plan from the previous step again and prompts the user to confirm that the plan should be applied:
Then Terraform creates the objects and prints status messages:
Then Terraform prints the outputs.
Run terraform destroy
terraform destroyDelete the service by executing the terraform destroy command and specifying the path to the .tfvars file:
Terraform prints the plan to delete the service and prompts the user to confirm that the plan should be applied:
If deletion protection is enabled for the resources, the operation raises an error:
If deletion protection is not enabled for the resources, Terraform deletes the resources and prints status messages:
Manually Install Provider from Binary Distribution
The MariaDB Cloud New Release Terraform provider can be downloaded from the GitHub releases page as a binary distribution and manually installed.
Manually Install Provider on Linux
With Linux, manually install the provider on the target system by performing the following steps in the same Bash terminal:
Set some environment variables to configure your provider version, OS, and architecture:
For
TF_PROVIDER_ARCH, the following architectures are supported on Linux:386amd64armarm64
Download the provider from GitHub using
wget:Create a Terraform plugin directory:
Move the provider's binary distribution to the Terraform plugin directory:
Verify that the provider's binary distribution is present in the Terraform plugin directory:
Manually Install Provider on macOS
With macOS, manually install the provider on the target system by performing the following steps in the same macOS Terminal:
If Homebrew is not installed, install it:
Install
wgetusing Homebrew:Set some environment variables to configure your provider version, OS, and architecture:
For
TF_PROVIDER_ARCH, the following architectures are supported on macOS:amd64arm64
Download the provider from GitHub using
wget:Create a Terraform plugin directory:
Move the provider's binary distribution to the Terraform plugin directory:
Verify that the provider's binary distribution is present in the Terraform plugin directory:
Resources
Last updated
Was this helpful?

