1. Packages
  2. MSSQL
  3. API Docs
  4. getDatabaseRoles
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

mssql.getDatabaseRoles

Explore with Pulumi AI

Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

Obtains information about all roles defined in a database.

Example Usage

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

const master = mssql.getDatabase({
    name: "master",
});
const example = master.then(master => mssql.getDatabaseRoles({
    databaseId: master.id,
}));
export const roles = example.then(example => example.roles);
Copy
import pulumi
import pulumi_mssql as mssql

master = mssql.get_database(name="master")
example = mssql.get_database_roles(database_id=master.id)
pulumi.export("roles", example.roles)
Copy
package main

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-mssql/sdk/go/mssql"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		master, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
			Name: "master",
		}, nil)
		if err != nil {
			return err
		}
		example, err := mssql.GetDatabaseRoles(ctx, &mssql.GetDatabaseRolesArgs{
			DatabaseId: pulumi.StringRef(master.Id),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("roles", example.Roles)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mssql = Pulumi.Mssql;

return await Deployment.RunAsync(() => 
{
    var master = Mssql.GetDatabase.Invoke(new()
    {
        Name = "master",
    });

    var example = Mssql.GetDatabaseRoles.Invoke(new()
    {
        DatabaseId = master.Apply(getDatabaseResult => getDatabaseResult.Id),
    });

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

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mssql.MssqlFunctions;
import com.pulumi.mssql.inputs.GetDatabaseArgs;
import com.pulumi.mssql.inputs.GetDatabaseRolesArgs;
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 master = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
            .name("master")
            .build());

        final var example = MssqlFunctions.getDatabaseRoles(GetDatabaseRolesArgs.builder()
            .databaseId(master.applyValue(getDatabaseResult -> getDatabaseResult.id()))
            .build());

        ctx.export("roles", example.applyValue(getDatabaseRolesResult -> getDatabaseRolesResult.roles()));
    }
}
Copy
variables:
  master:
    fn::invoke:
      Function: mssql:getDatabase
      Arguments:
        name: master
  example:
    fn::invoke:
      Function: mssql:getDatabaseRoles
      Arguments:
        databaseId: ${master.id}
outputs:
  roles: ${example.roles}
Copy

Using getDatabaseRoles

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 getDatabaseRoles(args: GetDatabaseRolesArgs, opts?: InvokeOptions): Promise<GetDatabaseRolesResult>
function getDatabaseRolesOutput(args: GetDatabaseRolesOutputArgs, opts?: InvokeOptions): Output<GetDatabaseRolesResult>
Copy
def get_database_roles(database_id: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetDatabaseRolesResult
def get_database_roles_output(database_id: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseRolesResult]
Copy
func GetDatabaseRoles(ctx *Context, args *GetDatabaseRolesArgs, opts ...InvokeOption) (*GetDatabaseRolesResult, error)
func GetDatabaseRolesOutput(ctx *Context, args *GetDatabaseRolesOutputArgs, opts ...InvokeOption) GetDatabaseRolesResultOutput
Copy

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

public static class GetDatabaseRoles 
{
    public static Task<GetDatabaseRolesResult> InvokeAsync(GetDatabaseRolesArgs args, InvokeOptions? opts = null)
    public static Output<GetDatabaseRolesResult> Invoke(GetDatabaseRolesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetDatabaseRolesResult> getDatabaseRoles(GetDatabaseRolesArgs args, InvokeOptions options)
public static Output<GetDatabaseRolesResult> getDatabaseRoles(GetDatabaseRolesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: mssql:index/getDatabaseRoles:getDatabaseRoles
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

DatabaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
DatabaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
databaseId String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
databaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
database_id str
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
databaseId String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.

getDatabaseRoles Result

The following output properties are available:

Id string
ID of the resource, equals to database ID
Roles List<Pulumiverse.Mssql.Outputs.GetDatabaseRolesRole>
Set of database role objects
DatabaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
Id string
ID of the resource, equals to database ID
Roles []GetDatabaseRolesRole
Set of database role objects
DatabaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
id String
ID of the resource, equals to database ID
roles List<GetDatabaseRolesRole>
Set of database role objects
databaseId String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
id string
ID of the resource, equals to database ID
roles GetDatabaseRolesRole[]
Set of database role objects
databaseId string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
id str
ID of the resource, equals to database ID
roles Sequence[GetDatabaseRolesRole]
Set of database role objects
database_id str
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
id String
ID of the resource, equals to database ID
roles List<Property Map>
Set of database role objects
databaseId String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.

Supporting Types

GetDatabaseRolesRole

DatabaseId This property is required. string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
Id This property is required. string
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
Name This property is required. string
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
OwnerId This property is required. string
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
DatabaseId This property is required. string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
Id This property is required. string
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
Name This property is required. string
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
OwnerId This property is required. string
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
databaseId This property is required. String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
id This property is required. String
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
name This property is required. String
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
ownerId This property is required. String
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
databaseId This property is required. string
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
id This property is required. string
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
name This property is required. string
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
ownerId This property is required. string
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
database_id This property is required. str
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
id This property is required. str
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
name This property is required. str
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
owner_id This property is required. str
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
databaseId This property is required. String
ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
id This property is required. String
<database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
name This property is required. String
Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
ownerId This property is required. String
ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.

Package Details

Repository
mssql pulumiverse/pulumi-mssql
License
Apache-2.0
Notes
This Pulumi package is based on the mssql Terraform Provider.
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse