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

mssql.getSqlUser

Explore with Pulumi AI

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

    Obtains information about single SQL database user.

    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.GetSqlUser.Invoke(new()
        {
            Name = "dbo",
            DatabaseId = master.Apply(getDatabaseResult => getDatabaseResult.Id),
        });
    
        return new Dictionary<string, object?>
        {
            ["id"] = example.Apply(getSqlUserResult => getSqlUserResult.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.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
    			Name:       "dbo",
    			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.GetSqlUserArgs;
    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.getSqlUser(GetSqlUserArgs.builder()
                .name("dbo")
                .databaseId(master.applyValue(getDatabaseResult -> getDatabaseResult.id()))
                .build());
    
            ctx.export("id", example.applyValue(getSqlUserResult -> getSqlUserResult.id()));
        }
    }
    
    import pulumi
    import pulumi_mssql as mssql
    
    master = mssql.get_database(name="master")
    example = mssql.get_sql_user(name="dbo",
        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.getSqlUser({
        name: "dbo",
        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:getSqlUser
          Arguments:
            name: dbo
            databaseId: ${master.id}
    outputs:
      id: ${example.id}
    

    Using getSqlUser

    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 getSqlUser(args: GetSqlUserArgs, opts?: InvokeOptions): Promise<GetSqlUserResult>
    function getSqlUserOutput(args: GetSqlUserOutputArgs, opts?: InvokeOptions): Output<GetSqlUserResult>
    def get_sql_user(database_id: Optional[str] = None,
                     name: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetSqlUserResult
    def get_sql_user_output(database_id: Optional[pulumi.Input[str]] = None,
                     name: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetSqlUserResult]
    func LookupSqlUser(ctx *Context, args *LookupSqlUserArgs, opts ...InvokeOption) (*LookupSqlUserResult, error)
    func LookupSqlUserOutput(ctx *Context, args *LookupSqlUserOutputArgs, opts ...InvokeOption) LookupSqlUserResultOutput

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

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

    The following arguments are supported:

    Name string
    User name. Cannot be longer than 128 chars.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    Name string
    User name. Cannot be longer than 128 chars.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    name String
    User name. Cannot be longer than 128 chars.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    name string
    User name. Cannot be longer than 128 chars.
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    name str
    User name. Cannot be longer than 128 chars.
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    name String
    User name. Cannot be longer than 128 chars.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').

    getSqlUser Result

    The following output properties are available:

    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    Id string
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    LoginId string
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    Name string
    User name. Cannot be longer than 128 chars.
    DatabaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    Id string
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    LoginId string
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    Name string
    User name. Cannot be longer than 128 chars.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id String
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    loginId String
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    name String
    User name. Cannot be longer than 128 chars.
    databaseId string
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id string
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    loginId string
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    name string
    User name. Cannot be longer than 128 chars.
    database_id str
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id str
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    login_id str
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    name str
    User name. Cannot be longer than 128 chars.
    databaseId String
    ID of database. Can be retrieved using mssql.Database or SELECT DB_ID('<db_name>').
    id String
    <database_id>/<user_id>. User ID can be retrieved using SELECT DATABASE_PRINCIPAL_ID('<user_name>').
    loginId String
    SID of SQL login. Can be retrieved using mssql.SqlLogin or SELECT SUSER_SID('<login_name>').
    name String
    User name. Cannot be longer than 128 chars.

    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