databricks.SqlPermissions
Explore with Pulumi AI
Please switch to databricks.Grants with Unity Catalog to manage data access, which provides a better and faster way for managing data security.
databricks.Grants
resource doesn’t require a technical cluster to perform operations. On workspaces with Unity Catalog enabled, you may run into errors such asError: cannot create sql permissions: cannot read current grants: For unity catalog, please specify the catalog name explicitly. E.g. SHOW GRANT ``your.address@email.com`` ON CATALOG main
. This happens if yourdefault_catalog_name
was set to a UC catalog instead ofhive_metastore
. The workaround is to re-assign the metastore again with the default catalog set to behive_metastore
. See databricks_metastore_assignment.
This resource manages data object access control lists in Databricks workspaces for things like tables, views, databases, and more. In order to enable Table Access control, you have to login to the workspace as administrator, go to Admin Console
, pick Access Control
tab, click on Enable
button in Table Access Control
section, and click Confirm
. The security guarantees of table access control will only be effective if cluster access control is also turned on. Please make sure that no users can create clusters in your workspace and all databricks.Cluster have approximately the following configuration:
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
const clusterWithTableAccessControl = new databricks.Cluster("cluster_with_table_access_control", {sparkConf: {
"spark.databricks.acl.dfAclsEnabled": "true",
"spark.databricks.repl.allowedLanguages": "python,sql",
}});
import pulumi
import pulumi_databricks as databricks
cluster_with_table_access_control = databricks.Cluster("cluster_with_table_access_control", spark_conf={
"spark.databricks.acl.dfAclsEnabled": "true",
"spark.databricks.repl.allowedLanguages": "python,sql",
})
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.NewCluster(ctx, "cluster_with_table_access_control", &databricks.ClusterArgs{
SparkConf: pulumi.StringMap{
"spark.databricks.acl.dfAclsEnabled": pulumi.String("true"),
"spark.databricks.repl.allowedLanguages": pulumi.String("python,sql"),
},
})
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 clusterWithTableAccessControl = new Databricks.Cluster("cluster_with_table_access_control", new()
{
SparkConf =
{
{ "spark.databricks.acl.dfAclsEnabled", "true" },
{ "spark.databricks.repl.allowedLanguages", "python,sql" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.Cluster;
import com.pulumi.databricks.ClusterArgs;
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 clusterWithTableAccessControl = new Cluster("clusterWithTableAccessControl", ClusterArgs.builder()
.sparkConf(Map.ofEntries(
Map.entry("spark.databricks.acl.dfAclsEnabled", "true"),
Map.entry("spark.databricks.repl.allowedLanguages", "python,sql")
))
.build());
}
}
resources:
clusterWithTableAccessControl:
type: databricks:Cluster
name: cluster_with_table_access_control
properties:
sparkConf:
spark.databricks.acl.dfAclsEnabled: 'true'
spark.databricks.repl.allowedLanguages: python,sql
It is required to define all permissions for a securable in a single resource, otherwise Pulumi cannot guarantee config drift prevention.
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("foo_table", {
table: "foo",
privilegeAssignments: [
{
principal: "serge@example.com",
privileges: [
"SELECT",
"MODIFY",
],
},
{
principal: "special group",
privileges: ["SELECT"],
},
],
});
import pulumi
import pulumi_databricks as databricks
foo_table = databricks.SqlPermissions("foo_table",
table="foo",
privilege_assignments=[
{
"principal": "serge@example.com",
"privileges": [
"SELECT",
"MODIFY",
],
},
{
"principal": "special group",
"privileges": ["SELECT"],
},
])
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, "foo_table", &databricks.SqlPermissionsArgs{
Table: pulumi.String("foo"),
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"),
},
},
},
})
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("foo_table", new()
{
Table = "foo",
PrivilegeAssignments = new[]
{
new Databricks.Inputs.SqlPermissionsPrivilegeAssignmentArgs
{
Principal = "serge@example.com",
Privileges = new[]
{
"SELECT",
"MODIFY",
},
},
new Databricks.Inputs.SqlPermissionsPrivilegeAssignmentArgs
{
Principal = "special group",
Privileges = new[]
{
"SELECT",
},
},
},
});
});
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()
.table("foo")
.privilegeAssignments(
SqlPermissionsPrivilegeAssignmentArgs.builder()
.principal("serge@example.com")
.privileges(
"SELECT",
"MODIFY")
.build(),
SqlPermissionsPrivilegeAssignmentArgs.builder()
.principal("special group")
.privileges("SELECT")
.build())
.build());
}
}
resources:
fooTable:
type: databricks:SqlPermissions
name: foo_table
properties:
table: foo
privilegeAssignments:
- principal: serge@example.com
privileges:
- SELECT
- MODIFY
- principal: special group
privileges:
- SELECT
Related Resources
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.
Constructor 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=[{
"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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The SqlPermissions resource accepts the following input properties:
- 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 string - Database string
- Name of the database. Has default value of
default
. - Privilege
Assignments List<SqlPermissions Privilege Assignment> - 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 string - Database string
- Name of the database. Has default value of
default
. - Privilege
Assignments []SqlPermissions Privilege Assignment Args - Table string
- Name of the table. Can be combined with
database
. - View string
- Name of the view. Can be combined with
database
.
- anonymous
Function Boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id String - database String
- Name of the database. Has default value of
default
. - privilege
Assignments List<SqlPermissions Privilege Assignment> - table String
- Name of the table. Can be combined with
database
. - view String
- Name of the view. Can be combined with
database
.
- anonymous
Function boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id string - database string
- Name of the database. Has default value of
default
. - privilege
Assignments SqlPermissions Privilege Assignment[] - 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[SqlPermissions Privilege Assignment Args] - table str
- Name of the table. Can be combined with
database
. - view str
- Name of the view. Can be combined with
database
.
- anonymous
Function Boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id String - database String
- Name of the database. Has default value of
default
. - privilege
Assignments 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.
- 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 string - Database string
- Name of the database. Has default value of
default
. - Privilege
Assignments List<SqlPermissions Privilege Assignment> - 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 string - Database string
- Name of the database. Has default value of
default
. - Privilege
Assignments []SqlPermissions Privilege Assignment Args - Table string
- Name of the table. Can be combined with
database
. - View string
- Name of the view. Can be combined with
database
.
- anonymous
Function Boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id String - database String
- Name of the database. Has default value of
default
. - privilege
Assignments List<SqlPermissions Privilege Assignment> - table String
- Name of the table. Can be combined with
database
. - view String
- Name of the view. Can be combined with
database
.
- anonymous
Function boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id string - database string
- Name of the database. Has default value of
default
. - privilege
Assignments SqlPermissions Privilege Assignment[] - 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[SqlPermissions Privilege Assignment Args] - table str
- Name of the table. Can be combined with
database
. - view str
- Name of the view. Can be combined with
database
.
- anonymous
Function Boolean - If this access control for using anonymous function. Defaults to
false
. - any
File 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
. - cluster
Id String - database String
- Name of the database. Has default value of
default
. - privilege
Assignments 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>
- Principal string
display_name
for a databricks.Group or databricks_user,application_id
for a databricks_service_principal.- Privileges []string
- principal String
display_name
for a databricks.Group or databricks_user,application_id
for a databricks_service_principal.- privileges List<String>
- principal string
display_name
for a databricks.Group or databricks_user,application_id
for a databricks_service_principal.- privileges string[]
- principal str
display_name
for a databricks.Group or databricks_user,application_id
for a databricks_service_principal.- privileges Sequence[str]
- principal String
display_name
for a databricks.Group or databricks_user,application_id
for a databricks_service_principal.- privileges List<String>
Import
The resource can be imported using a synthetic identifier. Examples of valid synthetic identifiers are:
table/default.foo
- tablefoo
in adefault
database. Database is always mandatory.view/bar.foo
- viewfoo
inbar
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.