Skip to content

Commit 8c0a19e

Browse files
authored
Remove validation for SPN resource for application_id on Azure (#1171)
Remove client-side validation in `databricks_service_principal` for `application_id`, that may not always be available in the planning stage. Fixes #1165
1 parent 21c4f06 commit 8c0a19e

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.5.3
44

55
* Failures in [exporter](https://asciinema.org/a/Rv8ZFJQpfrfp6ggWddjtyXaOy) resource listing no longer halt the entire command run ([#1166](https://github.com/databrickslabs/terraform-provider-databricks/issues/1166)).
6+
* Removed client-side validation in `databricks_service_principal` for `application_id`, that may not always be available in the planning stage ([#1165](https://github.com/databrickslabs/terraform-provider-databricks/issues/1165)).
67

78
Updated dependency versions:
89

scim/resource_service_principal.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,16 @@ func ResourceServicePrincipal() *schema.Resource {
8585
var sp entity
8686
common.DiffToStructPointer(d, servicePrincipalSchema, &sp)
8787
client := c.(*common.DatabricksClient)
88-
if client.IsAzure() && sp.ApplicationID == "" {
89-
// TODO: verify cases for non-existing resources
90-
return fmt.Errorf("application_id is required for service principals in Azure Databricks")
91-
}
9288
if client.IsAws() && sp.DisplayName == "" {
9389
return fmt.Errorf("display_name is required for service principals in Databricks on AWS")
9490
}
91+
if client.IsAws() && sp.ApplicationID != "" {
92+
return fmt.Errorf("application_id is not allowed for service principals in Databricks on AWS")
93+
}
9594
return nil
9695
},
9796
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
9897
sp := spFromData(d)
99-
if c.IsAws() && sp.ApplicationID != "" {
100-
return fmt.Errorf("application_id is not allowed for service principals in Databricks on AWS")
101-
}
10298
servicePrincipal, err := NewServicePrincipalsAPI(ctx, c).Create(sp)
10399
if err != nil {
104100
return err

scim/resource_service_principal_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ func TestResourceServicePrincipalRead_NotFound(t *testing.T) {
102102
}.ApplyNoError(t)
103103
}
104104

105-
func TestResourceServicePrincipalRead_Invalid_Azure(t *testing.T) {
106-
qa.ResourceFixture{
107-
Resource: ResourceServicePrincipal(),
108-
New: true,
109-
Read: true,
110-
Azure: true,
111-
ID: "abc",
112-
}.ExpectError(t, "application_id is required for service principals in Azure Databricks")
113-
}
114-
115105
func TestResourceServicePrincipalRead_Invalid_AWS(t *testing.T) {
116106
qa.ResourceFixture{
117107
Resource: ResourceServicePrincipal(),
@@ -219,17 +209,6 @@ func TestResourceServicePrincipalCreate_Error(t *testing.T) {
219209
require.Error(t, err, err)
220210
}
221211

222-
func TestResourceServicePrincipalCreate_Error_AzureNoApplicationID(t *testing.T) {
223-
qa.ResourceFixture{
224-
Resource: ResourceServicePrincipal(),
225-
Create: true,
226-
Azure: true,
227-
HCL: `
228-
display_name = "abc"
229-
`,
230-
}.ExpectError(t, "application_id is required for service principals in Azure Databricks")
231-
}
232-
233212
func TestResourceServicePrincipalUpdate(t *testing.T) {
234213
newServicePrincipal := User{
235214
Schemas: []URN{ServicePrincipalSchema},

0 commit comments

Comments
 (0)