Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse
mssql.getDatabasePermissions
Explore with Pulumi AI
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse
Returns all permissions granted in a DB to given principal
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as mssql from "@pulumi/mssql";
const exampleDatabase = mssql.getDatabase({
name: "example",
});
const exampleSqlUser = exampleDatabase.then(exampleDatabase => mssql.getSqlUser({
name: "example_user",
databaseId: exampleDatabase.id,
}));
const exampleDatabasePermissions = exampleSqlUser.then(exampleSqlUser => mssql.getDatabasePermissions({
principalId: exampleSqlUser.id,
}));
export const permissions = exampleDatabasePermissions.then(exampleDatabasePermissions => exampleDatabasePermissions.permissions);
import pulumi
import pulumi_mssql as mssql
example_database = mssql.get_database(name="example")
example_sql_user = mssql.get_sql_user(name="example_user",
database_id=example_database.id)
example_database_permissions = mssql.get_database_permissions(principal_id=example_sql_user.id)
pulumi.export("permissions", example_database_permissions.permissions)
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 {
exampleDatabase, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
Name: "example",
}, nil)
if err != nil {
return err
}
exampleSqlUser, err := mssql.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
Name: "example_user",
DatabaseId: pulumi.StringRef(exampleDatabase.Id),
}, nil)
if err != nil {
return err
}
exampleDatabasePermissions, err := mssql.GetDatabasePermissions(ctx, &mssql.GetDatabasePermissionsArgs{
PrincipalId: exampleSqlUser.Id,
}, nil)
if err != nil {
return err
}
ctx.Export("permissions", exampleDatabasePermissions.Permissions)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mssql = Pulumi.Mssql;
return await Deployment.RunAsync(() =>
{
var exampleDatabase = Mssql.GetDatabase.Invoke(new()
{
Name = "example",
});
var exampleSqlUser = Mssql.GetSqlUser.Invoke(new()
{
Name = "example_user",
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
});
var exampleDatabasePermissions = Mssql.GetDatabasePermissions.Invoke(new()
{
PrincipalId = exampleSqlUser.Apply(getSqlUserResult => getSqlUserResult.Id),
});
return new Dictionary<string, object?>
{
["permissions"] = exampleDatabasePermissions.Apply(getDatabasePermissionsResult => getDatabasePermissionsResult.Permissions),
};
});
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 com.pulumi.mssql.inputs.GetDatabasePermissionsArgs;
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 exampleDatabase = MssqlFunctions.getDatabase(GetDatabaseArgs.builder()
.name("example")
.build());
final var exampleSqlUser = MssqlFunctions.getSqlUser(GetSqlUserArgs.builder()
.name("example_user")
.databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
.build());
final var exampleDatabasePermissions = MssqlFunctions.getDatabasePermissions(GetDatabasePermissionsArgs.builder()
.principalId(exampleSqlUser.applyValue(getSqlUserResult -> getSqlUserResult.id()))
.build());
ctx.export("permissions", exampleDatabasePermissions.applyValue(getDatabasePermissionsResult -> getDatabasePermissionsResult.permissions()));
}
}
variables:
exampleDatabase:
fn::invoke:
Function: mssql:getDatabase
Arguments:
name: example
exampleSqlUser:
fn::invoke:
Function: mssql:getSqlUser
Arguments:
name: example_user
databaseId: ${exampleDatabase.id}
exampleDatabasePermissions:
fn::invoke:
Function: mssql:getDatabasePermissions
Arguments:
principalId: ${exampleSqlUser.id}
outputs:
permissions: ${exampleDatabasePermissions.permissions}
Using getDatabasePermissions
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 getDatabasePermissions(args: GetDatabasePermissionsArgs, opts?: InvokeOptions): Promise<GetDatabasePermissionsResult>
function getDatabasePermissionsOutput(args: GetDatabasePermissionsOutputArgs, opts?: InvokeOptions): Output<GetDatabasePermissionsResult>
def get_database_permissions(principal_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetDatabasePermissionsResult
def get_database_permissions_output(principal_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetDatabasePermissionsResult]
func GetDatabasePermissions(ctx *Context, args *GetDatabasePermissionsArgs, opts ...InvokeOption) (*GetDatabasePermissionsResult, error)
func GetDatabasePermissionsOutput(ctx *Context, args *GetDatabasePermissionsOutputArgs, opts ...InvokeOption) GetDatabasePermissionsResultOutput
> Note: This function is named GetDatabasePermissions
in the Go SDK.
public static class GetDatabasePermissions
{
public static Task<GetDatabasePermissionsResult> InvokeAsync(GetDatabasePermissionsArgs args, InvokeOptions? opts = null)
public static Output<GetDatabasePermissionsResult> Invoke(GetDatabasePermissionsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDatabasePermissionsResult> getDatabasePermissions(GetDatabasePermissionsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: mssql:index/getDatabasePermissions:getDatabasePermissions
arguments:
# arguments dictionary
The following arguments are supported:
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- principal_
id str <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
getDatabasePermissions Result
The following output properties are available:
- Id string
<database_id>/<principal_id>
.- Permissions
List<Pulumiverse.
Mssql. Outputs. Get Database Permissions Permission> - Set of permissions granted to the principal
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- Id string
<database_id>/<principal_id>
.- Permissions
[]Get
Database Permissions Permission - Set of permissions granted to the principal
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- id String
<database_id>/<principal_id>
.- permissions
List<Get
Database Permissions Permission> - Set of permissions granted to the principal
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- id string
<database_id>/<principal_id>
.- permissions
Get
Database Permissions Permission[] - Set of permissions granted to the principal
- principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- id str
<database_id>/<principal_id>
.- permissions
Sequence[Get
Database Permissions Permission] - Set of permissions granted to the principal
- principal_
id str <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
- id String
<database_id>/<principal_id>
.- permissions List<Property Map>
- Set of permissions granted to the principal
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.
Supporting Types
GetDatabasePermissionsPermission
- Permission string
- Name of database-level SQL permission. For full list of supported permissions, see docs
- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
- Permission string
- Name of database-level SQL permission. For full list of supported permissions, see docs
- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
- permission String
- Name of database-level SQL permission. For full list of supported permissions, see docs
- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
- permission string
- Name of database-level SQL permission. For full list of supported permissions, see docs
- with
Grant booleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
- permission str
- Name of database-level SQL permission. For full list of supported permissions, see docs
- with_
grant_ booloption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
- permission String
- Name of database-level SQL permission. For full list of supported permissions, see docs
- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals.
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