database_cluster

Generated on 30 Jun 2025 from digitalocean.cloud version v1.2.1

Synopsis

Create or delete database clusters. DigitalOcean’s managed database service simplifies the creation and management of highly javailable database clusters. Currently, it offers support for PostgreSQL, Valkey, MySQL, and MongoDB. Database clusters may be deployed in a multi-node, high-availability configuration. If your machine type is above the basic nodes, your node plan is above the smallest option, or you are running MongoDB, you may additionally include up to two standby nodes in your cluster. The size of individual nodes in a database cluster is represented by a human-readable slug, which is used in some of the following requests. Each slug denotes the node’s identifier, CPU count, and amount of RAM, in that order. View the create API documentation at https://docs.digitalocean.com/reference/api/api-reference/#tag/Databases.

Requirements

  • pydo >= 0.1.3
  • azure-core >= 1.26.1

Parameters

Parameter Choices / Default Description
backup_restore
dict
Object (database_backup)
client_override_options
dict
Client override options (developer use). For example, can be used to override the DigitalOcean API endpoint for an internal test suite. If provided, these options will knock out existing options.
engine
str / required
Choices:
  • pg
  • mysql
  • valkey
  • mongodb
A slug representing the database engine used for the cluster. The possible values are “pg” for PostgreSQL, “mysql” for MySQL, “valkey” for Valkey, and “mongodb” for MongoDB.
module_override_options
dict
Module override options (developer use). Can be used to override module options to support experimental or future options. If provided, these options will knock out existing options.
name
str / required
A unique, human-readable name referring to a database cluster.
num_nodes
int
Default: 1 The number of nodes in the database cluster.
private_network_uuid
str
A string specifying the UUID of the VPC to which the database cluster will be assigned. If excluded, the cluster when creating a new database cluster, it will be assigned to your account’s default VPC for the region.
project_id
str
The ID of the project that the database cluster is assigned to. If excluded when creating a new database cluster, it will be assigned to your default project.
region
str / required
The slug identifier for the region where the database cluster is located.
rules
list / elements=dict
Array of objects (firewall_rule)
size
str
Default: db-s-1vcpu-1gb The slug identifier representing the size of the nodes in the database cluster.
state
str
Choices:
  • present (default)
  • absent
State of the resource, present to create, absent to destroy.
tags
list / elements=str
An array of tags that have been applied to the database cluster.
timeout
int
Default: 300 Polling timeout in seconds.
token
str
DigitalOcean API token. There are several environment variables which can be used to provide this value. DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_TOKEN, DO_API_TOKEN, DO_API_KEY, DO_OAUTH_TOKEN and OAUTH_TOKEN
version
str
A string representing the version of the database engine in use for the cluster.

Examples

- name: Create Postgres database cluster
  digitalocean.cloud.database_cluster:
    token: "{{ token }}"
    state: present
    name: backend
    region: nyc3
    type: pg
    num_nodes: 2
    size: db-s-2vcpu-4gb

Return Values

KeyReturnedDescription
database
dict
always Database information.
Sample:
{
  "connection": {
    "database": "",
    "host": "backend-do-user-19081923-0.db.ondigitalocean.com",
    "password": "wv78n3zpz42xezdk",
    "port": 25060,
    "ssl": true,
    "uri": "postgres://doadmin:wv78n3zpz42xezdk@backend-do-user-19081923-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
    "user": "doadmin"
  },
  "created_at": "2019-01-11T18:37:36Z",
  "db_names": [
    "defaultdb"
  ],
  "engine": "pg",
  "id": "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30",
  "maintenance_window": {
    "day": "saturday",
    "description": "Update TimescaleDB to version 1.2.1 Upgrade to PostgreSQL 11.2 and 10.7 bugfix releases",
    "hour": "08:45:12",
    "pending": true
  },
  "name": "backend",
  "num_nodes": 2,
  "private_connection": {
    "database": "",
    "host": "private-backend-do-user-19081923-0.db.ondigitalocean.com",
    "password": "wv78n3zpz42xezdk",
    "port": 25060,
    "ssl": true,
    "uri": "postgres://doadmin:wv78n3zpz42xezdk@private-backend-do-user-19081923-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
    "user": "doadmin"
  },
  "private_network_uuid": "d455e75d-4858-4eec-8c95-da2f0a5f93a7",
  "region": "nyc3",
  "size": "db-s-2vcpu-4gb",
  "status": "creating",
  "tags": [
    "production"
  ],
  "users": [
    {
      "name": "doadmin",
      "password": "wv78n3zpz42xezdk",
      "role": "primary"
    }
  ],
  "version": "14"
}
error
dict
failure DigitalOcean API error.
Sample:
{
  "Message": "Informational error message.",
  "Reason": "Unauthorized",
  "Status Code": 401
}
msg
str
always Droplet result information.
Sample:
[
  "Created valkey database cluster backend (9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) in nyc3",
  "Created valkey database cluster backend (9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) in nyc3 is not 'online', it is 'creating'",
  "Deleted valkey database cluster backend (9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) in nyc3",
  "valkey database cluster backend in nyc3 would be created",
  "valkey database cluster backend (9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) in nyc3 exists",
  "valkey database cluster backend in nyc3 does not exist",
  "valkey database cluster backend (9cc10173-e9ea-4176-9dbc-a4cee4c4ff30) would be deleted"
]

We can't find any results for your search.

Try using different keywords or simplifying your search terms.