-
Notifications
You must be signed in to change notification settings - Fork 398
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
Add resource databricks_grant
for managing singular principal
#3024
Conversation
@Jonathan-Choi FYI |
There is an issue with the current implementation that we are fixing here This will need to be adjusted here after we merged. |
Added documentation for |
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.
the content of this page would be mostly duplicated from docs/resources/grants.md, so might make sense to just collapse them in a single page, highlighting the differences
wdyt @alexott
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3024 +/- ##
========================================
Coverage 84.59% 84.60%
========================================
Files 161 162 +1
Lines 14214 14332 +118
========================================
+ Hits 12025 12126 +101
- Misses 1507 1516 +9
- Partials 682 690 +8
|
… field validation
Co-authored-by: vuong-nguyen <44292934+nkvuong@users.noreply.github.com>
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.
This seems great, thanks for addressing my points. Just one question about diffPermissionsForPrincipal, which I think was kind of written to support multiple principals but only ever acts on one; can we clean this up?
// diffPermissionsForPrincipal returns UnityCatalogPermissionsDiff of this permissions list with `diff` privileges removed | ||
func diffPermissionsForPrincipal(principal string, pl catalog.PermissionsList, existing catalog.PermissionsList) (diff []catalog.PermissionsChange) { | ||
// diffs change sets for principal | ||
configured := map[string]*schema.Set{} |
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.
Ping here
It returns an array as that's what the |
Gotcha, that makes a lot of sense. |
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.
Got clarification on the main point. Thanks!
This failed one of our nightly tests. @nkvuong could you take a look at https://github.com/databricks/eng-dev-ecosystem/actions/runs/7399425920/job/20130815184 and see if you can debug this? |
@mgyucht basically resource "databricks_grant" "metastore" {
metastore = "{env.TEST_METASTORE_ID}"
principal = "%s"
privileges = ["CREATE_STORAGE_CREDENTIAL"]
} resource "databricks_grants" "metastore" {
metastore = "{env.TEST_METASTORE_ID}"
grant {
principal = "%s"
privileges = ["CREATE_STORAGE_CREDENTIAL"]
}
} so either we need to make these 2 tests run sequentially, or remove the metastore bit for |
Ah, that makes perfect sense. Can we comment out the databricks_grant test for metastore for now to merge? we need to fix this for metastore assignment for workspaces as well, which also races between two test cases. I can fix both of these at the same time. |
Co-authored-by: vuong-nguyen <44292934+nkvuong@users.noreply.github.com>
@mgyucht done. |
@mgyucht integration tests now passed (failed tests are not related to this PR) |
All nightlies passed. Merging now! @martin-walsh thank you so much for your work on this and your patience through this process! We and our other customers really appreciate contributions like these. This is one of the biggest pain points with permission management for the provider, so you've solved a major problem with this. |
Using provider version 1.39, and it seems that
This leaves me only with the USE_CATALOG permission. |
Changes
Add resource "databricks_grant" for managing grants for a single principal on a single securable. This allows securing of resources in distributed terraform repos e.g. granting an api user SELECT on a table without wiping out centrally managed privileges such as human user access.
Opening up PR to discuss whether the approach is acceptable to you and will add documentation, and clean up if it is.
Fixes #2704
Tests
make test
run locallydocs/
folderinternal/acceptance