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

mssql.ServerPermission

Explore with Pulumi AI

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

    Grants server-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 example = Mssql.GetSqlLogin.Invoke(new()
        {
            Name = "example_login",
        });
    
        var connectToExample = new Mssql.ServerPermission("connectToExample", new()
        {
            PrincipalId = example.Apply(getSqlLoginResult => getSqlLoginResult.PrincipalId),
            Permission = "CONNECT SQL",
            WithGrantOption = true,
        });
    
    });
    
    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 {
    		example, err := mssql.LookupSqlLogin(ctx, &mssql.LookupSqlLoginArgs{
    			Name: "example_login",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = mssql.NewServerPermission(ctx, "connectToExample", &mssql.ServerPermissionArgs{
    			PrincipalId:     *pulumi.String(example.PrincipalId),
    			Permission:      pulumi.String("CONNECT SQL"),
    			WithGrantOption: pulumi.Bool(true),
    		})
    		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.GetSqlLoginArgs;
    import com.pulumi.mssql.ServerPermission;
    import com.pulumi.mssql.ServerPermissionArgs;
    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 example = MssqlFunctions.getSqlLogin(GetSqlLoginArgs.builder()
                .name("example_login")
                .build());
    
            var connectToExample = new ServerPermission("connectToExample", ServerPermissionArgs.builder()        
                .principalId(example.applyValue(getSqlLoginResult -> getSqlLoginResult.principalId()))
                .permission("CONNECT SQL")
                .withGrantOption(true)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_mssql as mssql
    import pulumiverse_mssql as mssql
    
    example = mssql.get_sql_login(name="example_login")
    connect_to_example = mssql.ServerPermission("connectToExample",
        principal_id=example.principal_id,
        permission="CONNECT SQL",
        with_grant_option=True)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as mssql from "@pulumi/mssql";
    import * as mssql from "@pulumiverse/mssql";
    
    const example = mssql.getSqlLogin({
        name: "example_login",
    });
    const connectToExample = new mssql.ServerPermission("connectToExample", {
        principalId: example.then(example => example.principalId),
        permission: "CONNECT SQL",
        withGrantOption: true,
    });
    
    resources:
      connectToExample:
        type: mssql:ServerPermission
        properties:
          principalId: ${example.principalId}
          permission: CONNECT SQL
          withGrantOption: true
    variables:
      example:
        fn::invoke:
          Function: mssql:getSqlLogin
          Arguments:
            name: example_login
    

    Create ServerPermission Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ServerPermission(name: string, args: ServerPermissionArgs, opts?: CustomResourceOptions);
    @overload
    def ServerPermission(resource_name: str,
                         args: ServerPermissionArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def ServerPermission(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         permission: Optional[str] = None,
                         principal_id: Optional[str] = None,
                         with_grant_option: Optional[bool] = None)
    func NewServerPermission(ctx *Context, name string, args ServerPermissionArgs, opts ...ResourceOption) (*ServerPermission, error)
    public ServerPermission(string name, ServerPermissionArgs args, CustomResourceOptions? opts = null)
    public ServerPermission(String name, ServerPermissionArgs args)
    public ServerPermission(String name, ServerPermissionArgs args, CustomResourceOptions options)
    
    type: mssql:ServerPermission
    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 ServerPermissionArgs
    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 ServerPermissionArgs
    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 ServerPermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServerPermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServerPermissionArgs
    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 serverPermissionResource = new Mssql.ServerPermission("serverPermissionResource", new()
    {
        Permission = "string",
        PrincipalId = "string",
        WithGrantOption = false,
    });
    
    example, err := mssql.NewServerPermission(ctx, "serverPermissionResource", &mssql.ServerPermissionArgs{
    	Permission:      pulumi.String("string"),
    	PrincipalId:     pulumi.String("string"),
    	WithGrantOption: pulumi.Bool(false),
    })
    
    var serverPermissionResource = new ServerPermission("serverPermissionResource", ServerPermissionArgs.builder()
        .permission("string")
        .principalId("string")
        .withGrantOption(false)
        .build());
    
    server_permission_resource = mssql.ServerPermission("serverPermissionResource",
        permission="string",
        principal_id="string",
        with_grant_option=False)
    
    const serverPermissionResource = new mssql.ServerPermission("serverPermissionResource", {
        permission: "string",
        principalId: "string",
        withGrantOption: false,
    });
    
    type: mssql:ServerPermission
    properties:
        permission: string
        principalId: string
        withGrantOption: false
    

    ServerPermission 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 ServerPermission resource accepts the following input properties:

    Permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    Permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission String
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission str
    Name of server-level SQL permission. For full list of supported permissions see docs
    principal_id str
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    with_grant_option bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission String
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ServerPermission 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 ServerPermission Resource

    Get an existing ServerPermission 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?: ServerPermissionState, opts?: CustomResourceOptions): ServerPermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            permission: Optional[str] = None,
            principal_id: Optional[str] = None,
            with_grant_option: Optional[bool] = None) -> ServerPermission
    func GetServerPermission(ctx *Context, name string, id IDInput, state *ServerPermissionState, opts ...ResourceOption) (*ServerPermission, error)
    public static ServerPermission Get(string name, Input<string> id, ServerPermissionState? state, CustomResourceOptions? opts = null)
    public static ServerPermission get(String name, Output<String> id, ServerPermissionState 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.
    The following state arguments are supported:
    Permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    Permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    PrincipalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    WithGrantOption bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission String
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission string
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId string
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission str
    Name of server-level SQL permission. For full list of supported permissions see docs
    principal_id str
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    with_grant_option bool
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false
    permission String
    Name of server-level SQL permission. For full list of supported permissions see docs
    principalId String
    ID of the principal who will be granted permission. Can be retrieved using mssql.ServerRole or mssql.SqlLogin.
    withGrantOption Boolean
    When set to true, principal_id will be allowed to grant the permission to other principals. Defaults to false

    Import

    import using <principal_id>/

     $ pulumi import mssql:index/serverPermission:ServerPermission example '7/CONNECT SQL'
    

    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.
    mssql logo
    Microsoft SQL Server v0.0.8 published on Wednesday, Nov 1, 2023 by pulumiverse