Skip to content

Commit d950dcc

Browse files
authored
Added preview for GCP PSC workspace (#2090)
1 parent 82954cc commit d950dcc

File tree

4 files changed

+138
-8
lines changed

4 files changed

+138
-8
lines changed

docs/resources/mws_workspaces.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ output "databricks_token" {
257257
}
258258
```
259259

260+
In order to create a [Databricks Workspace that leverages GCP Private Service Connect](https://docs.gcp.databricks.com/administration-guide/cloud-configurations/gcp/private-service-connect.html) please ensure that you have read and understood the [Enable Private Service Connect](https://docs.gcp.databricks.com/administration-guide/cloud-configurations/gcp/private-service-connect.html) documentation and then customise the example above with the relevant examples from [mws_vpc_endpoint](mws_vpc_endpoint.md), [mws_private_access_settings](mws_private_access_settings.md) and [mws_networks](mws_networks.md).
261+
260262
#### Creating a Databricks on GCP workspace with Databricks-Managed VPC
261263

262264
![VPCs](https://docs.databricks.com/_images/customer-managed-vpc.png)
@@ -302,24 +304,25 @@ output "databricks_token" {
302304

303305
## Argument Reference
304306

305-
-> **Note** All workspaces would be verified to get into runnable state or deleted upon failure. You can only update `credentials_id`, `network_id`, and `storage_customer_managed_key_id` on a running workspace.
307+
-> **Note** All workspaces would be verified to get into runnable state or deleted upon failure. You can only update `credentials_id`, `network_id`, and `storage_customer_managed_key_id`, `private_access_settings_id` on a running workspace.
306308

307-
The following arguments are available and cannot be changed after workspace is created:
309+
The following arguments are available:
308310

309311
* `account_id` - Account Id that could be found in the bottom left corner of [Accounts Console](https://accounts.cloud.databricks.com/).
310312
* `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.
311-
* `workspace_name` - name of the workspace, will appear on UI
313+
* `workspace_name` - name of the workspace, will appear on UI.
312314
* `network_id` - (Optional) `network_id` from [networks](mws_networks.md).
313-
* `aws_region` - (AWS only) region of VPC
314-
* `storage_configuration_id` - (AWS only)`storage_configuration_id` from [storage configuration](mws_storage_configurations.md)
315+
* `aws_region` - (AWS only) region of VPC.
316+
* `storage_configuration_id` - (AWS only)`storage_configuration_id` from [storage configuration](mws_storage_configurations.md).
315317
* `managed_services_customer_managed_key_id` - (Optional, AWS only) `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.
316-
* `location` - (GCP only) region of the subnet
318+
* `location` - (GCP only) region of the subnet.
317319
* `cloud_resource_container` - (GCP only) A block that specifies GCP workspace configurations, consisting of following blocks:
318320
* `gcp` - A block that consists of the following field:
319321
* `project_id` - The Google Cloud project ID, which the workspace uses to instantiate cloud resources for your workspace.
320-
* `gke_config` - A block that specifies GKE configuration for the Databricks workspace:
321-
* `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`
322+
* `gke_config` - (GCP only) A block that specifies GKE configuration for the Databricks workspace:
323+
* `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`.
322324
* `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`.
325+
* `private_access_settings_id` - (Optional) Canonical unique identifier of [databricks_mws_private_access_settings](mws_private_access_settings.md) in Databricks Account.
323326

324327
## token block
325328

@@ -384,3 +387,4 @@ The following resources are used in the same context:
384387
* [databricks_mws_log_delivery](mws_log_delivery.md) to configure delivery of [billable usage logs](https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html) and [audit logs](https://docs.databricks.com/administration-guide/account-settings/audit-logs.html).
385388
* [databricks_mws_networks](mws_networks.md) to [configure VPC](https://docs.databricks.com/administration-guide/cloud-configurations/aws/customer-managed-vpc.html) & subnets for new workspaces within AWS.
386389
* [databricks_mws_storage_configurations](mws_storage_configurations.md) to configure root bucket new workspaces within AWS.
390+
* [databricks_mws_private_access_settings](mws_private_access_settings.md) to create a [Private Access Setting](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html#step-5-create-a-private-access-settings-configuration-using-the-databricks-account-api) that can be used as part of a [databricks_mws_workspaces](mws_workspaces.md) resource to create a [Databricks Workspace that leverages AWS PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html).

internal/acceptance/mws_workspaces_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,49 @@ func TestMwsAccGcpByovpcWorkspaces(t *testing.T) {
109109
}`,
110110
})
111111
}
112+
113+
func TestMwsAccGcpPscWorkspaces(t *testing.T) {
114+
accountLevel(t, step{
115+
Template: `
116+
resource "databricks_mws_networks" "this" {
117+
account_id = "{env.DATABRICKS_ACCOUNT_ID}"
118+
network_name = "{env.TEST_PREFIX}-network-{var.RANDOM}"
119+
gcp_network_info {
120+
network_project_id = "{env.GOOGLE_PROJECT}"
121+
vpc_id = "{env.VPC_NETWORK_ID}"
122+
subnet_id = "{env.SUBNET_ID}"
123+
subnet_region = "{env.GOOGLE_REGION}"
124+
pod_ip_range_name = "{env.POD_IP_RANGE_NAME}"
125+
service_ip_range_name = "{env.SVC_IP_RANGE_NAME}"
126+
}
127+
}
128+
129+
resource "databricks_mws_private_access_settings" "this" {
130+
account_id = "{env.DATABRICKS_ACCOUNT_ID}"
131+
private_access_settings_name = "tf-pas-{var.RANDOM}"
132+
region = "{env.GOOGLE_REGION}"
133+
public_access_enabled = true
134+
private_access_level = "ACCOUNT"
135+
}
136+
137+
resource "databricks_mws_workspaces" "this" {
138+
account_id = "{env.DATABRICKS_ACCOUNT_ID}"
139+
workspace_name = "{env.TEST_PREFIX}-{var.RANDOM}"
140+
location = "{env.GOOGLE_REGION}"
141+
142+
cloud_resource_container {
143+
gcp {
144+
project_id = "{env.GOOGLE_PROJECT}"
145+
}
146+
}
147+
148+
private_access_settings_id = databricks_mws_private_access_settings.this.private_access_settings_id
149+
network_id = databricks_mws_networks.this.network_id
150+
151+
gke_config {
152+
connectivity_type = "PRIVATE_NODE_PUBLIC_MASTER"
153+
master_ip_range = "10.3.0.0/28"
154+
}
155+
}`,
156+
})
157+
}

