mssql.DatabaseRoleMember
Explore with Pulumi AI
Manages database role membership.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as mssql from "@pulumi/mssql";
import * as mssql from "@pulumiverse/mssql";
const exampleDatabase = mssql.getDatabase({
name: "example",
});
const owner = exampleDatabase.then(exampleDatabase => mssql.getSqlUser({
name: "example_user",
databaseId: exampleDatabase.id,
}));
const member = exampleDatabase.then(exampleDatabase => mssql.getSqlUser({
name: "member_user",
databaseId: exampleDatabase.id,
}));
const exampleDatabaseRole = new mssql.DatabaseRole("exampleDatabaseRole", {
databaseId: exampleDatabase.then(exampleDatabase => exampleDatabase.id),
ownerId: owner.then(owner => owner.id),
});
const exampleDatabaseRoleMember = new mssql.DatabaseRoleMember("exampleDatabaseRoleMember", {
roleId: exampleDatabaseRole.id,
memberId: member.then(member => member.id),
});
import pulumi
import pulumi_mssql as mssql
import pulumiverse_mssql as mssql
example_database = mssql.get_database(name="example")
owner = mssql.get_sql_user(name="example_user",
database_id=example_database.id)
member = mssql.get_sql_user(name="member_user",
database_id=example_database.id)
example_database_role = mssql.DatabaseRole("exampleDatabaseRole",
database_id=example_database.id,
owner_id=owner.id)
example_database_role_member = mssql.DatabaseRoleMember("exampleDatabaseRoleMember",
role_id=example_database_role.id,
member_id=member.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 {
exampleDatabase, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
Name: "example",
}, nil)
if err != nil {
return err
}
owner, err := mssql.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
Name: "example_user",
DatabaseId: pulumi.StringRef(exampleDatabase.Id),
}, nil)
if err != nil {
return err
}
member, err := mssql.LookupSqlUser(ctx, &mssql.LookupSqlUserArgs{
Name: "member_user",
DatabaseId: pulumi.StringRef(exampleDatabase.Id),
}, nil)
if err != nil {
return err
}
exampleDatabaseRole, err := mssql.NewDatabaseRole(ctx, "exampleDatabaseRole", &mssql.DatabaseRoleArgs{
DatabaseId: pulumi.String(exampleDatabase.Id),
OwnerId: pulumi.String(owner.Id),
})
if err != nil {
return err
}
_, err = mssql.NewDatabaseRoleMember(ctx, "exampleDatabaseRoleMember", &mssql.DatabaseRoleMemberArgs{
RoleId: exampleDatabaseRole.ID(),
MemberId: pulumi.String(member.Id),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mssql = Pulumi.Mssql;
using Mssql = Pulumiverse.Mssql;
return await Deployment.RunAsync(() =>
{
var exampleDatabase = Mssql.GetDatabase.Invoke(new()
{
Name = "example",
});
var owner = Mssql.GetSqlUser.Invoke(new()
{
Name = "example_user",
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
});
var member = Mssql.GetSqlUser.Invoke(new()
{
Name = "member_user",
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
});
var exampleDatabaseRole = new Mssql.DatabaseRole("exampleDatabaseRole", new()
{
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
OwnerId = owner.Apply(getSqlUserResult => getSqlUserResult.Id),
});
var exampleDatabaseRoleMember = new Mssql.DatabaseRoleMember("exampleDatabaseRoleMember", new()
{
RoleId = exampleDatabaseRole.Id,
MemberId = member.Apply(getSqlUserResult => getSqlUserResult.Id),
});
});
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.DatabaseRole;
import com.pulumi.mssql.DatabaseRoleArgs;
import com.pulumi.mssql.DatabaseRoleMember;
import com.pulumi.mssql.DatabaseRoleMemberArgs;
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 owner = MssqlFunctions.getSqlUser(GetSqlUserArgs.builder()
.name("example_user")
.databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
.build());
final var member = MssqlFunctions.getSqlUser(GetSqlUserArgs.builder()
.name("member_user")
.databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
.build());
var exampleDatabaseRole = new DatabaseRole("exampleDatabaseRole", DatabaseRoleArgs.builder()
.databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
.ownerId(owner.applyValue(getSqlUserResult -> getSqlUserResult.id()))
.build());
var exampleDatabaseRoleMember = new DatabaseRoleMember("exampleDatabaseRoleMember", DatabaseRoleMemberArgs.builder()
.roleId(exampleDatabaseRole.id())
.memberId(member.applyValue(getSqlUserResult -> getSqlUserResult.id()))
.build());
}
}
resources:
exampleDatabaseRole:
type: mssql:DatabaseRole
properties:
databaseId: ${exampleDatabase.id}
ownerId: ${owner.id}
exampleDatabaseRoleMember:
type: mssql:DatabaseRoleMember
properties:
roleId: ${exampleDatabaseRole.id}
memberId: ${member.id}
variables:
exampleDatabase:
fn::invoke:
Function: mssql:getDatabase
Arguments:
name: example
owner:
fn::invoke:
Function: mssql:getSqlUser
Arguments:
name: example_user
databaseId: ${exampleDatabase.id}
member:
fn::invoke:
Function: mssql:getSqlUser
Arguments:
name: member_user
databaseId: ${exampleDatabase.id}
Create DatabaseRoleMember Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DatabaseRoleMember(name: string, args: DatabaseRoleMemberArgs, opts?: CustomResourceOptions);
@overload
def DatabaseRoleMember(resource_name: str,
args: DatabaseRoleMemberArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DatabaseRoleMember(resource_name: str,
opts: Optional[ResourceOptions] = None,
member_id: Optional[str] = None,
role_id: Optional[str] = None)
func NewDatabaseRoleMember(ctx *Context, name string, args DatabaseRoleMemberArgs, opts ...ResourceOption) (*DatabaseRoleMember, error)
public DatabaseRoleMember(string name, DatabaseRoleMemberArgs args, CustomResourceOptions? opts = null)
public DatabaseRoleMember(String name, DatabaseRoleMemberArgs args)
public DatabaseRoleMember(String name, DatabaseRoleMemberArgs args, CustomResourceOptions options)
type: mssql:DatabaseRoleMember
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DatabaseRoleMemberArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DatabaseRoleMemberArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DatabaseRoleMemberArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseRoleMemberArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DatabaseRoleMemberArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var databaseRoleMemberResource = new Mssql.DatabaseRoleMember("databaseRoleMemberResource", new()
{
MemberId = "string",
RoleId = "string",
});
example, err := mssql.NewDatabaseRoleMember(ctx, "databaseRoleMemberResource", &mssql.DatabaseRoleMemberArgs{
MemberId: pulumi.String("string"),
RoleId: pulumi.String("string"),
})
var databaseRoleMemberResource = new DatabaseRoleMember("databaseRoleMemberResource", DatabaseRoleMemberArgs.builder()
.memberId("string")
.roleId("string")
.build());
database_role_member_resource = mssql.DatabaseRoleMember("databaseRoleMemberResource",
member_id="string",
role_id="string")
const databaseRoleMemberResource = new mssql.DatabaseRoleMember("databaseRoleMemberResource", {
memberId: "string",
roleId: "string",
});
type: mssql:DatabaseRoleMember
properties:
memberId: string
roleId: string
DatabaseRoleMember Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The DatabaseRoleMember resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the DatabaseRoleMember resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing DatabaseRoleMember Resource
Get an existing DatabaseRoleMember resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: DatabaseRoleMemberState, opts?: CustomResourceOptions): DatabaseRoleMember
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
member_id: Optional[str] = None,
role_id: Optional[str] = None) -> DatabaseRoleMember
func GetDatabaseRoleMember(ctx *Context, name string, id IDInput, state *DatabaseRoleMemberState, opts ...ResourceOption) (*DatabaseRoleMember, error)
public static DatabaseRoleMember Get(string name, Input<string> id, DatabaseRoleMemberState? state, CustomResourceOptions? opts = null)
public static DatabaseRoleMember get(String name, Output<String> id, DatabaseRoleMemberState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
Import
import using <db_id>/<role_id> - can be retrieved using SELECT CONCAT(DB_ID(), '/', DATABASE_PRINCIPAL_ID('<role_name>'), '/', DATABASE_PRINCIPAL_ID('<member_name'))
$ pulumi import mssql:index/databaseRoleMember:DatabaseRoleMember example '7/5/9'
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- mssql pulumiverse/pulumi-mssql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
mssql
Terraform Provider.