digitalocean_database_user

Provides a DigitalOcean database user resource. When creating a new database cluster, a default admin user with name doadmin will be created. Then, this resource can be used to provide additional normal users inside the cluster.

Example Usage

Create a new PostgreSQL database user

resource "digitalocean_database_user" "user-example" {
  cluster_id = digitalocean_database_cluster.postgres-example.id
  name       = "foobar"
}

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

Create a new user for a PostgreSQL database replica

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"
}

resource "digitalocean_database_user" "user-example" {
  cluster_id = digitalocean_database_replica.replica-example.uuid
  name       = "foobar"
}

Create a new user for a Kafka database cluster

resource "digitalocean_database_cluster" "kafka-example" {
  name       = "example-kafka-cluster"
  engine     = "kafka"
  version    = "3.5"
  size       = "db-s-2vcpu-2gb"
  region     = "nyc1"
  node_count = 3
}

resource "digitalocean_database_kafka_topic" "foobar_topic" {
  cluster_id = digitalocean_database_cluster.foobar.id
  name       = "topic-1"
}

resource "digitalocean_database_user" "foobar_user" {
  cluster_id = digitalocean_database_cluster.foobar.id
  name       = "example-user"
  settings {
    acl {
      topic      = "topic-1"
      permission = "produce"
    }
    acl {
      topic      = "topic-2"
      permission = "produceconsume"
    }
    acl {
      topic      = "topic-*"
      permission = "consume"
    }
  }
}

Argument Reference

The following arguments are supported:

settings supports the following:

An individual ACL includes the following:

Attributes Reference

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

For individual ACLs for Kafka topics, the following attributes are exported:

Import

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

terraform import digitalocean_database_user.user-example 245bcfd0-7f31-4ce6-a2bc-475a116cca97,foobar