Resource
dcloud_db_instance
A managed PostgreSQL database. The master password is generated and filed in Secrets (master_secret_id); it never passes through Terraform.
Example Usage
resource "dcloud_db_instance" "main" {
identifier = "main"
instance_class = "performance-4"
engine_version = "17"
allocated_storage_gib = 50
backup_retention_days = 14
vpc_id = dcloud_vpc.main.id
deletion_protection = true
tags = { env = "prod" }
}
# The master password is in Secrets, never in Terraform state.
output "master_secret_id" {
value = dcloud_db_instance.main.master_secret_id
}Schema
Required
identifier(String) Name of the database, unique within the organization. 3 to 48 characters. Must match^[a-z][a-z0-9-]*[a-z0-9]$. Changing it replaces the resource.instance_class(String) Instance type of every node, from server-types (e.g. performance-2; the provider’s own names are still accepted, deprecated); a cluster needs one with at least 8 GiB of memory. Up to 32 characters.
Optional
allocated_storage_gib(Number) Size of each node's data volume in GiB; 20 when omitted. Default20. From 10 to 4000.availability_zone_id(String) Zone of a single node or of a single-placement cluster, e.g. de1b; omitted: the region's default zone. Must match^[a-z]+[0-9]+[a-z]$. Changing it replaces the resource.backup_retention_days(Number) Days backups are kept for restores; 0 turns scheduled backups off; 7 when omitted. Default7. From 0 to 35.backup_window(String) When the daily backup runs, HH:MM-HH:MM (only the start is used; 03:00-04:00 by default); omitted: unchangedcapacity_fallback(String) What a create may fall back to when the provider is out of stock Changing it replaces the resource.capacity_max_wait_hours(Number) With onStockOut wait: give up after this many hours (1–168, default 24). From 1 to 168. Changing it replaces the resource.db_name(String) Name of the database created inside the server; appdb when omitted. Defaultappdb. Up to 63 characters. Must match^[a-z][a-z0-9_]*$. Changing it replaces the resource.deletion_protection(Boolean) Refuse delete until it is switched off again; off by default. Defaultfalse.engine_version(String) PostgreSQL major (e.g. 17, installed at its current pinned minor) or one of its pinned minors (e.g. 17.11); omitted: PostgreSQL 17. Up to 16 characters. Changing it replaces the resource.kms_key_id(String) KMS key that wraps every node volume's key (needs kms:Encrypt on it); omitted: the platform key. A UUID. Changing it replaces the resource.logical_replication(Boolean) wal_level = logical from the first start, for CDC and publications; off by default. Defaultfalse.master_username(String) Name of the master role, whose password is filed in Secrets; admin when omitted. Defaultadmin. Up to 63 characters. Must match^[a-z][a-z0-9_]*$. Changing it replaces the resource.max_allocated_storage_gib(Number) Autoscaling ceiling in GiB, not below allocatedStorageGib; null or omitted leaves automatic growth off. From 10 to 10000.on_stock_out(String) When the type is sold out where it goes and no fallback applies: fail at once (default), or wait as waiting-for-capacity (nothing built or billed) until it is back One of:fail,wait. Changing it replaces the resource.project(String) The project (its slug) the resource lives in. At create: this, else the provider'sproject, else Default. Changing it moves the resource and its parts; it is never replaced.publicly_accessible(Boolean) Whether the database answers on the internet; off by default: reachable only from its VPC. Defaultfalse. Changing it replaces the resource.region_id(String) Region to create in (default: the X-EWS-Region header, else de1). fi1 (Helsinki, Finland) needs the organization setting "allow EU outside Germany". Up to 32 characters. Changing it replaces the resource.replication_mode(String) Cluster only. sync (the default for a cluster): a commit waits for one standby, so a failover loses nothing acknowledged; async: lower commit latency One of:async,sync.require_tls(Boolean) Refuse clients that do not use TLS, on both ports; on by default. Defaulttrue.subnet_id(String) Subnet of that VPC to place the database in; omitted: the VPC's whole range. A UUID. Changing it replaces the resource.tags(Map of String) Tags, key → value. Once set here, only these keys are managed; tags Deutsche Cloud adds itself are left alone.topology(String) single: one node (the default); cluster: three nodes with automatic failover. Defaultsingle. One of:single,cluster. Changing it replaces the resource.vpc_id(String) VPC the database joins; omitted: the organization's default VPC for the region. A UUID. Changing it replaces the resource.zone_placement(String) Cluster only, fixed after creation. spread (the default for a cluster): members round-robin over the region's zones; single: all in availabilityZoneId One of:spread,single. Changing it replaces the resource.
Read-Only
endpoint_address(String) Host to connect to.endpoint_port(Number) Port to connect to.id(String) The resource's id.master_secret_id(String) The secret holding the master password.private_endpoint_address(String) Host inside the VPC, for a database in a VPC.status(String)creating,available,modifying, …failed.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_db_instance.main ewdb-0123456789abGenerated from the provider's schema.
Related