[ Web Proxy ]
URL:
Viewing: https://docs.digitalocean.com/reference/terraform/reference/resources/database_user/ [Back]  [Original]

digitalocean_database_user | DigitalOcean Documentation

For AI agents: The documentation index is at https://docs.digitalocean.com/llms.txt. Markdown versions of pages use the same URL with index.html.md in place of the HTML page (for example, append index.html.md to the directory path instead of opening the HTML document).

digitalocean_database_user

Generated on 18 Aug 2026 from Terraform version v2.100.0

Copy page as Markdown View page as Markdown

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.

NOTE: Any new users created will always have normal role, only the default user that comes with database cluster creation has primary role. Additional permissions must be managed manually.

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

Note: MongoDB user passwords are only available when the user is created. An existing MongoDB user that is imported will not have its password attribute exported. Recreate the user if it is necessary to access the password with Terraform.

In this article...


We can't find any results for your search.

Try using different keywords or simplifying your search terms.


Web Proxy Viewer  |  New URL  |  Original Page