» 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    = "11"
  size       = "db-s-1vcpu-1gb"
  region     = "nyc1"
  node_count = 1

» Argument Reference

The following arguments are supported:

  • cluster_id - (Required) The ID of the original source database cluster.
  • name - (Required) The name for the database user.
  • mysql_auth_plugin - (Optional) The authentication method to use for connections to the MySQL user account. The valid values are mysql_native_password or caching_sha2_password (this is the default).

» Attributes Reference

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

  • role - Role for the database user. The value will be either "primary" or "normal".
  • password - Password for the database user.

» 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