1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. getDatabaseUser
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

digitalocean.getDatabaseUser

Explore with Pulumi AI

DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi

Provides information on a DigitalOcean database user resource.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const main = digitalocean.getDatabaseCluster({
    name: "main-cluster",
});
const example = main.then(main => digitalocean.getDatabaseUser({
    clusterId: main.id,
    name: "example-user",
}));
export const databaseUserPassword = example.then(example => example.password);
Copy
import pulumi
import pulumi_digitalocean as digitalocean

main = digitalocean.get_database_cluster(name="main-cluster")
example = digitalocean.get_database_user(cluster_id=main.id,
    name="example-user")
pulumi.export("databaseUserPassword", example.password)
Copy
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 {
		main, err := digitalocean.LookupDatabaseCluster(ctx, &digitalocean.LookupDatabaseClusterArgs{
			Name: "main-cluster",
		}, nil)
		if err != nil {
			return err
		}
		example, err := digitalocean.LookupDatabaseUser(ctx, &digitalocean.LookupDatabaseUserArgs{
			ClusterId: main.Id,
			Name:      "example-user",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("databaseUserPassword", example.Password)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var main = DigitalOcean.GetDatabaseCluster.Invoke(new()
    {
        Name = "main-cluster",
    });

    var example = DigitalOcean.GetDatabaseUser.Invoke(new()
    {
        ClusterId = main.Apply(getDatabaseClusterResult => getDatabaseClusterResult.Id),
        Name = "example-user",
    });

    return new Dictionary<string, object?>
    {
        ["databaseUserPassword"] = example.Apply(getDatabaseUserResult => getDatabaseUserResult.Password),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetDatabaseClusterArgs;
import com.pulumi.digitalocean.inputs.GetDatabaseUserArgs;
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) {
        final var main = DigitaloceanFunctions.getDatabaseCluster(GetDatabaseClusterArgs.builder()
            .name("main-cluster")
            .build());

        final var example = DigitaloceanFunctions.getDatabaseUser(GetDatabaseUserArgs.builder()
            .clusterId(main.applyValue(getDatabaseClusterResult -> getDatabaseClusterResult.id()))
            .name("example-user")
            .build());

        ctx.export("databaseUserPassword", example.applyValue(getDatabaseUserResult -> getDatabaseUserResult.password()));
    }
}
Copy
variables:
  main:
    fn::invoke:
      function: digitalocean:getDatabaseCluster
      arguments:
        name: main-cluster
  example:
    fn::invoke:
      function: digitalocean:getDatabaseUser
      arguments:
        clusterId: ${main.id}
        name: example-user
outputs:
  databaseUserPassword: ${example.password}
Copy

Using getDatabaseUser

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getDatabaseUser(args: GetDatabaseUserArgs, opts?: InvokeOptions): Promise<GetDatabaseUserResult>
function getDatabaseUserOutput(args: GetDatabaseUserOutputArgs, opts?: InvokeOptions): Output<GetDatabaseUserResult>
Copy
def get_database_user(cluster_id: Optional[str] = None,
                      name: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetDatabaseUserResult
def get_database_user_output(cluster_id: Optional[pulumi.Input[str]] = None,
                      name: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseUserResult]
Copy
func LookupDatabaseUser(ctx *Context, args *LookupDatabaseUserArgs, opts ...InvokeOption) (*LookupDatabaseUserResult, error)
func LookupDatabaseUserOutput(ctx *Context, args *LookupDatabaseUserOutputArgs, opts ...InvokeOption) LookupDatabaseUserResultOutput
Copy

> Note: This function is named LookupDatabaseUser in the Go SDK.

public static class GetDatabaseUser 
{
    public static Task<GetDatabaseUserResult> InvokeAsync(GetDatabaseUserArgs args, InvokeOptions? opts = null)
    public static Output<GetDatabaseUserResult> Invoke(GetDatabaseUserInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetDatabaseUserResult> getDatabaseUser(GetDatabaseUserArgs args, InvokeOptions options)
public static Output<GetDatabaseUserResult> getDatabaseUser(GetDatabaseUserArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: digitalocean:index/getDatabaseUser:getDatabaseUser
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

ClusterId This property is required. string
The ID of the database cluster.
Name This property is required. string
The name of the database user.
ClusterId This property is required. string
The ID of the database cluster.
Name This property is required. string
The name of the database user.
clusterId This property is required. String
The ID of the database cluster.
name This property is required. String
The name of the database user.
clusterId This property is required. string
The ID of the database cluster.
name This property is required. string
The name of the database user.
cluster_id This property is required. str
The ID of the database cluster.
name This property is required. str
The name of the database user.
clusterId This property is required. String
The ID of the database cluster.
name This property is required. String
The name of the database user.

getDatabaseUser Result

The following output properties are available:

AccessCert string
Access certificate for TLS client authentication. (Kafka only)
AccessKey string
Access key for TLS client authentication. (Kafka only)
ClusterId string
Id string
The provider-assigned unique ID for this managed resource.
MysqlAuthPlugin string
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
Name string
Password string
The password of the database user. This will not be set for MongoDB users.
Role string
The role of the database user. The value will be either primary or normal.
Settings List<Pulumi.DigitalOcean.Outputs.GetDatabaseUserSetting>
AccessCert string
Access certificate for TLS client authentication. (Kafka only)
AccessKey string
Access key for TLS client authentication. (Kafka only)
ClusterId string
Id string
The provider-assigned unique ID for this managed resource.
MysqlAuthPlugin string
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
Name string
Password string
The password of the database user. This will not be set for MongoDB users.
Role string
The role of the database user. The value will be either primary or normal.
Settings []GetDatabaseUserSetting
accessCert String
Access certificate for TLS client authentication. (Kafka only)
accessKey String
Access key for TLS client authentication. (Kafka only)
clusterId String
id String
The provider-assigned unique ID for this managed resource.
mysqlAuthPlugin String
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
name String
password String
The password of the database user. This will not be set for MongoDB users.
role String
The role of the database user. The value will be either primary or normal.
settings List<GetDatabaseUserSetting>
accessCert string
Access certificate for TLS client authentication. (Kafka only)
accessKey string
Access key for TLS client authentication. (Kafka only)
clusterId string
id string
The provider-assigned unique ID for this managed resource.
mysqlAuthPlugin string
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
name string
password string
The password of the database user. This will not be set for MongoDB users.
role string
The role of the database user. The value will be either primary or normal.
settings GetDatabaseUserSetting[]
access_cert str
Access certificate for TLS client authentication. (Kafka only)
access_key str
Access key for TLS client authentication. (Kafka only)
cluster_id str
id str
The provider-assigned unique ID for this managed resource.
mysql_auth_plugin str
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
name str
password str
The password of the database user. This will not be set for MongoDB users.
role str
The role of the database user. The value will be either primary or normal.
settings Sequence[GetDatabaseUserSetting]
accessCert String
Access certificate for TLS client authentication. (Kafka only)
accessKey String
Access key for TLS client authentication. (Kafka only)
clusterId String
id String
The provider-assigned unique ID for this managed resource.
mysqlAuthPlugin String
The authentication method of the MySQL user. The value will be mysql_native_password or caching_sha2_password.
name String
password String
The password of the database user. This will not be set for MongoDB users.
role String
The role of the database user. The value will be either primary or normal.
settings List<Property Map>

Supporting Types

GetDatabaseUserSetting

GetDatabaseUserSettingAcl

Id This property is required. string
Permission This property is required. string
Topic This property is required. string
Id This property is required. string
Permission This property is required. string
Topic This property is required. string
id This property is required. String
permission This property is required. String
topic This property is required. String
id This property is required. string
permission This property is required. string
topic This property is required. string
id This property is required. str
permission This property is required. str
topic This property is required. str
id This property is required. String
permission This property is required. String
topic This property is required. String

GetDatabaseUserSettingOpensearchAcl

Index This property is required. string
Permission This property is required. string
Index This property is required. string
Permission This property is required. string
index This property is required. String
permission This property is required. String
index This property is required. string
permission This property is required. string
index This property is required. str
permission This property is required. str
index This property is required. String
permission This property is required. String

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes
This Pulumi package is based on the digitalocean Terraform Provider.
DigitalOcean v4.41.0 published on Wednesday, Mar 26, 2025 by Pulumi