This is the Terraform Provider for the Severalnines CCX Database as a service platform.
- CCX Website: https://ccx.severalnines.com/
- Documentation: https://docs.severalnines.com/docs/ccx/
- Support: https://support.severalnines.com/hc/en-us/requests/new (sign up before you create the request).
- Terraform 0.13.x or later
- Sign up for CCX at https://ccx.severalnines.com/
- Create a Terraform file called datastore.tf with the content below.
- Set
client_id
,client_secret
and datastore information. You can generate these credentials on the Account page (https://app.mydbservice.net/account) Authorization tab.
terraform {
required_providers {
ccx = {
source = "severalnines/ccx"
version = "~> 0.3.2"
}
}
}
provider "ccx" {
client_id = "please_enter_your_client_id_here"
client_secret = "please_enter_your_client_secret_here"
}
resource "ccx_datastore" "luna_postgres" {
name = "luna"
size = 1
db_vendor = "postgres"
tags = ["new", "test"]
cloud_provider = "aws"
cloud_region = "eu-north-1"
instance_size = "m5.large"
volume_size = 80
volume_type = "gp2"
network_type = "public"
}
resource "ccx_datastore" "luna_mysql" {
name = "luna_mysql"
size = 3
type = "replication"
db_vendor = "mysql"
tags = ["new", "test"]
cloud_provider = "aws"
cloud_region = "eu-north-1"
instance_size = "m5.large"
volume_size = 80
volume_type = "gp2"
network_type = "public"
}
Optionally you can create a VPC (supported by AWS)
resource "ccx_vpc" "venus" {
vpc_name = "venus"
vpc_cloud_provider = "aws"
vpc_cloud_region = "eu-north-1"
vpc_ipv4_cidr = "10.10.0.0/16"
}
In that case set:
network_type = "private"
network_vpc_uuid = ccx_vpc.venus.id
in the resource "ccx_datastore" section, see also example_datastore.tf
- Run:
terraform init
terraform apply
- Login to CCX and watch the datastore being deployed :)
Database parameters can be configured for the cluster by using the block db_params
inside the ccx_datastore
block as follows:
db_params = {
sql_mode = "STRICT"
}
The parameters will depend on the database vendor and version.
Refer to the Settings > DB Parameters
section for a list of available parameters.
Firewall settings can be configured for the cluster by using the block firewall
inside the ccx_datastore
block as follows:
firewall {
source = "x.x.x.x/32"
description = "description here"
}
firewall {
source = "y.y.y.y/32"
description = "description here"
}
You may add multiple firewall blocks to allow multiple IP addresses.
Notifications can be configured for the cluster by including the following blocks inside the ccx_datastore
block:
notifications_enabled = true # or false
notifications_emails = ["[email protected]", "[email protected]"] #
Maintenance settings can be configured for the cluster by including the following blocks inside the ccx_datastore
block:
maintenance_day_of_week = 2 # 1-7, 1 is Monday
maintenance_start_hour = 2 # 0-23
maintenance_end_hour = 4
Scaling the cluster can be done by changing the size
parameter in the ccx_datastore
block. When downscaling, the oldest non-primary node will be removed.
- go 1.21 or later
- Terraform 0.13.x or later
Clone and use make
to install.
- Clone:
git clone https://github.com/severalnines/terraform-provider-ccx
- Install:
make install
Clone, build and place the plugin in the right folder.
- Clone:
git clone https://github.com/severalnines/terraform-provider-ccx
- Build:
go build -o ./bin/terraform-provider-ccx.exe ./cmd/terraform-provider-ccx
- Place:
./bin/terraform-provider-ccx.exe
as%APPDATA%/terraform.d/plugins/registry.terraform.io/severalnines/ccx/0.3.2/windows_amd64/terraform-provider-ccx.exe
Create a provider and a resource file and specify account settings and datastore properties. The provider and resource sections may be located in one file, see https://github.com/severalnines/terraform-provider-ccx/examples/example_datastore.tf
terraform {
required_providers {
ccx = {
source = "severalnines/ccx"
version = "~> 0.3.2"
}
}
}
provider "ccx" {
client_id = "your_ccx_client_id"
client_secret = "your_ccx_client_secret
# base_url = "optionally_use_a_different_base_url"
# timeout = "60m"
}
Note:
the option
base_url
may be used to specify a different ccx compliant cloud service.The option
timeout
may be used to specify a different timeout for operations. Default is"60m"
. Format is according to ParseDuration.
resource "ccx_datastore" "luna" {
name = "luna"
size = 2
db_vendor = "postgres"
tags = ["new", "test"]
cloud_provider = "aws"
cloud_region = "eu-north-1"
instance_size = "m5.large"
volume_size = 80
volume_type = "gp2"
network_type = "public"
}
or for mysql, replication (primary and two replicas, i.e size=3)
resource "ccx_datastore" "luna_mysql" {
name = "luna_mysql"
size = 3
type = "replication"
db_vendor = "mysql"
tags = ["new", "test"]
cloud_provider = "aws"
cloud_region = "eu-north-1"
instance_size = "m5.large"
volume_size = 80
volume_type = "gp2"
network_type = "public"
}
resource "ccx_vpc" "venus" {
vpc_name = "venus"
vpc_cloud_provider = "aws"
vpc_cloud_region = "eu-north-1"
vpc_ipv4_cidr = "10.10.0.0/16"
}
terraform apply
If you have issues, please report them under Issues.