Skip to content

Commit e6546fc

Browse files
authored
Removed check for creation of Azure Key Vault-based databricks_secret_scope using Service Principals (#1965)
* With Service Principals was never possible to create a Secret Scope in Databricks. It seems MSFT now fixed this issue. This commit removes the control that checks if the principal calling this is a Service Principal and throws an error. * Removed unused function kvDiffFunc
1 parent 8660c0f commit e6546fc

File tree

2 files changed

+0
-55
lines changed

2 files changed

+0
-55
lines changed

secrets/resource_secret_scope.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ func (a SecretScopesAPI) Create(s SecretScope) error {
6666
//lint:ignore ST1005 Azure is a valid capitalized string
6767
return fmt.Errorf("Azure KeyVault is not available")
6868
}
69-
if a.client.IsAzureClientSecretSet() {
70-
//lint:ignore ST1005 Azure is a valid capitalized string
71-
return fmt.Errorf("Azure KeyVault cannot yet be configured for Service Principal authorization")
72-
}
7369
req.BackendType = "AZURE_KEYVAULT"
7470
req.BackendAzureKeyvault = s.KeyvaultMetadata
7571
}
@@ -114,21 +110,6 @@ var validScope = validation.StringMatch(regexp.MustCompile(`^[\w\.@_/-]{1,128}$`
114110
"Must consist of alphanumeric characters, dashes, underscores, and periods, "+
115111
"and may not exceed 128 characters.")
116112

117-
func kvDiffFunc(ctx context.Context, diff *schema.ResourceDiff, v any) error {
118-
if diff == nil {
119-
return nil
120-
}
121-
kvLst := diff.Get("keyvault_metadata").([]any)
122-
if len(kvLst) == 0 {
123-
return nil
124-
}
125-
client := v.(*common.DatabricksClient)
126-
if client.IsAzure() && client.IsAzureClientSecretSet() {
127-
return fmt.Errorf("you can't set up Azure KeyVault-based secret scope via Service Principal")
128-
}
129-
return nil
130-
}
131-
132113
// ResourceSecretScope manages secret scopes
133114
func ResourceSecretScope() *schema.Resource {
134115
s := common.StructToSchema(SecretScope{}, func(s map[string]*schema.Schema) map[string]*schema.Schema {
@@ -161,6 +142,5 @@ func ResourceSecretScope() *schema.Resource {
161142
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
162143
return NewSecretScopesAPI(ctx, c).Delete(d.Id())
163144
},
164-
CustomizeDiff: kvDiffFunc,
165145
}.ToResource()
166146
}

secrets/resource_secret_scope_test.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package secrets
22

33
import (
4-
"context"
54
"net/http"
65
"testing"
76

@@ -302,37 +301,3 @@ func TestResourceSecretScopeDelete_Error(t *testing.T) {
302301
qa.AssertErrorStartsWith(t, err, "Internal error happened")
303302
assert.Equal(t, "abc", d.Id())
304303
}
305-
306-
func TestKVDiffFuncNil(t *testing.T) {
307-
err := kvDiffFunc(context.Background(), nil, common.DatabricksClient{Host: ""})
308-
assert.Nil(t, err)
309-
}
310-
311-
func TestKVDiffFuncSPN(t *testing.T) {
312-
qa.ResourceFixture{
313-
Fixtures: []qa.HTTPFixture{
314-
{
315-
Method: "POST",
316-
Resource: "/api/2.0/secrets/scopes/create",
317-
ExpectedRequest: secretScopeRequest{
318-
Scope: "Boom",
319-
BackendType: "AZURE_KEYVAULT",
320-
BackendAzureKeyvault: &KeyvaultMetadata{
321-
ResourceID: "bcd",
322-
DNSName: "def",
323-
},
324-
},
325-
},
326-
},
327-
Resource: ResourceSecretScope(),
328-
HCL: `
329-
name = "Boom"
330-
keyvault_metadata {
331-
resource_id = "bcd"
332-
dns_name = "def"
333-
}`,
334-
Azure: true,
335-
AzureSPN: true,
336-
Create: true,
337-
}.ExpectError(t, "you can't set up Azure KeyVault-based secret scope via Service Principal")
338-
}

0 commit comments

Comments
 (0)