Skip to content
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

Added databricks_service_principal and databricks_service_principals data resources #1370

Merged
merged 6 commits into from
Jun 10, 2022

Conversation

nkvuong
Copy link
Contributor

@nkvuong nkvuong commented Jun 9, 2022

This continues and closes #1207

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #1370 (5d837f5) into master (aa03042) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1370      +/-   ##
==========================================
+ Coverage   90.10%   90.14%   +0.04%     
==========================================
  Files         122      124       +2     
  Lines       10127    10172      +45     
==========================================
+ Hits         9125     9170      +45     
  Misses        638      638              
  Partials      364      364              
Impacted Files Coverage Δ
provider/provider.go 94.96% <100.00%> (+0.07%) ⬆️
scim/data_service_principal.go 100.00% <100.00%> (ø)
scim/data_service_principals.go 100.00% <100.00%> (ø)
scim/data_user.go 96.87% <100.00%> (+0.26%) ⬆️

docs/data-sources/service_principal.md Show resolved Hide resolved
docs/data-sources/service_principals.md Outdated Show resolved Hide resolved
scim/data_service_principal.go Show resolved Hide resolved
scim/data_service_principal.go Outdated Show resolved Hide resolved
}
return common.DataResource(spnsData{}, func(ctx context.Context, e interface{}, c *common.DatabricksClient) error {
response := e.(*spnsData)
spnAPI := NewServicePrincipalsAPI(ctx, c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful for looking up spns either created outside of Terraform, or in another Terraform config - application_id or id are less friendly

scim/data_service_principal.go Outdated Show resolved Hide resolved
@@ -71,6 +75,7 @@ func DataSourceUser() *schema.Resource {
d.Set("home", fmt.Sprintf("/Users/%s", user.UserName))
d.Set("repos", fmt.Sprintf("/Repos/%s", user.UserName))
d.Set("external_id", user.ExternalID)
d.Set("application_id", user.ApplicationID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if databricks_current_user is a Service Principal, return the application_id as well

scim/data_user.go Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎊

@nfx nfx changed the title Add data source for service principals Added databricks_service_principal and databricks_service_principals data resources Jun 10, 2022
@nfx nfx merged commit a121b39 into databricks:master Jun 10, 2022
@nkvuong nkvuong deleted the add-spn-data-source branch June 10, 2022 16:19
@nfx nfx mentioned this pull request Jun 16, 2022
michael-berk pushed a commit to michael-berk/terraform-provider-databricks that referenced this pull request Feb 15, 2023
…ls` data resources (databricks#1370)

* return `application_id` from `databricks_current_user` if that user is a Service Principal
* add `databricks_service_principal` data source based on `application_id`
* add `databricks_service_principals` data source based on `display_name`

Co-authored-by: Ron DeFreitas <drax3d@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add data source for SPNs and identify if current user is a SPN
3 participants