mssql.SchemaPermission
Explore with Pulumi AI
Grants database-level permission.
Example Usage
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 exampleSqlUser = Mssql.GetSqlUser.Invoke(new()
{
Name = "example_user",
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
});
var exampleSchema = Mssql.GetSchema.Invoke(new()
{
Name = "example_schema",
DatabaseId = exampleDatabase.Apply(getDatabaseResult => getDatabaseResult.Id),
});
var deleteToExample = new Mssql.SchemaPermission("deleteToExample", new()
{
SchemaId = exampleSchema.Apply(getSchemaResult => getSchemaResult.Id),
PrincipalId = exampleSqlUser.Apply(getSqlUserResult => getSqlUserResult.Id),
Permission = "DELETE",
});
});
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
}
exampleSchema, err := mssql.LookupSchema(ctx, &mssql.LookupSchemaArgs{
Name: pulumi.StringRef("example_schema"),
DatabaseId: pulumi.StringRef(exampleDatabase.Id),
}, nil)
if err != nil {
return err
}
_, err = mssql.NewSchemaPermission(ctx, "deleteToExample", &mssql.SchemaPermissionArgs{
SchemaId: *pulumi.String(exampleSchema.Id),
PrincipalId: *pulumi.String(exampleSqlUser.Id),
Permission: pulumi.String("DELETE"),
})
if err != nil {
return err
}
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 com.pulumi.mssql.inputs.GetSchemaArgs;
import com.pulumi.mssql.SchemaPermission;
import com.pulumi.mssql.SchemaPermissionArgs;
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 exampleSchema = MssqlFunctions.getSchema(GetSchemaArgs.builder()
.name("example_schema")
.databaseId(exampleDatabase.applyValue(getDatabaseResult -> getDatabaseResult.id()))
.build());
var deleteToExample = new SchemaPermission("deleteToExample", SchemaPermissionArgs.builder()
.schemaId(exampleSchema.applyValue(getSchemaResult -> getSchemaResult.id()))
.principalId(exampleSqlUser.applyValue(getSqlUserResult -> getSqlUserResult.id()))
.permission("DELETE")
.build());
}
}
import pulumi
import pulumi_mssql as mssql
import pulumiverse_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_schema = mssql.get_schema(name="example_schema",
database_id=example_database.id)
delete_to_example = mssql.SchemaPermission("deleteToExample",
schema_id=example_schema.id,
principal_id=example_sql_user.id,
permission="DELETE")
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 exampleSqlUser = exampleDatabase.then(exampleDatabase => mssql.getSqlUser({
name: "example_user",
databaseId: exampleDatabase.id,
}));
const exampleSchema = exampleDatabase.then(exampleDatabase => mssql.getSchema({
name: "example_schema",
databaseId: exampleDatabase.id,
}));
const deleteToExample = new mssql.SchemaPermission("deleteToExample", {
schemaId: exampleSchema.then(exampleSchema => exampleSchema.id),
principalId: exampleSqlUser.then(exampleSqlUser => exampleSqlUser.id),
permission: "DELETE",
});
resources:
deleteToExample:
type: mssql:SchemaPermission
properties:
schemaId: ${exampleSchema.id}
principalId: ${exampleSqlUser.id}
permission: DELETE
variables:
exampleDatabase:
fn::invoke:
Function: mssql:getDatabase
Arguments:
name: example
exampleSqlUser:
fn::invoke:
Function: mssql:getSqlUser
Arguments:
name: example_user
databaseId: ${exampleDatabase.id}
exampleSchema:
fn::invoke:
Function: mssql:getSchema
Arguments:
name: example_schema
databaseId: ${exampleDatabase.id}
Create SchemaPermission Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SchemaPermission(name: string, args: SchemaPermissionArgs, opts?: CustomResourceOptions);
@overload
def SchemaPermission(resource_name: str,
args: SchemaPermissionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SchemaPermission(resource_name: str,
opts: Optional[ResourceOptions] = None,
permission: Optional[str] = None,
principal_id: Optional[str] = None,
schema_id: Optional[str] = None,
with_grant_option: Optional[bool] = None)
func NewSchemaPermission(ctx *Context, name string, args SchemaPermissionArgs, opts ...ResourceOption) (*SchemaPermission, error)
public SchemaPermission(string name, SchemaPermissionArgs args, CustomResourceOptions? opts = null)
public SchemaPermission(String name, SchemaPermissionArgs args)
public SchemaPermission(String name, SchemaPermissionArgs args, CustomResourceOptions options)
type: mssql:SchemaPermission
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 SchemaPermissionArgs
- 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 SchemaPermissionArgs
- 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 SchemaPermissionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SchemaPermissionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SchemaPermissionArgs
- 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 schemaPermissionResource = new Mssql.SchemaPermission("schemaPermissionResource", new()
{
Permission = "string",
PrincipalId = "string",
SchemaId = "string",
WithGrantOption = false,
});
example, err := mssql.NewSchemaPermission(ctx, "schemaPermissionResource", &mssql.SchemaPermissionArgs{
Permission: pulumi.String("string"),
PrincipalId: pulumi.String("string"),
SchemaId: pulumi.String("string"),
WithGrantOption: pulumi.Bool(false),
})
var schemaPermissionResource = new SchemaPermission("schemaPermissionResource", SchemaPermissionArgs.builder()
.permission("string")
.principalId("string")
.schemaId("string")
.withGrantOption(false)
.build());
schema_permission_resource = mssql.SchemaPermission("schemaPermissionResource",
permission="string",
principal_id="string",
schema_id="string",
with_grant_option=False)
const schemaPermissionResource = new mssql.SchemaPermission("schemaPermissionResource", {
permission: "string",
principalId: "string",
schemaId: "string",
withGrantOption: false,
});
type: mssql:SchemaPermission
properties:
permission: string
principalId: string
schemaId: string
withGrantOption: false
SchemaPermission Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The SchemaPermission resource accepts the following input properties:
- Permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- Schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- Permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- Schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission String
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id String <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant booleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission str
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal_
id str <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema_
id str <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with_
grant_ booloption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission String
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id String <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
Outputs
All input properties are implicitly available as output properties. Additionally, the SchemaPermission 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 SchemaPermission Resource
Get an existing SchemaPermission 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?: SchemaPermissionState, opts?: CustomResourceOptions): SchemaPermission
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
permission: Optional[str] = None,
principal_id: Optional[str] = None,
schema_id: Optional[str] = None,
with_grant_option: Optional[bool] = None) -> SchemaPermission
func GetSchemaPermission(ctx *Context, name string, id IDInput, state *SchemaPermissionState, opts ...ResourceOption) (*SchemaPermission, error)
public static SchemaPermission Get(string name, Input<string> id, SchemaPermissionState? state, CustomResourceOptions? opts = null)
public static SchemaPermission get(String name, Output<String> id, SchemaPermissionState 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.
- Permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- Schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- Permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- Principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- Schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- With
Grant boolOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission String
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id String <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission string
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id string <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id string <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant booleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission str
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal_
id str <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema_
id str <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with_
grant_ booloption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
- permission String
- Name of schema SQL permission. For full list of supported permissions, see docs
- principal
Id String <database_id>/<principal_id>
. Can be retrieved usingmssql.DatabaseRole
,mssql.SqlUser
,mssql.AzureadUser
ormssql.AzureadServicePrincipal
.- schema
Id String <database_id>/<schema_id>
. Can be retrieved usingmssql.Schema
.- with
Grant BooleanOption - When set to
true
,principal_id
will be allowed to grant thepermission
to other principals. Defaults tofalse
.
Import
import using <db_id>/<schema_id>/<principal_id>/SELECT CONCAT(DB_ID(), '/', SCHEMA_ID('<schema_name>'), '/', DATABASE_PRINCIPAL_ID('<principal_name>'), '/DELETE')
$ pulumi import mssql:index/schemaPermission:SchemaPermission example '7/5/8/DELETE'
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.