digitalocean logo
DigitalOcean v4.19.1, Mar 23 23

digitalocean.DatabaseUser

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

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var postgres_example = new DigitalOcean.DatabaseCluster("postgres-example", new()
    {
        Engine = "pg",
        Version = "11",
        Size = "db-s-1vcpu-1gb",
        Region = "nyc1",
        NodeCount = 1,
    });

    var user_example = new DigitalOcean.DatabaseUser("user-example", new()
    {
        ClusterId = postgres_example.Id,
    });

});
package main

import (
	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := digitalocean.NewDatabaseCluster(ctx, "postgres-example", &digitalocean.DatabaseClusterArgs{
			Engine:    pulumi.String("pg"),
			Version:   pulumi.String("11"),
			Size:      pulumi.String("db-s-1vcpu-1gb"),
			Region:    pulumi.String("nyc1"),
			NodeCount: pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		_, err = digitalocean.NewDatabaseUser(ctx, "user-example", &digitalocean.DatabaseUserArgs{
			ClusterId: postgres_example.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DatabaseCluster;
import com.pulumi.digitalocean.DatabaseClusterArgs;
import com.pulumi.digitalocean.DatabaseUser;
import com.pulumi.digitalocean.DatabaseUserArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var postgres_example = new DatabaseCluster("postgres-example", DatabaseClusterArgs.builder()        
            .engine("pg")
            .version("11")
            .size("db-s-1vcpu-1gb")
            .region("nyc1")
            .nodeCount(1)
            .build());

        var user_example = new DatabaseUser("user-example", DatabaseUserArgs.builder()        
            .clusterId(postgres_example.id())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

postgres_example = digitalocean.DatabaseCluster("postgres-example",
    engine="pg",
    version="11",
    size="db-s-1vcpu-1gb",
    region="nyc1",
    node_count=1)
user_example = digitalocean.DatabaseUser("user-example", cluster_id=postgres_example.id)
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const postgres_example = new digitalocean.DatabaseCluster("postgres-example", {
    engine: "pg",
    version: "11",
    size: "db-s-1vcpu-1gb",
    region: "nyc1",
    nodeCount: 1,
});
const user_example = new digitalocean.DatabaseUser("user-example", {clusterId: postgres_example.id});
resources:
  user-example:
    type: digitalocean:DatabaseUser
    properties:
      clusterId: ${["postgres-example"].id}
  postgres-example:
    type: digitalocean:DatabaseCluster
    properties:
      engine: pg
      version: '11'
      size: db-s-1vcpu-1gb
      region: nyc1
      nodeCount: 1

Create DatabaseUser Resource

new DatabaseUser(name: string, args: DatabaseUserArgs, opts?: CustomResourceOptions);
@overload
def DatabaseUser(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 cluster_id: Optional[str] = None,
                 mysql_auth_plugin: Optional[str] = None,
                 name: Optional[str] = None)
@overload
def DatabaseUser(resource_name: str,
                 args: DatabaseUserArgs,
                 opts: Optional[ResourceOptions] = None)
func NewDatabaseUser(ctx *Context, name string, args DatabaseUserArgs, opts ...ResourceOption) (*DatabaseUser, error)
public DatabaseUser(string name, DatabaseUserArgs args, CustomResourceOptions? opts = null)
public DatabaseUser(String name, DatabaseUserArgs args)
public DatabaseUser(String name, DatabaseUserArgs args, CustomResourceOptions options)
type: digitalocean:DatabaseUser
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args DatabaseUserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args DatabaseUserArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args DatabaseUserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DatabaseUserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args DatabaseUserArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

DatabaseUser Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The DatabaseUser resource accepts the following input properties:

ClusterId string

The ID of the original source database cluster.

MysqlAuthPlugin string

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).

Name string

The name for the database user.

ClusterId string

The ID of the original source database cluster.

MysqlAuthPlugin string

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).

Name string

The name for the database user.

clusterId String

The ID of the original source database cluster.

mysqlAuthPlugin String

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).

name String

The name for the database user.

clusterId string

The ID of the original source database cluster.

mysqlAuthPlugin string

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).

name string

The name for the database user.

cluster_id str

The ID of the original source database cluster.

mysql_auth_plugin str

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).

name str

The name for the database user.

clusterId String

The ID of the original source database cluster.

mysqlAuthPlugin String

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).

name String

The name for the database user.

Outputs

All input properties are implicitly available as output properties. Additionally, the DatabaseUser resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Password string

Password for the database user.

Role string

Role for the database user. The value will be either "primary" or "normal".

Id string

The provider-assigned unique ID for this managed resource.

Password string

Password for the database user.

Role string

Role for the database user. The value will be either "primary" or "normal".

id String

The provider-assigned unique ID for this managed resource.

password String

Password for the database user.

role String

Role for the database user. The value will be either "primary" or "normal".

id string

The provider-assigned unique ID for this managed resource.

password string

Password for the database user.

role string

Role for the database user. The value will be either "primary" or "normal".

id str

The provider-assigned unique ID for this managed resource.

password str

Password for the database user.

role str

Role for the database user. The value will be either "primary" or "normal".

id String

The provider-assigned unique ID for this managed resource.

password String

Password for the database user.

role String

Role for the database user. The value will be either "primary" or "normal".

Look up Existing DatabaseUser Resource

Get an existing DatabaseUser resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DatabaseUserState, opts?: CustomResourceOptions): DatabaseUser
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cluster_id: Optional[str] = None,
        mysql_auth_plugin: Optional[str] = None,
        name: Optional[str] = None,
        password: Optional[str] = None,
        role: Optional[str] = None) -> DatabaseUser
func GetDatabaseUser(ctx *Context, name string, id IDInput, state *DatabaseUserState, opts ...ResourceOption) (*DatabaseUser, error)
public static DatabaseUser Get(string name, Input<string> id, DatabaseUserState? state, CustomResourceOptions? opts = null)
public static DatabaseUser get(String name, Output<String> id, DatabaseUserState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ClusterId string

The ID of the original source database cluster.

MysqlAuthPlugin string

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).

Name string

The name for the database user.

Password string

Password for the database user.

Role string

Role for the database user. The value will be either "primary" or "normal".

ClusterId string

The ID of the original source database cluster.

MysqlAuthPlugin string

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).

Name string

The name for the database user.

Password string

Password for the database user.

Role string

Role for the database user. The value will be either "primary" or "normal".

clusterId String

The ID of the original source database cluster.

mysqlAuthPlugin String

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).

name String

The name for the database user.

password String

Password for the database user.

role String

Role for the database user. The value will be either "primary" or "normal".

clusterId string

The ID of the original source database cluster.

mysqlAuthPlugin string

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).

name string

The name for the database user.

password string

Password for the database user.

role string

Role for the database user. The value will be either "primary" or "normal".

cluster_id str

The ID of the original source database cluster.

mysql_auth_plugin str

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).

name str

The name for the database user.

password str

Password for the database user.

role str

Role for the database user. The value will be either "primary" or "normal".

clusterId String

The ID of the original source database cluster.

mysqlAuthPlugin String

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).

name String

The name for the database user.

password String

Password for the database user.

role String

Role for the database user. The value will be either "primary" or "normal".

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

 $ pulumi import digitalocean:index/databaseUser:DatabaseUser user-example 245bcfd0-7f31-4ce6-a2bc-475a116cca97,foobar

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.