Skip to main content

cloider_options data source (Terraform)

The cloider_options data source reads what can be created on Cloider at the moment: the Kubernetes versions a cluster can run, the database engines with their versions, the database plans, the roots free subdomains go under, and the nameservers a custom domain points at. Use it to pick versions, validate inputs and print nameservers without hard coding them.

At a glance​

ArgumentsNone
Returnscluster_versions, database_engines, database_plans, subdomain_roots, nameservers
Changes anything?No, it only reads
APIGET /api/options, see Account endpoints
CLI equivalentcloider pricing for plans

Example usage​

List the Kubernetes versions​

main.tf
data "cloider_options" "current" {}

output "kubernetes_versions" {
value = data.cloider_options.current.cluster_versions
}
Output
kubernetes_versions = tolist([
"1.34",
"1.33",
"1.32",
])

Pick the newest PostgreSQL version​

main.tf
data "cloider_options" "current" {}

locals {
postgresql_versions = one([
for e in data.cloider_options.current.database_engines : e.versions if e.engine == "postgresql"
])
}

resource "cloider_database" "orders" {
name = "orders-db"
engine = "postgresql"
version = local.postgresql_versions[0]

# A new version would replace the database, so keep the one it was created with
lifecycle {
ignore_changes = [version]
}
}

Validate a plan variable​

main.tf
data "cloider_options" "current" {}

variable "database_plan" {
type = string
default = "starter"
}

resource "cloider_database" "orders" {
name = "orders-db"
engine = "postgresql"
plan = var.database_plan

lifecycle {
precondition {
condition = contains(data.cloider_options.current.database_plans, var.database_plan)
error_message = "database_plan has to be one of ${join(", ", data.cloider_options.current.database_plans)}."
}
}
}
main.tf
data "cloider_options" "current" {}

resource "cloider_domain" "example" {
name = "example.com"
}

output "set_these_nameservers_at_your_registrar" {
value = data.cloider_options.current.nameservers
}
Output
set_these_nameservers_at_your_registrar = tolist([
"ns1.cloider.com",
"ns2.cloider.com",
"ns3.cloider.com",
"ns4.cloider.com",
])

Build a free subdomain from the root​

main.tf
data "cloider_options" "current" {}

resource "cloider_domain" "preview" {
name = "acme-preview.${data.cloider_options.current.subdomain_roots[0]}"
}

Attribute reference​

AttributeTypeDescription
cluster_versionsList of StringThe Kubernetes versions a cloider_cluster can run, newest first
database_enginesList of ObjectThe engines a cloider_database can run, see below
database_plansList of StringThe plans a database can have, smallest first, lower case as cloider_database takes them: hobby, starter, basic, standard, plus, pro
subdomain_rootsList of StringThe roots a free subdomain cloider_domain goes under, such as cloider.app
nameserversList of StringThe nameservers to set at a custom domain's registrar

Each database_engines element has:

AttributeTypeDescription
engineStringThe engine, as cloider_database's engine takes it: postgresql, mysql, mongodb or redis
versionsList of StringIts versions, newest first
sslBoolWhether it supports SSL

The values come from the API every time Terraform reads the data source, so they change when Cloider adds or retires a version. Referring to cluster_versions[0] or versions[0] therefore needs ignore_changes, as in the examples, or a new release would replace the cluster or database.

Frequently asked questions

Which Kubernetes versions does Cloider offer?

The cloider_options data source's cluster_versions lists them, newest first. The same list is returned by GET /api/options and used by the CLI and the dashboard.

How do I get Cloider's nameservers in Terraform?

Read data.cloider_options.<name>.nameservers. Set those nameservers at your domain's registrar to have Cloider answer DNS for a custom domain.

Why should I use ignore_changes with versions from cloider_options?

Because the list changes when Cloider adds a version, and a different version replaces a cluster or database. ignore_changes = [version] keeps the version the resource was created with.