IaC Bazaar
DigitalOceanPlan-validated

DigitalOcean Managed Database

Managed PG/MySQL/Valkey cluster with firewall trust list, users, DBs, and replicas.

terraformAlt & Specialty Clouds#digitalocean

Compare Managed Relational Database across clouds →

do-managed-databaseterraform v1.7

Verification

Plan-validated

Passed: module logic verified on a mocked plan — inputs, validation rules, conditional creation and outputs resolve (no real provider, no cloud).

Conformance

  • Static validation (fmt · validate · tflint)
  • No applicable security policies for this provider
  • Plan tests (mocked: validation rules · outputs)

Provenance

  • SHA-256 checksum
  • Signature (pending)

Functional

  • Live test pending (no cloud run yet)

Last verified 2026-06-28 · how we verify

Documentation

do-managed-database

Managed PG/MySQL/Valkey cluster with firewall trust list, users, DBs, and replicas. One module call provisions the cluster (single-node to 3-node HA), locks inbound access to an explicit trust list, creates additional users and logical databases, and stamps out read replicas — with engine-conditional arguments (sql_mode, eviction_policy) wired automatically so a single interface covers all three engines. Works with Terraform and OpenTofu (>= 1.6), DigitalOcean provider >= 2.0, < 3.0.

Opinionated defaults:

  • Explicit weekly maintenance window (Sunday 04:00 UTC)
  • Engine-conditional preconditions fail fast at plan time (users/DBs/replicas on Valkey are rejected before any API call)
  • Credentials only leave the module through sensitive outputs

Usage

module "db" {
  source = "./do-managed-database"

  name           = "app-pg"
  engine         = "pg"
  engine_version = "17"
  region         = "fra1"
  node_count     = 2 # primary + standby

  private_network_uuid = digitalocean_vpc.main.id

  trusted_sources = [
    { type = "tag", value = "app" },          # droplets tagged "app"
    { type = "ip_addr", value = "203.0.113.10" },
  ]

  users     = ["app_rw"]
  databases = ["app"]

  read_replicas = {
    reporting = { size = "db-s-2vcpu-4gb" }
  }

  tags = ["env:prod"]
}

Inputs

NameTypeDefaultDescription
namestringCluster name (required)
enginestringpg, mysql, or valkey (required)
engine_versionstringEngine major version, e.g. "17" (required)
sizestringdb-s-1vcpu-1gbNode size slug
regionstringDO region slug (required)
node_countnumber11–3 nodes (2+ = HA standbys)
private_network_uuidstringnullVPC for the cluster (null = region default)
storage_size_mibnumbernullExtra disk (pg/mysql)
sql_modestringnullMySQL sql_mode (ignored otherwise)
eviction_policystringnullValkey eviction policy (ignored otherwise)
maintenance_windowobject{day="sunday", hour="04:00"}Weekly window (UTC)
trusted_sourceslist(object)[]Firewall rules {type, value}; type ∈ ip_addr/droplet/k8s/tag/app
userslist(string)[]Additional users (pg/mysql)
databaseslist(string)[]Additional logical DBs (pg/mysql)
read_replicasmap(object){}Replicas keyed by name: {size, region, private_network_uuid}
tagslist(string)[]DO tags

Outputs

cluster_id, cluster_urn, host, private_host, port, default_database, default_user, default_password (sensitive), uri (sensitive), private_uri (sensitive), user_passwords (sensitive), database_names, replica_hosts, replica_private_hosts, replica_uris (sensitive).

Notes

  • Set trusted_sources in production. Without it, DigitalOcean leaves the cluster reachable from any source (TLS + password still required).
  • Provisioning takes ~10 minutes; replicas add a few more each.
  • Valkey clusters do not support extra users, logical DBs, or replicas — the module rejects those combinations at plan time.

Requirements

  • Terraform or OpenTofu >= 1.6
  • digitalocean/digitalocean provider >= 2.0, < 3.0 (the valkey engine needs a recent 2.x — latest recommended)

Verification

Static-validated (fmt, validate, tflint). Live apply/destroy testing pending cloud sandbox availability — see catalog status.

License

Commercial — IaC Bazaar EULA. © IaC Bazaar. Original work (not derived from a third-party module).