-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RESOURCE] databricks_sql_permissions to manage data object access control lists #545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good, but test is still failing
@alexott it's that SP test - started failing after ADAL updated to a more recent version. The problem is that it tries now to go and see if there's MSI endpoint available and fail otherwise. Does not really affect the normal case scenarios with Azure SP, though. Will test with |
Codecov Report
@@ Coverage Diff @@
## master #545 +/- ##
==========================================
+ Coverage 82.15% 82.53% +0.38%
==========================================
Files 78 79 +1
Lines 6786 7027 +241
==========================================
+ Hits 5575 5800 +225
- Misses 801 812 +11
- Partials 410 415 +5
|
hey @nfx does this use a shared cluster and what is the throughput of the changes? Quick question also around does parallelism cause any funky behavior when you are applying grants/denys? Typically in notebook everything is run sequentially. |
@stikkireddy it would use the shared cluster (or we can specify one as parameter). resource will work on table level, so there should be no conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick pass. Looks good!
|
* Fixed issue with putting back revoked permission * Added acceptance test * Enhanced documentation
I looked through the changes and no obvious issues jump out. Thanks for this work, @nfx! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm ;-)
subcategory: "Security"
databricks_sql_permissions Resource
-> Note This resource has an evolving API, which may change in the upcoming versions.
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
, pickAccess Control
tab, click onEnable
button inTable Access Control
section, and clickConfirm
. 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: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`
Argument Reference
The following arguments are available to specify the data object you need to enforce access controls on. You must specify only one of those arguments (except for
table
andview
), otherwise resource creation will fail.database
- Name of the database. Has default value ofdefault
.table
- Name of the table. Can be combined withdatabase
.view
- Name of the view. Can be combined withdatabase
.catalog
- (Boolean) If this access control for the entire catalog. Defaults tofalse
.any_file
- (Boolean) If this access control for reading any file. Defaults tofalse
.anonymous_function
- (Boolean) If this access control for using anonymous function. Defaults tofalse
.privilege_assignments
blocksYou must specify one or many
privilege_assignments
configuration blocks to declareprivileges
to aprincipal
, which corresponds todisplay_name
of databricks_group or databricks_user. Terraform would ensure that only those principals and privileges defined in the resource are applied for the data object and would remove anything else. It would not remove any transitive privileges.DENY
statements are intentionally not supported. Everyprivilege_assignments
has the following required arguments:principal
-display_name
of databricks_group or databricks_user.privileges
- set of available privilege names in upper case.Available privilege names are:
SELECT
- gives read access to an object.CREATE
- gives the ability to create an object (for example, a table in a database).MODIFY
- gives the ability to add, delete, and modify data to or from an object.USAGE
- do not give any abilities, but is an additional requirement to perform any action on a database object.READ_METADATA
- gives the ability to view an object and its metadata.CREATE_NAMED_FUNCTION
- gives the ability to create a named UDF in an existing catalog or database.MODIFY_CLASSPATH
- gives the ability to add files to the Spark class path.ALL PRIVILEGES
- gives all privileges (is translated into all the above privileges).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.