Terraform & Ansible Integration
Automate 123cluster provisioning via Terraform in your CI/CD pipelines.
In this section, we’ll walk through how to leverage 123cluster’s REST API from Terraform and Ansible to implement a fully automated DevOps workflow. Using MongoDB replica-sets as our running example, you’ll learn to extract the exact JSON payloads from the UI, translate them into Terraform resources for each key action:
/create_cluster/
(for MongoDB replicaset initialization)/add_mongo_standby/
/backup_node/
/export_database/
/restore_backup/
&/restore_export/
/drop_node/
&/drop_database/
&/drop_backup/
—and then invoke Ansible playbooks to finalize server configuration, security settings, and any database-specific tuning. Although we illustrate this with MongoDB (which uses replica-sets rather than “clusters”), you can follow the same pattern for MySQL, PostgreSQL, MariaDB, Redis, and other engines supported by 123cluster—simply swap the REST endpoints and JSON payload fields as needed. By the end, you’ll have a reproducible, version-controlled pipeline for managing any database service on 123cluster.
Prerequisites
- Terraform CLI (v1.0+) installed
- A valid 123cluster JWT token
- Network access to your target host
- (Optional) Ansible and SSH access for post-provisioning