1. Packages
  2. Databricks
  3. API Docs
  4. SqlPermissions
Databricks v1.35.0 published on Friday, Mar 29, 2024 by Pulumi

databricks.SqlPermissions

Explore with Pulumi AI

databricks logo
Databricks v1.35.0 published on Friday, Mar 29, 2024 by Pulumi

    Example Usage

    The following resource definition will enforce access control on a table by executing the following SQL queries on a special auto-terminating cluster it would create for this operation:

    • SHOW GRANT ON TABLE `default`.`foo`
    • REVOKE ALL PRIVILEGES ON TABLE `default`.`foo` FROM ... every group and user that has access to it ...
    • GRANT MODIFY, SELECT ON TABLE `default`.`foo` TO `serge@example.com`
    • GRANT SELECT ON TABLE `default`.`foo` TO `special group`
    import * as pulumi from "@pulumi/pulumi";
    import * as databricks from "@pulumi/databricks";
    
    const fooTable = new databricks.SqlPermissions("fooTable", {
        privilegeAssignments: [
            {
                principal: "serge@example.com",
                privileges: [
                    "SELECT",
                    "MODIFY",
                ],
            },
            {
                principal: "special group",
                privileges: ["SELECT"],
            },
        ],
        table: "foo",
    });
    
    import pulumi
    import pulumi_databricks as databricks
    
    foo_table = databricks.SqlPermissions("fooTable",
        privilege_assignments=[
            databricks.SqlPermissionsPrivilegeAssignmentArgs(
                principal="serge@example.com",
                privileges=[
                    "SELECT",
                    "MODIFY",
                ],
            ),
            databricks.SqlPermissionsPrivilegeAssignmentArgs(
                principal="special group",
                privileges=["SELECT"],
            ),
        ],
        table="foo")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := databricks.NewSqlPermissions(ctx, "fooTable", &databricks.SqlPermissionsArgs{
    			PrivilegeAssignments: databricks.SqlPermissionsPrivilegeAssignmentArray{
    				&databricks.SqlPermissionsPrivilegeAssignmentArgs{
    					Principal: pulumi.String("serge@example.com"),
    					Privileges: pulumi.StringArray{
    						pulumi.String("SELECT"),
    						pulumi.String("MODIFY"),
    					},
    				},
    				&databricks.SqlPermissionsPrivilegeAssignmentArgs{
    					Principal: pulumi.String("special group"),
    					Privileges: pulumi.StringArray{
    						pulumi.String("SELECT"),
    					},
    				},
    			},
    			Table: pulumi.String("foo"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Databricks = Pulumi.Databricks;
    
    return await Deployment.RunAsync(() => 
    {
        var fooTable = new Databricks.SqlPermissions("fooTable", new()
        {
            PrivilegeAssignments = new[]
            {
                new Databricks.Inputs.SqlPermissionsPrivilegeAssignmentArgs
                {
                    Principal = "serge@example.com",
                    Privileges = new[]
                    {
                        "SELECT",
                        "MODIFY",
                    },
                },
                new Databricks.Inputs.SqlPermissionsPrivilegeAssignmentArgs
                {
                    Principal = "special group",
                    Privileges = new[]
                    {
                        "SELECT",
                    },
                },
            },
            Table = "foo",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.databricks.SqlPermissions;
    import com.pulumi.databricks.SqlPermissionsArgs;
    import com.pulumi.databricks.inputs.SqlPermissionsPrivilegeAssignmentArgs;
    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) {
            var fooTable = new SqlPermissions("fooTable", SqlPermissionsArgs.builder()        
                .privilegeAssignments(            
                    SqlPermissionsPrivilegeAssignmentArgs.builder()
                        .principal("serge@example.com")
                        .privileges(                    
                            "SELECT",
                            "MODIFY")
                        .build(),
                    SqlPermissionsPrivilegeAssignmentArgs.builder()
                        .principal("special group")
                        .privileges("SELECT")
                        .build())
                .table("foo")
                .build());
    
        }
    }
    
    resources:
      fooTable:
        type: databricks:SqlPermissions
        properties:
          privilegeAssignments:
            - principal: serge@example.com
              privileges:
                - SELECT
                - MODIFY
            - principal: special group
              privileges:
                - SELECT
          table: foo
    

    The following resources are often used in the same context:

    • End to end workspace management guide.
    • databricks.Group to manage groups in Databricks Workspace or Account Console (for AWS deployments).
    • databricks.Grants to manage data access in Unity Catalog.
    • databricks.Permissions to manage access control in Databricks workspace.
    • databricks.User to manage users, that could be added to databricks.Group within the workspace.

    Create SqlPermissions Resource

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

    Constructor syntax

    new SqlPermissions(name: string, args?: SqlPermissionsArgs, opts?: CustomResourceOptions);
    @overload
    def SqlPermissions(resource_name: str,
                       args: Optional[SqlPermissionsArgs] = None,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def SqlPermissions(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       anonymous_function: Optional[bool] = None,
                       any_file: Optional[bool] = None,
                       catalog: Optional[bool] = None,
                       cluster_id: Optional[str] = None,
                       database: Optional[str] = None,
                       privilege_assignments: Optional[Sequence[SqlPermissionsPrivilegeAssignmentArgs]] = None,
                       table: Optional[str] = None,
                       view: Optional[str] = None)
    func NewSqlPermissions(ctx *Context, name string, args *SqlPermissionsArgs, opts ...ResourceOption) (*SqlPermissions, error)
    public SqlPermissions(string name, SqlPermissionsArgs? args = null, CustomResourceOptions? opts = null)
    public SqlPermissions(String name, SqlPermissionsArgs args)
    public SqlPermissions(String name, SqlPermissionsArgs args, CustomResourceOptions options)
    
    type: databricks:SqlPermissions
    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 SqlPermissionsArgs
    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 SqlPermissionsArgs
    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 SqlPermissionsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SqlPermissionsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SqlPermissionsArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var sqlPermissionsResource = new Databricks.SqlPermissions("sqlPermissionsResource", new()
    {
        AnonymousFunction = false,
        AnyFile = false,
        Catalog = false,
        ClusterId = "string",
        Database = "string",
        PrivilegeAssignments = new[]
        {
            new Databricks.Inputs.SqlPermissionsPrivilegeAssignmentArgs
            {
                Principal = "string",
                Privileges = new[]
                {
                    "string",
                },
            },
        },
        Table = "string",
        View = "string",
    });
    
    example, err := databricks.NewSqlPermissions(ctx, "sqlPermissionsResource", &databricks.SqlPermissionsArgs{
    	AnonymousFunction: pulumi.Bool(false),
    	AnyFile:           pulumi.Bool(false),
    	Catalog:           pulumi.Bool(false),
    	ClusterId:         pulumi.String("string"),
    	Database:          pulumi.String("string"),
    	PrivilegeAssignments: databricks.SqlPermissionsPrivilegeAssignmentArray{
    		&databricks.SqlPermissionsPrivilegeAssignmentArgs{
    			Principal: pulumi.String("string"),
    			Privileges: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    		},
    	},
    	Table: pulumi.String("string"),
    	View:  pulumi.String("string"),
    })
    
    var sqlPermissionsResource = new SqlPermissions("sqlPermissionsResource", SqlPermissionsArgs.builder()        
        .anonymousFunction(false)
        .anyFile(false)
        .catalog(false)
        .clusterId("string")
        .database("string")
        .privilegeAssignments(SqlPermissionsPrivilegeAssignmentArgs.builder()
            .principal("string")
            .privileges("string")
            .build())
        .table("string")
        .view("string")
        .build());
    
    sql_permissions_resource = databricks.SqlPermissions("sqlPermissionsResource",
        anonymous_function=False,
        any_file=False,
        catalog=False,
        cluster_id="string",
        database="string",
        privilege_assignments=[databricks.SqlPermissionsPrivilegeAssignmentArgs(
            principal="string",
            privileges=["string"],
        )],
        table="string",
        view="string")
    
    const sqlPermissionsResource = new databricks.SqlPermissions("sqlPermissionsResource", {
        anonymousFunction: false,
        anyFile: false,
        catalog: false,
        clusterId: "string",
        database: "string",
        privilegeAssignments: [{
            principal: "string",
            privileges: ["string"],
        }],
        table: "string",
        view: "string",
    });
    
    type: databricks:SqlPermissions
    properties:
        anonymousFunction: false
        anyFile: false
        catalog: false
        clusterId: string
        database: string
        privilegeAssignments:
            - principal: string
              privileges:
                - string
        table: string
        view: string
    

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

    AnonymousFunction bool
    If this access control for using anonymous function. Defaults to false.
    AnyFile bool
    If this access control for reading/writing any file. Defaults to false.
    Catalog bool
    If this access control for the entire catalog. Defaults to false.
    ClusterId string
    Database string
    Name of the database. Has default value of default.
    PrivilegeAssignments List<SqlPermissionsPrivilegeAssignment>
    Table string
    Name of the table. Can be combined with database.
    View string
    Name of the view. Can be combined with database.
    AnonymousFunction bool
    If this access control for using anonymous function. Defaults to false.
    AnyFile bool
    If this access control for reading/writing any file. Defaults to false.
    Catalog bool
    If this access control for the entire catalog. Defaults to false.
    ClusterId string
    Database string
    Name of the database. Has default value of default.
    PrivilegeAssignments []SqlPermissionsPrivilegeAssignmentArgs
    Table string
    Name of the table. Can be combined with database.
    View string
    Name of the view. Can be combined with database.
    anonymousFunction Boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile Boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog Boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId String
    database String
    Name of the database. Has default value of default.
    privilegeAssignments List<SqlPermissionsPrivilegeAssignment>
    table String
    Name of the table. Can be combined with database.
    view String
    Name of the view. Can be combined with database.
    anonymousFunction boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId string
    database string
    Name of the database. Has default value of default.
    privilegeAssignments SqlPermissionsPrivilegeAssignment[]
    table string
    Name of the table. Can be combined with database.
    view string
    Name of the view. Can be combined with database.
    anonymous_function bool
    If this access control for using anonymous function. Defaults to false.
    any_file bool
    If this access control for reading/writing any file. Defaults to false.
    catalog bool
    If this access control for the entire catalog. Defaults to false.
    cluster_id str
    database str
    Name of the database. Has default value of default.
    privilege_assignments Sequence[SqlPermissionsPrivilegeAssignmentArgs]
    table str
    Name of the table. Can be combined with database.
    view str
    Name of the view. Can be combined with database.
    anonymousFunction Boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile Boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog Boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId String
    database String
    Name of the database. Has default value of default.
    privilegeAssignments List<Property Map>
    table String
    Name of the table. Can be combined with database.
    view String
    Name of the view. Can be combined with database.

    Outputs

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

    Get an existing SqlPermissions 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?: SqlPermissionsState, opts?: CustomResourceOptions): SqlPermissions
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            anonymous_function: Optional[bool] = None,
            any_file: Optional[bool] = None,
            catalog: Optional[bool] = None,
            cluster_id: Optional[str] = None,
            database: Optional[str] = None,
            privilege_assignments: Optional[Sequence[SqlPermissionsPrivilegeAssignmentArgs]] = None,
            table: Optional[str] = None,
            view: Optional[str] = None) -> SqlPermissions
    func GetSqlPermissions(ctx *Context, name string, id IDInput, state *SqlPermissionsState, opts ...ResourceOption) (*SqlPermissions, error)
    public static SqlPermissions Get(string name, Input<string> id, SqlPermissionsState? state, CustomResourceOptions? opts = null)
    public static SqlPermissions get(String name, Output<String> id, SqlPermissionsState 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:
    AnonymousFunction bool
    If this access control for using anonymous function. Defaults to false.
    AnyFile bool
    If this access control for reading/writing any file. Defaults to false.
    Catalog bool
    If this access control for the entire catalog. Defaults to false.
    ClusterId string
    Database string
    Name of the database. Has default value of default.
    PrivilegeAssignments List<SqlPermissionsPrivilegeAssignment>
    Table string
    Name of the table. Can be combined with database.
    View string
    Name of the view. Can be combined with database.
    AnonymousFunction bool
    If this access control for using anonymous function. Defaults to false.
    AnyFile bool
    If this access control for reading/writing any file. Defaults to false.
    Catalog bool
    If this access control for the entire catalog. Defaults to false.
    ClusterId string
    Database string
    Name of the database. Has default value of default.
    PrivilegeAssignments []SqlPermissionsPrivilegeAssignmentArgs
    Table string
    Name of the table. Can be combined with database.
    View string
    Name of the view. Can be combined with database.
    anonymousFunction Boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile Boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog Boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId String
    database String
    Name of the database. Has default value of default.
    privilegeAssignments List<SqlPermissionsPrivilegeAssignment>
    table String
    Name of the table. Can be combined with database.
    view String
    Name of the view. Can be combined with database.
    anonymousFunction boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId string
    database string
    Name of the database. Has default value of default.
    privilegeAssignments SqlPermissionsPrivilegeAssignment[]
    table string
    Name of the table. Can be combined with database.
    view string
    Name of the view. Can be combined with database.
    anonymous_function bool
    If this access control for using anonymous function. Defaults to false.
    any_file bool
    If this access control for reading/writing any file. Defaults to false.
    catalog bool
    If this access control for the entire catalog. Defaults to false.
    cluster_id str
    database str
    Name of the database. Has default value of default.
    privilege_assignments Sequence[SqlPermissionsPrivilegeAssignmentArgs]
    table str
    Name of the table. Can be combined with database.
    view str
    Name of the view. Can be combined with database.
    anonymousFunction Boolean
    If this access control for using anonymous function. Defaults to false.
    anyFile Boolean
    If this access control for reading/writing any file. Defaults to false.
    catalog Boolean
    If this access control for the entire catalog. Defaults to false.
    clusterId String
    database String
    Name of the database. Has default value of default.
    privilegeAssignments List<Property Map>
    table String
    Name of the table. Can be combined with database.
    view String
    Name of the view. Can be combined with database.

    Supporting Types

    SqlPermissionsPrivilegeAssignment, SqlPermissionsPrivilegeAssignmentArgs

    Principal string
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    Privileges List<string>

    set of available privilege names in upper case.

    Available privilege names are:

    Principal string
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    Privileges []string

    set of available privilege names in upper case.

    Available privilege names are:

    principal String
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    privileges List<String>

    set of available privilege names in upper case.

    Available privilege names are:

    principal string
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    privileges string[]

    set of available privilege names in upper case.

    Available privilege names are:

    principal str
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    privileges Sequence[str]

    set of available privilege names in upper case.

    Available privilege names are:

    principal String
    display_name for a databricks.Group or databricks_user, application_id for a databricks_service_principal.
    privileges List<String>

    set of available privilege names in upper case.

    Available privilege names are:

    Import

    The resource can be imported using a synthetic identifier. Examples of valid synthetic identifiers are:

    • table/default.foo - table foo in a default database. Database is always mandatory.

    • view/bar.foo - view foo in bar database.

    • database/bar - bar database.

    • catalog/ - entire catalog. / suffix is mandatory.

    • any file/ - direct access to any file. / suffix is mandatory.

    • anonymous function/ - anonymous function. / suffix is mandatory.

    bash

    $ pulumi import databricks:index/sqlPermissions:SqlPermissions foo /<object-type>/<object-name>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    databricks pulumi/pulumi-databricks
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the databricks Terraform Provider.
    databricks logo
    Databricks v1.35.0 published on Friday, Mar 29, 2024 by Pulumi