mws/resource_mws_workspaces.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ func (w *Workspace) MarshalJSON() ([]byte, error) {
122122
if w.NetworkID != "" {
123123
workspaceCreationRequest["network_id"] = w.NetworkID
124124
}
125+
if w.PrivateAccessSettingsID != "" {
126+
workspaceCreationRequest["private_access_settings_id"] = w.PrivateAccessSettingsID
127+
}
125128
if w.GkeConfig != nil {
126129
workspaceCreationRequest["gke_config"] = w.GkeConfig
127130
}

mws/resource_mws_workspaces_test.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,83 @@ func TestResourceWorkspaceCreateGcp(t *testing.T) {
152152
}.ApplyNoError(t)
153153
}
154154

155+
func TestResourceWorkspaceCreateGcpPsc(t *testing.T) {
156+
qa.ResourceFixture{
157+
Fixtures: []qa.HTTPFixture{
158+
{
159+
Method: "POST",
160+
Resource: "/api/2.0/accounts/abc/workspaces",
161+
// retreating to raw JSON, as certain fields don't work well together
162+
ExpectedRequest: map[string]any{
163+
"account_id": "abc",
164+
"cloud": "gcp",
165+
"cloud_resource_container": map[string]any{
166+
"gcp": map[string]any{
167+
"project_id": "def",
168+
},
169+
},
170+
"location": "bcd",
171+
"private_access_settings_id": "pas_id_a",
172+
"network_id": "net_id_a",
173+
"gke_config": map[string]any{
174+
"master_ip_range": "e",
175+
"connectivity_type": "PRIVATE_NODE_PUBLIC_MASTER",
176+
},
177+
"gcp_managed_network_config": map[string]any{
178+
"gke_cluster_pod_ip_range": "b",
179+
"gke_cluster_service_ip_range": "c",
180+
"subnet_cidr": "a",
181+
},
182+
"workspace_name": "labdata",
183+
},
184+
Response: Workspace{
185+
WorkspaceID: 1234,
186+
AccountID: "abc",
187+
DeploymentName: "900150983cd24fb0",
188+
WorkspaceName: "labdata",
189+
},
190+
},
191+
{
192+
Method: "GET",
193+
ReuseRequest: true,
194+
Resource: "/api/2.0/accounts/abc/workspaces/1234",
195+
Response: Workspace{
196+
AccountID: "abc",
197+
WorkspaceID: 1234,
198+
WorkspaceStatus: WorkspaceStatusRunning,
199+
DeploymentName: "900150983cd24fb0",
200+
WorkspaceName: "labdata",
201+
},
202+
},
203+
},
204+
Resource: ResourceMwsWorkspaces(),
205+
HCL: `
206+
account_id = "abc"
207+
workspace_name = "labdata"
208+
deployment_name = "900150983cd24fb0"
209+
location = "bcd"
210+
cloud_resource_container {
211+
gcp {
212+
project_id = "def"
213+
}
214+
}
215+
private_access_settings_id = "pas_id_a"
216+
network_id = "net_id_a"
217+
gcp_managed_network_config {
218+
subnet_cidr = "a"
219+
gke_cluster_pod_ip_range = "b"
220+
gke_cluster_service_ip_range = "c"
221+
}
222+
gke_config {
223+
connectivity_type = "PRIVATE_NODE_PUBLIC_MASTER"
224+
master_ip_range = "e"
225+
}
226+
`,
227+
Gcp: true,
228+
Create: true,
229+
}.ApplyNoError(t)
230+
}
231+
155232
func TestResourceWorkspaceCreateWithIsNoPublicIPEnabledFalse(t *testing.T) {
156233
d, err := qa.ResourceFixture{
157234
Fixtures: []qa.HTTPFixture{

0 commit comments

Comments
 (0)