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

[WIP] Upgrade databricks api the latest 2021-04-01-preview version #12284

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azurerm/internal/services/databricks/client/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/databricks/mgmt/2018-04-01/databricks"
"github.com/Azure/azure-sdk-for-go/services/preview/databricks/mgmt/2021-04-01-preview/databricks"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/databricks/mgmt/2018-04-01/databricks"
"github.com/Azure/azure-sdk-for-go/services/preview/databricks/mgmt/2021-04-01-preview/databricks"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/locks"
Expand Down Expand Up @@ -148,7 +148,7 @@ func DatabricksWorkspaceCustomerManagedKeyCreateUpdate(d *pluginsdk.ResourceData
params := workspace.Parameters
params.Encryption = &databricks.WorkspaceEncryptionParameter{
Value: &databricks.Encryption{
KeySource: databricks.MicrosoftKeyvault,
KeySource: databricks.KeySourceMicrosoftKeyvault,
KeyName: &key.Name,
KeyVersion: &key.Version,
KeyVaultURI: &key.KeyVaultBaseUrl,
Expand Down Expand Up @@ -229,7 +229,7 @@ func DatabricksWorkspaceCustomerManagedKeyRead(d *pluginsdk.ResourceData, meta i
// return fmt.Errorf("retrieving Databricks Workspace %q (Resource Group %q): `Workspace.WorkspaceProperties.Encryption.Value.KeySource` was expected to be %q, got %q", id.CustomerMangagedKeyName, id.ResourceGroup, string(databricks.MicrosoftKeyvault), keySource)
// }

if strings.EqualFold(keySource, string(databricks.MicrosoftKeyvault)) && (keyName == "" || keyVersion == "" || keyVaultURI == "") {
if strings.EqualFold(keySource, string(databricks.KeySourceMicrosoftKeyvault)) && (keyName == "" || keyVersion == "" || keyVaultURI == "") {
return fmt.Errorf("Databricks Workspace %q (Resource Group %q): `Workspace.WorkspaceProperties.Encryption.Value(s)` were nil", id.CustomerMangagedKeyName, id.ResourceGroup)
}

Expand Down Expand Up @@ -282,7 +282,7 @@ func DatabricksWorkspaceCustomerManagedKeyDelete(d *pluginsdk.ResourceData, meta
params := workspace.Parameters
params.Encryption = &databricks.WorkspaceEncryptionParameter{
Value: &databricks.Encryption{
KeySource: databricks.Default,
KeySource: databricks.KeySourceDefault,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/Azure/azure-sdk-for-go/services/databricks/mgmt/2018-04-01/databricks"
"github.com/Azure/azure-sdk-for-go/services/preview/databricks/mgmt/2021-04-01-preview/databricks"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance/check"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
Expand Down Expand Up @@ -117,7 +117,7 @@ func (DatabricksWorkspaceCustomerManagedKeyResource) Exists(ctx context.Context,

// This is the only way we can tell if the CMK has actually been provisioned or not...
if resp.WorkspaceProperties.Parameters != nil && resp.WorkspaceProperties.Parameters.Encryption != nil {
if resp.WorkspaceProperties.Parameters.Encryption.Value.KeySource == databricks.MicrosoftKeyvault {
if resp.WorkspaceProperties.Parameters.Encryption.Value.KeySource == databricks.KeySourceMicrosoftKeyvault {
return utils.Bool(true), nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/databricks/mgmt/2018-04-01/databricks"
"github.com/Azure/azure-sdk-for-go/services/preview/databricks/mgmt/2021-04-01-preview/databricks"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
Expand Down Expand Up @@ -114,13 +114,27 @@ func resourceDatabricksWorkspace() *pluginsdk.Resource {
AtLeastOneOf: workspaceCustomParametersString(),
},

"public_subnet_network_security_group_association_id": {
Type: pluginsdk.TypeString,
ForceNew: true,
Optional: true,
AtLeastOneOf: workspaceCustomParametersString(),
},

"private_subnet_name": {
Type: pluginsdk.TypeString,
ForceNew: true,
Optional: true,
AtLeastOneOf: workspaceCustomParametersString(),
},

"private_subnet_network_security_group_association_id": {
Type: pluginsdk.TypeString,
ForceNew: true,
Optional: true,
AtLeastOneOf: workspaceCustomParametersString(),
},

"virtual_network_id": {
Type: pluginsdk.TypeString,
ForceNew: true,
Expand Down Expand Up @@ -178,6 +192,18 @@ func resourceDatabricksWorkspace() *pluginsdk.Resource {
_, infrastructureEncryptionEnabled := d.GetChange("infrastructure_encryption_enabled")
oldSku, newSku := d.GetChange("sku")

_, customParamsRaw := d.GetChange("custom_parameters")
if customParamsRaw != nil {
customParams := expandWorkspaceCustomParameters(customParamsRaw.([]interface{}), customerEncryptionEnabled.(bool), infrastructureEncryptionEnabled.(bool))

if customParams.CustomVirtualNetworkID != nil && (customParams.CustomPrivateSubnetName == nil || customParams.CustomPublicSubnetName == nil) {
return fmt.Errorf("'public_subnet_name' and 'private_subnet_name' must both have values if 'virtual_network_id' is set")
}
if customParams.CustomVirtualNetworkID == nil && (customParams.CustomPrivateSubnetName != nil || customParams.CustomPublicSubnetName != nil) {
return fmt.Errorf("'virtual_network_id' must have a value if 'public_subnet_name' and/or 'private_subnet_name' are set")
}
}

if d.HasChange("sku") {
if newSku == "trial" {
log.Printf("[DEBUG] recreate databricks workspace, cannot be migrated to %s", newSku)
Expand Down Expand Up @@ -510,5 +536,6 @@ func expandWorkspaceCustomParameters(input []interface{}, customerManagedKeyEnab

func workspaceCustomParametersString() []string {
return []string{"custom_parameters.0.machine_learning_workspace_id", "custom_parameters.0.no_public_ip",
"custom_parameters.0.public_subnet_name", "custom_parameters.0.private_subnet_name", "custom_parameters.0.virtual_network_id"}
"custom_parameters.0.public_subnet_name", "custom_parameters.0.private_subnet_name", "custom_parameters.0.virtual_network_id",
"custom_parameters.0.public_subnet_network_security_group_association_id", "custom_parameters.0.private_subnet_network_security_group_association_id"}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading