Skip to main content

database_clusters

Creates, updates, deletes, gets or lists a database_clusters resource.

Overview

Namedatabase_clusters
TypeResource
Iddigitalocean.databases.database_clusters

Fields

NameDatatypeDescription
idstringA unique ID that can be used to identify and reference a database cluster.
namestringA unique, human-readable name referring to a database cluster.
connectionobject
created_atstringA time value given in ISO8601 combined date and time format that represents when the database cluster was created.
db_namesarrayAn array of strings containing the names of databases created in the database cluster.
enginestringA slug representing the database engine used for the cluster. The possible values are: "pg" for PostgreSQL, "mysql" for MySQL, "redis" for Redis, "mongodb" for MongoDB, "kafka" for Kafka, and "opensearch" for OpenSearch.
maintenance_windowobject
metrics_endpointsarrayPublic hostname and port of the cluster's metrics endpoint(s). Includes one record for the cluster's primary node and a second entry for the cluster's standby node(s).
num_nodesintegerThe number of nodes in the database cluster.
private_connectionobject
private_network_uuidstringA 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_idstringThe 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.
regionstringThe slug identifier for the region where the database cluster is located.
rulesarray
semantic_versionstringA string representing the semantic version of the database engine in use for the cluster.
sizestringThe slug identifier representing the size of the nodes in the database cluster.
standby_connectionobject
standby_private_connectionobject
statusstringA string representing the current status of the database cluster.
storage_size_mibintegerAdditional storage added to the cluster, in MiB. If null, no additional storage is added to the cluster, beyond what is provided as a base amount from the 'size' and any previously added additional storage.
tagsarrayAn array of tags that have been applied to the database cluster.
ui_connectionobject
usersarray
versionstringA string representing the version of the database engine in use for the cluster.
version_end_of_availabilitystringA timestamp referring to the date when the particular version will no longer be available for creating new clusters. If null, the version does not have an end of availability timeline.
version_end_of_lifestringA timestamp referring to the date when the particular version will no longer be supported. If null, the version does not have an end of life timeline.

Methods

