Skip to content

Commit e6e847b

Browse files
authored
[Internal] Bug fixed in databricks_mws_workspaces resource due to migration of resource to Go SDK (#4652)
## Changes <!-- Summary of your changes that are easy to understand --> Reverts change in #4633 and set computed for workspace_status and vpc_status until they are fixed internally. ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> N/A - [ ] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] using Go SDK - [ ] using TF Plugin Framework
1 parent 70b688f commit e6e847b

12 files changed

+1896
-1558
lines changed

NEXT_CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features and Improvements
66

77
### Bug Fixes
8+
* Bug fixed in `databricks_mws_workspaces` resource due to migration of resource to Go SDK
89

910
### Documentation
1011

docs/resources/mws_workspaces.md

+7-11
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ The following arguments are available:
323323
* `deployment_name` - (Optional) part of URL as in `https://<prefix>-<deployment-name>.cloud.databricks.com`. Deployment name cannot be used until a deployment name prefix is defined. Please contact your Databricks representative. Once a new deployment prefix is added/updated, it only will affect the new workspaces created.
324324
* `workspace_name` - name of the workspace, will appear on UI.
325325
* `network_id` - (Optional) `network_id` from [networks](mws_networks.md).
326-
* `credentials_id` - (AWS only) ID of the workspace's credential configuration object.
327326
* `aws_region` - (AWS only) region of VPC.
328327
* `storage_configuration_id` - (AWS only)`storage_configuration_id` from [storage configuration](mws_storage_configurations.md).
329328
* `managed_services_customer_managed_key_id` - (Optional) `customer_managed_key_id` from [customer managed keys](mws_customer_managed_keys.md) with `use_cases` set to `MANAGED_SERVICES`. This is used to encrypt the workspace's notebook and secret data in the control plane.
@@ -332,9 +331,7 @@ The following arguments are available:
332331
* `cloud_resource_container` - (GCP only) A block that specifies GCP workspace configurations, consisting of following blocks:
333332
* `gcp` - A block that consists of the following field:
334333
* `project_id` - The Google Cloud project ID, which the workspace uses to instantiate cloud resources for your workspace.
335-
* `gcp_managed_network_config` - (GCP only) A block that describes the network configuration for workspaces with Databricks-managed networks.
336-
* `subnet_cidr` - The IP range from which to allocate GKE cluster nodes. No bigger than `/9` and no smaller than `/29`.
337-
* `gke_config` - (GCP only, deprecated) A block that specifies GKE configuration for the Databricks workspace:
334+
* `gke_config` - (GCP only) A block that specifies GKE configuration for the Databricks workspace:
338335
* `connectivity_type`: Specifies the network connectivity types for the GKE nodes and the GKE master network. Possible values are: `PRIVATE_NODE_PUBLIC_MASTER`, `PUBLIC_NODE_PUBLIC_MASTER`.
339336
* `master_ip_range`: The IP range from which to allocate GKE cluster master resources. This field will be ignored if GKE private cluster is not enabled. It must be exactly as big as `/28`.
340337
* `private_access_settings_id` - (Optional) Canonical unique identifier of [databricks_mws_private_access_settings](mws_private_access_settings.md) in Databricks Account.
@@ -354,25 +351,24 @@ You can specify a `token` block in the body of the workspace resource, so that T
354351

355352
On AWS, the following arguments could be modified after the workspace is running:
356353

357-
* `credentials_id`
358-
* `custom_tags`
359-
* `managed_services_customer_managed_key_id`
360354
* `network_id` - Modifying [networks on running workspaces](mws_networks.md#modifying-networks-on-running-workspaces-aws-only) would require three separate `terraform apply` steps.
361-
* `private_access_settings_id`
355+
* `credentials_id`
362356
* `storage_customer_managed_key_id`
357+
* `private_access_settings_id`
358+
* `custom_tags`
363359

364360
## Attribute Reference
365361

366362
In addition to all arguments above, the following attributes are exported:
367363

368364
* `id` - (String) Canonical unique identifier for the workspace, of the format `<account-id>/<workspace-id>`
369-
* `creation_time` - (Integer) time when workspace was created
370-
* `custom_tags` - (Map) Custom Tags (if present) added to workspace
371-
* `gcp_workspace_sa` - (String, GCP only) identifier of a service account created for the workspace in form of `db-<workspace-id>@prod-gcp-<region>.iam.gserviceaccount.com`
372365
* `workspace_id` - (String) workspace id
373366
* `workspace_status_message` - (String) updates on workspace status
374367
* `workspace_status` - (String) workspace status
368+
* `creation_time` - (Integer) time when workspace was created
375369
* `workspace_url` - (String) URL of the workspace
370+
* `custom_tags` - (Map) Custom Tags (if present) added to workspace
371+
* `gcp_workspace_sa` - (String, GCP only) identifier of a service account created for the workspace in form of `db-<workspace-id>@prod-gcp-<region>.iam.gserviceaccount.com`
376372

377373
## Timeouts
378374

internal/acceptance/expect_not_destroyed.go

-29
This file was deleted.

internal/providers/pluginfw/products/dashboards/data_dashboards_acc_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestAccDashboardsDataSource(t *testing.T) {
2727
acceptance.WorkspaceLevel(t, acceptance.Step{
2828
Template: `
2929
resource "databricks_dashboard" "dashboard" {
30-
display_name = "New Dashboard"
30+
display_name = "dashboard-{var.RANDOM}"
3131
warehouse_id = "{env.TEST_DEFAULT_WAREHOUSE_ID}"
3232
serialized_dashboard = "{\"pages\":[{\"name\":\"new_name\",\"displayName\":\"New Page\"}]}"
3333
embed_credentials = false // Optional

internal/service/provisioning_tf/legacy_model.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mws/data_mws_workspaces.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ func DataSourceMwsWorkspaces() common.Resource {
1616
if c.Config.AccountID == "" {
1717
return fmt.Errorf("provider block is missing `account_id` property")
1818
}
19-
a, err := c.AccountClient()
20-
if err != nil {
21-
return err
22-
}
23-
workspaces, err := a.Workspaces.List(ctx)
19+
workspaces, err := NewWorkspacesAPI(ctx, c).List(c.Config.AccountID)
2420
if err != nil {
2521
return err
2622
}
2723
data.Ids = map[string]int64{}
2824
for _, v := range workspaces {
29-
data.Ids[v.WorkspaceName] = v.WorkspaceId
25+
data.Ids[v.WorkspaceName] = v.WorkspaceID
3026
}
3127
return nil
3228
})

mws/data_mws_workspaces_test.go

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
package mws
22

33
import (
4-
"errors"
54
"testing"
65

7-
"github.com/databricks/databricks-sdk-go/experimental/mocks"
8-
"github.com/databricks/databricks-sdk-go/service/provisioning"
96
"github.com/databricks/terraform-provider-databricks/qa"
10-
"github.com/stretchr/testify/mock"
117
)
128

139
func TestDataSourceMwsWorkspaces(t *testing.T) {
1410
qa.ResourceFixture{
15-
MockAccountClientFunc: func(a *mocks.MockAccountClient) {
16-
a.GetMockWorkspacesAPI().EXPECT().List(mock.Anything).Return([]provisioning.Workspace{
17-
{
18-
WorkspaceName: "bcd",
19-
WorkspaceId: 123,
20-
},
21-
{
22-
WorkspaceName: "def",
23-
WorkspaceId: 456,
11+
Fixtures: []qa.HTTPFixture{
12+
{
13+
Method: "GET",
14+
Resource: "/api/2.0/accounts/abc/workspaces",
15+
16+
Response: []Workspace{
17+
{
18+
WorkspaceName: "bcd",
19+
WorkspaceID: 123,
20+
},
21+
{
22+
WorkspaceName: "def",
23+
WorkspaceID: 456,
24+
},
2425
},
25-
}, nil)
26+
},
2627
},
2728
AccountID: "abc",
2829
Resource: DataSourceMwsWorkspaces(),
@@ -37,12 +38,10 @@ func TestDataSourceMwsWorkspaces(t *testing.T) {
3738
})
3839
}
3940

40-
func TestDataSourceMwsWorkspaces_Error(t *testing.T) {
41+
func TestCatalogsData_Error(t *testing.T) {
4142
qa.ResourceFixture{
42-
MockAccountClientFunc: func(a *mocks.MockAccountClient) {
43-
a.GetMockWorkspacesAPI().EXPECT().List(mock.Anything).Return(nil, errors.New("i'm a teapot"))
44-
},
4543
AccountID: "abc",
44+
Fixtures: qa.HTTPFailures,
4645
Resource: DataSourceMwsWorkspaces(),
4746
Read: true,
4847
NonWritable: true,
@@ -52,8 +51,13 @@ func TestDataSourceMwsWorkspaces_Error(t *testing.T) {
5251

5352
func TestDataSourceMwsWorkspaces_Empty(t *testing.T) {
5453
qa.ResourceFixture{
55-
MockAccountClientFunc: func(a *mocks.MockAccountClient) {
56-
a.GetMockWorkspacesAPI().EXPECT().List(mock.Anything).Return([]provisioning.Workspace{}, nil)
54+
Fixtures: []qa.HTTPFixture{
55+
{
56+
Method: "GET",
57+
Resource: "/api/2.0/accounts/abc/workspaces",
58+
59+
Response: []Workspace{},
60+
},
5761
},
5862
AccountID: "abc",
5963
Resource: DataSourceMwsWorkspaces(),

0 commit comments

Comments
 (0)