1. Packages
  2. MSSQL
  3. API Docs
  4. getDatabaseRole
Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse

mssql.getDatabaseRole

Explore with Pulumi AI

mssql logo
Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse

    Obtains information about single database role.

    Example Usage

    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.GetDatabaseRole.Invoke(new()
        {
            Name = "public",
            DatabaseId = master.Apply(getDatabaseResult => getDatabaseResult.Id),
        });
    
        return new Dictionary<string, object?>
        {
            ["id"] = example.Apply(getDatabaseRoleResult => getDatabaseRoleResult.Id),
        };
    });
    
    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.LookupDatabaseRole(ctx, &mssql.LookupDatabaseRoleArgs{
    			Name:       "public",
    			DatabaseId: pulumi.StringRef(master.Id),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("id", example.Id)
    		return nil
    	})
    }
    
    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.GetDatabaseRoleArgs;
    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.getDatabaseRole(GetDatabaseRoleArgs.builder()
                .name("public")
                .databaseId(master.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
            ctx.export("id", example.applyValue(getDatabaseRoleResult -> getDatabaseRoleResult.id()));
        }
    }
    
    import pulumi
    import pulumi_mssql as mssql
    
    master = mssql.get_database(name="master")
    example = mssql.get_database_role(name="public",
        database_id=master.id)
    pulumi.export("id", example.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    
    const master = mssql.getDatabase({
        name: "master",
    });
    const example = master.then(master => mssql.getDatabaseRole({
        name: "public",
        databaseId: master.id,
    }));
    export const id = example.then(example => example.id);
    
    variables:
      master:
        fn::invoke:
          Function: mssql:getDatabase
          Arguments:
            name: master
      example:
        fn::invoke:
          Function: mssql:getDatabaseRole
          Arguments:
            name: public
            databaseId: ${master.id}
    outputs:
      id: ${example.id}
    

    Using getDatabaseRole

    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 getDatabaseRole(args: GetDatabaseRoleArgs, opts?: InvokeOptions): Promise<GetDatabaseRoleResult>
    function getDatabaseRoleOutput(args: GetDatabaseRoleOutputArgs, opts?: InvokeOptions): Output<GetDatabaseRoleResult>
    def get_database_role(database_id: Optional[str] = None,
                          name: Optional[str] = None,
                          opts: Optional[InvokeOptions] = None) -> GetDatabaseRoleResult
    def get_database_role_output(database_id: Optional[pulumi.Input[str]] = None,
                          name: Optional[pulumi.Input[str]] = None,
                          opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseRoleResult]
    func LookupDatabaseRole(ctx *Context, args *LookupDatabaseRoleArgs, opts ...InvokeOption) (*LookupDatabaseRoleResult, error)
    func LookupDatabaseRoleOutput(ctx *Context, args *LookupDatabaseRoleOutputArgs, opts ...InvokeOption) LookupDatabaseRoleResultOutput

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

    public static class GetDatabaseRole 
    {
        public static Task<GetDatabaseRoleResult> InvokeAsync(GetDatabaseRoleArgs args, InvokeOptions? opts = null)
        public static Output<GetDatabaseRoleResult> Invoke(GetDatabaseRoleInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDatabaseRoleResult> getDatabaseRole(GetDatabaseRoleArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: mssql:index/getDatabaseRole:getDatabaseRole
      arguments:
        # arguments dictionary

    The following arguments are supported:

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

    getDatabaseRole Result

    The following output properties are available:

    Id string
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    Members List<Pulumiverse.Mssql.Outputs.GetDatabaseRoleMember>
    Set of role members
    Name string
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    OwnerId string
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    Id string
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    Members []GetDatabaseRoleMemberType
    Set of role members
    Name string
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    OwnerId string
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id String
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    members List<GetDatabaseRoleMember>
    Set of role members
    name String
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    ownerId String
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id string
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    members GetDatabaseRoleMember[]
    Set of role members
    name string
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    ownerId string
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.
    id str
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    members Sequence[GetDatabaseRoleMember]
    Set of role members
    name str
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    owner_id str
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    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
    <database_id>/<role_id>. Role ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<role_name>')
    members List<Property Map>
    Set of role members
    name String
    Role name. Must follow Regular Identifiers rules and cannot be longer than 128 chars.
    ownerId String
    ID of another database role or user owning this role. Can be retrieved using mssql.DatabaseRole or mssql.SqlUser.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>'). Defaults to ID of master.

    Supporting Types

    GetDatabaseRoleMember

    Id string
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    Name string
    Name of the database principal.
    Type string
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER
    Id string
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    Name string
    Name of the database principal.
    Type string
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER
    id String
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    name String
    Name of the database principal.
    type String
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER
    id string
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    name string
    Name of the database principal.
    type string
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER
    id str
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    name str
    Name of the database principal.
    type str
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER
    id String
    <database_id>/<member_id>. Member ID can be retrieved using `SELECT DATABASEPRINCIPALID('\n\n')
    name String
    Name of the database principal.
    type String
    One of: SQL_USER, DATABASE_ROLE, AZUREAD_USER

    Package Details

    Repository
    mssql pulumiverse/pulumi-mssql
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mssql Terraform Provider.
    mssql logo
    Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse