digitalocean_database_replica

Provides a DigitalOcean database replica resource.

Example Usage

Create a new PostgreSQL database replica

output "UUID" {
  value = digitalocean_database_replica.replica-example.uuid
}

resource "digitalocean_database_cluster" "postgres-example" {
  name       = "example-postgres-cluster"
  engine     = "pg"
  version    = "15"
  size       = "db-s-1vcpu-1gb"
  region     = "nyc1"
  node_count = 1
}

resource "digitalocean_database_replica" "replica-example" {
  cluster_id = digitalocean_database_cluster.postgres-example.id
  name       = "replica-example"
  size       = "db-s-1vcpu-1gb"
  region     = "nyc1"
}

# Create firewall rule for database replica
resource "digitalocean_database_firewall" "example-fw" {
  cluster_id = digitalocean_database_replica.replica-example.uuid

  rule {
    type  = "ip_addr"
    value = "192.168.1.1"
  }
}

Argument Reference

The following arguments are supported:

Attributes Reference

In addition to the above arguments, the following attributes are exported:

Import

Database replicas can be imported using the id of the source database cluster and the name of the replica joined with a comma. For example:

terraform import digitalocean_database_replica.read-replica 245bcfd0-7f31-4ce6-a2bc-475a116cca97,read-replica