Skip to content

Commit 74685dc

Browse files
committed
some fixes
1 parent cebb9f3 commit 74685dc

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

docs/resources/mws_workspaces.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ 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.
326327
* `aws_region` - (AWS only) region of VPC.
327328
* `storage_configuration_id` - (AWS only)`storage_configuration_id` from [storage configuration](mws_storage_configurations.md).
328329
* `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.
@@ -331,7 +332,9 @@ The following arguments are available:
331332
* `cloud_resource_container` - (GCP only) A block that specifies GCP workspace configurations, consisting of following blocks:
332333
* `gcp` - A block that consists of the following field:
333334
* `project_id` - The Google Cloud project ID, which the workspace uses to instantiate cloud resources for your workspace.
334-
* `gke_config` - (GCP only) A block that specifies GKE configuration for the Databricks 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:
335338
* `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`.
336339
* `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`.
337340
* `private_access_settings_id` - (Optional) Canonical unique identifier of [databricks_mws_private_access_settings](mws_private_access_settings.md) in Databricks Account.
@@ -351,24 +354,25 @@ You can specify a `token` block in the body of the workspace resource, so that T
351354

352355
On AWS, the following arguments could be modified after the workspace is running:
353356

354-
* `network_id` - Modifying [networks on running workspaces](mws_networks.md#modifying-networks-on-running-workspaces-aws-only) would require three separate `terraform apply` steps.
355357
* `credentials_id`
356-
* `storage_customer_managed_key_id`
357-
* `private_access_settings_id`
358358
* `custom_tags`
359+
* `managed_services_customer_managed_key_id`
360+
* `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`
362+
* `storage_customer_managed_key_id`
359363

360364
## Attribute Reference
361365

362366
In addition to all arguments above, the following attributes are exported:
363367

364368
* `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`
365372
* `workspace_id` - (String) workspace id
366373
* `workspace_status_message` - (String) updates on workspace status
367374
* `workspace_status` - (String) workspace status
368-
* `creation_time` - (Integer) time when workspace was created
369375
* `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`
372376

373377
## Timeouts
374378

mws/resource_mws_workspaces.go

+22-15
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ import (
2828
// this may help with local DNS cache issues.
2929
const DefaultProvisionTimeout = 20 * time.Minute
3030

31-
// Workspace is the object that contains all the information for deploying a workspace
32-
type Workspace struct {
31+
// workspaceReachableRequestTimeout is the amount of seconds to wait when polling the
32+
// newly created workspace's SCIM Me endpoint to check if the workspace is reachable.
33+
const workspaceReachableRequestTimeout = 10 * time.Second
34+
35+
// workspace is the object that contains all the information for deploying a workspace
36+
type workspace struct {
3337
provisioning.Workspace
3438
CustomerManagedKeyID string `json:"customer_managed_key_id,omitempty"` // just for compatibility, will be removed
3539
GcpWorkspaceSa string `json:"gcp_workspace_sa" tf:"computed"`
@@ -49,7 +53,7 @@ func verifyWorkspaceReachable(ctx context.Context, w *databricks.WorkspaceClient
4953
}
5054
return false
5155
})).Wait(ctx, func(ctx context.Context) error {
52-
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
56+
ctx, cancel := context.WithTimeout(ctx, workspaceReachableRequestTimeout)
5357
defer cancel()
5458
_, err := w.CurrentUser.Me(ctx)
5559
return err
@@ -154,27 +158,27 @@ func removeToken(ctx context.Context, w *databricks.WorkspaceClient, tokenID str
154158
// ResourceMwsWorkspaces manages E2 workspaces
155159
func ResourceMwsWorkspaces() common.Resource {
156160
var computedFields = map[string]struct{}{
157-
"cloud": {},
158-
"workspace_id": {},
159-
"workspace_url": {},
160-
"workspace_status": {},
161-
"workspace_status_message": {},
161+
"azure_workspace_info": {},
162162
"creation_time": {},
163163
"gke_config": {},
164164
"pricing_tier": {},
165+
"workspace_id": {},
166+
"workspace_status": {},
167+
"workspace_status_message": {},
168+
"workspace_url": {},
165169
}
166170

167171
var workspaceRunningUpdatesAllowed = map[string]struct{}{
168172
"credentials_id": {},
173+
"custom_tags": {},
174+
"managed_services_customer_managed_key_id": {},
169175
"network_id": {},
170-
"storage_customer_managed_key_id": {},
171176
"private_access_settings_id": {},
172-
"managed_services_customer_managed_key_id": {},
173-
"custom_tags": {},
177+
"storage_customer_managed_key_id": {},
174178
"token": {},
175179
}
176180

177-
workspaceSchema := common.StructToSchema(Workspace{},
181+
workspaceSchema := common.StructToSchema(workspace{},
178182
func(s map[string]*schema.Schema) map[string]*schema.Schema {
179183
for name, fieldSchema := range s {
180184
if _, ok := computedFields[name]; ok {
@@ -258,7 +262,7 @@ func ResourceMwsWorkspaces() common.Resource {
258262
}
259263
var createWorkspaceRequest provisioning.CreateWorkspaceRequest
260264
common.DataToStructPointer(d, workspaceSchema, &createWorkspaceRequest)
261-
var workspaceConfig Workspace
265+
var workspaceConfig workspace
262266
common.DataToStructPointer(d, workspaceSchema, &workspaceConfig)
263267

264268
// Validate required fields by cloud
@@ -275,6 +279,9 @@ func ResourceMwsWorkspaces() common.Resource {
275279
log.Print("[INFO] Using existing customer_managed_key_id as value for new managed_services_customer_managed_key_id")
276280
createWorkspaceRequest.ManagedServicesCustomerManagedKeyId = customerManagedKeyId.(string)
277281
}
282+
// is_no_public_ip_enabled always needs to be serialized. It is true by default, but if it is disabled
283+
// by a customer, it will be omitted by the default request serializer.
284+
createWorkspaceRequest.ForceSendFields = append(createWorkspaceRequest.ForceSendFields, "IsNoPublicIpEnabled")
278285

279286
// Create the workspace. If creation fails, clean it up and return.
280287
wait, err := a.Workspaces.Create(ctx, createWorkspaceRequest)
@@ -332,7 +339,7 @@ func ResourceMwsWorkspaces() common.Resource {
332339
if err != nil {
333340
return err
334341
}
335-
var workspaceConfig Workspace
342+
var workspaceConfig workspace
336343
common.DataToStructPointer(d, workspaceSchema, &workspaceConfig)
337344
workspace, err := a.Workspaces.Get(ctx, provisioning.GetWorkspaceRequest{WorkspaceId: common.MustInt64(workspaceID)})
338345
if err != nil {
@@ -370,7 +377,7 @@ func ResourceMwsWorkspaces() common.Resource {
370377
}
371378
var updateWorkspaceRequest provisioning.UpdateWorkspaceRequest
372379
common.DataToStructPointer(d, workspaceSchema, &updateWorkspaceRequest)
373-
var workspaceConfig Workspace
380+
var workspaceConfig workspace
374381
common.DataToStructPointer(d, workspaceSchema, &workspaceConfig)
375382
// WorkspaceId in UpdateWorkspaceRequest is a path parameter, thus tagged with `json:"-"`.
376383
// This causes it not to be set in DataToStructPointer. Instead, the workspace ID can be

0 commit comments

Comments
 (0)