NameAccessible byRequired ParamsDescription
databases_get_clusterSELECTdatabase_cluster_uuidTo show information about an existing database cluster, send a GET request to /v2/databases/$DATABASE_ID. The response will be a JSON object with a database key. This will be set to an object containing the standard database cluster attributes. The embedded connection and private_connection objects will contain the information needed to access the database cluster. For multi-node clusters, the standby_connection and standby_private_connection objects contain the information needed to connect to the cluster's standby node(s). The embedded maintenance_window object will contain information about any scheduled maintenance for the database cluster.
databases_list_clustersSELECTTo list all of the database clusters available on your account, send a GET request to /v2/databases. To limit the results to database clusters with a specific tag, include the tag_name query parameter set to the name of the tag. For example, /v2/databases?tag_name=$TAG_NAME. The result will be a JSON object with a databases key. This will be set to an array of database objects, each of which will contain the standard database attributes. The embedded connection and private_connection objects will contain the information needed to access the database cluster. For multi-node clusters, the standby_connection and standby_private_connection objects will contain the information needed to connect to the cluster's standby node(s). The embedded maintenance_window object will contain information about any scheduled maintenance for the database cluster.
databases_create_clusterINSERTdata__engine, data__name, data__num_nodes, data__region, data__sizeTo create a database cluster, send a POST request to /v2/databases. The response will be a JSON object with a key called database. The value of this will be an object that contains the standard attributes associated with a database cluster. The initial value of the database cluster's status attribute will be creating. When the cluster is ready to receive traffic, this will transition to online. The embedded connection and private_connection objects will contain the information needed to access the database cluster. For multi-node clusters, the standby_connection and standby_private_connection objects will contain the information needed to connect to the cluster's standby node(s). DigitalOcean managed PostgreSQL and MySQL database clusters take automated daily backups. To create a new database cluster based on a backup of an existing cluster, send a POST request to /v2/databases. In addition to the standard database cluster attributes, the JSON body must include a key named backup_restore with the name of the original database cluster and the timestamp of the backup to be restored. Creating a database from a backup is the same as forking a database in the control panel. Note: Backups are not supported for Redis clusters.
databases_destroy_clusterDELETEdatabase_cluster_uuidTo destroy a specific database, send a DELETE request to /v2/databases/$DATABASE_ID. A status of 204 will be given. This indicates that the request was processed successfully, but that no response body is needed.
databases_install_updateEXECdatabase_cluster_uuidTo start the installation of updates for a database cluster, send a PUT request to /v2/databases/$DATABASE_ID/install_update. A successful request will receive a 204 No Content status code with no body in response.
databases_update_cluster_sizeEXECdatabase_cluster_uuid, data__num_nodes, data__sizeTo resize a database cluster, send a PUT request to /v2/databases/$DATABASE_ID/resize. The body of the request must specify both the size and num_nodes attributes. A successful request will receive a 202 Accepted status code with no body in response. Querying the database cluster will show that its status attribute will now be set to resizing. This will transition back to online when the resize operation has completed.
databases_update_maintenance_windowEXECdatabase_cluster_uuid, data__day, data__hourTo configure the window when automatic maintenance should be performed for a database cluster, send a PUT request to /v2/databases/$DATABASE_ID/maintenance. A successful request will receive a 204 No Content status code with no body in response.
databases_update_major_versionEXECdatabase_cluster_uuidTo upgrade the major version of a database, send a PUT request to /v2/databases/$DATABASE_ID/upgrade, specifying the target version. A successful request will receive a 204 No Content status code with no body in response.
databases_update_regionEXECdatabase_cluster_uuid, data__regionTo migrate a database cluster to a new region, send a PUT request to /v2/databases/$DATABASE_ID/migrate. The body of the request must specify a region attribute. A successful request will receive a 202 Accepted status code with no body in response. Querying the database cluster will show that its status attribute will now be set to migrating. This will transition back to online when the migration has completed.

SELECT examples

To list all of the database clusters available on your account, send a GET request to /v2/databases. To limit the results to database clusters with a specific tag, include the tag_name query parameter set to the name of the tag. For example, /v2/databases?tag_name=$TAG_NAME. The result will be a JSON object with a databases key. This will be set to an array of database objects, each of which will contain the standard database attributes. The embedded connection and private_connection objects will contain the information needed to access the database cluster. For multi-node clusters, the standby_connection and standby_private_connection objects will contain the information needed to connect to the cluster's standby node(s). The embedded maintenance_window object will contain information about any scheduled maintenance for the database cluster.

SELECT
id,
name,
connection,
created_at,
db_names,
engine,
maintenance_window,
metrics_endpoints,
num_nodes,
private_connection,
private_network_uuid,
project_id,
region,
rules,
semantic_version,
size,
standby_connection,
standby_private_connection,
status,
storage_size_mib,
tags,
ui_connection,
users,
version,
version_end_of_availability,
version_end_of_life
FROM digitalocean.databases.database_clusters
;

INSERT example

Use the following StackQL query and manifest file to create a new database_clusters resource.

/*+ create */
INSERT INTO digitalocean.databases.database_clusters (
data__name,
data__engine,
data__version,
data__num_nodes,
data__size,
data__region,
data__private_network_uuid,
data__tags,
data__project_id,
data__rules,
data__storage_size_mib
)
SELECT
'{{ name }}',
'{{ engine }}',
'{{ version }}',
'{{ num_nodes }}',
'{{ size }}',
'{{ region }}',
'{{ private_network_uuid }}',
'{{ tags }}',
'{{ project_id }}',
'{{ rules }}',
'{{ storage_size_mib }}'
;

DELETE example

Deletes the specified database_clusters resource.

/*+ delete */
DELETE FROM digitalocean.databases.database_clusters
WHERE database_cluster_uuid = '{{ database_cluster_uuid }}';