Skip to content

Commit 98e9349

Browse files
committed
patch support for workspace to use customer managed key, mws_workspaces resource can now use customer managed key with a "" default, and updated the docs to reflect cmk
1 parent 0dd0bc9 commit 98e9349

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

client/service/mws_workspaces.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (a MWSWorkspacesAPI) WaitForWorkspaceRunning(mwsAcctId string, workspaceID
7676
}
7777

7878
// Patch will relaunch the mws workspace deployment TODO: may need to include customer managed key
79-
func (a MWSWorkspacesAPI) Patch(mwsAcctId string, workspaceID int64, awsRegion, credentialsID, storageConfigurationID, networkID string, isNoPublicIpEnabled bool) error {
79+
func (a MWSWorkspacesAPI) Patch(mwsAcctId string, workspaceID int64, awsRegion, credentialsID, storageConfigurationID, networkID, customerManagedKeyID string, isNoPublicIpEnabled bool) error {
8080
workspacesAPIPath := fmt.Sprintf("/accounts/%s/workspaces/%d", mwsAcctId, workspaceID)
8181

8282
mwsWorkspacesRequest := model.MWSWorkspace{
@@ -90,6 +90,10 @@ func (a MWSWorkspacesAPI) Patch(mwsAcctId string, workspaceID int64, awsRegion,
9090
mwsWorkspacesRequest.NetworkID = networkID
9191
}
9292

93+
if !reflect.ValueOf(customerManagedKeyID).IsZero() {
94+
mwsWorkspacesRequest.CustomerManagedKeyID = customerManagedKeyID
95+
}
96+
9397
_, err := a.Client.performQuery(http.MethodPatch, workspacesAPIPath, "2.0", nil, mwsWorkspacesRequest, nil)
9498
return err
9599
}

databricks/resource_databricks_mws_workspaces.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func resourceMWSWorkspaces() *schema.Resource {
6969
Type: schema.TypeBool,
7070
Required: true,
7171
},
72+
"customer_managed_key_id": {
73+
Type: schema.TypeString,
74+
Default: "",
75+
Optional: true,
76+
},
7277
"network_id": {
7378
Type: schema.TypeString,
7479
Optional: true,
@@ -127,14 +132,15 @@ func resourceMWSWorkspacesCreate(d *schema.ResourceData, m interface{}) error {
127132
credentialsID := d.Get("credentials_id").(string)
128133
storageConfigurationID := d.Get("storage_configuration_id").(string)
129134
networkID := d.Get("network_id").(string)
135+
customerManagedKeyId := d.Get("customer_managed_key_id").(string)
130136
isNoPublicIpEnabled := d.Get("is_no_public_ip_enabled").(bool)
131137
var workspace model.MWSWorkspace
132138
var err error
133-
workspace, err = client.MWSWorkspaces().Create(mwsAcctId, workspaceName, deploymentName, awsRegion, credentialsID, storageConfigurationID, networkID, "", isNoPublicIpEnabled)
139+
workspace, err = client.MWSWorkspaces().Create(mwsAcctId, workspaceName, deploymentName, awsRegion, credentialsID, storageConfigurationID, networkID, customerManagedKeyId, isNoPublicIpEnabled)
134140
// Sometimes workspaces api is buggy
135141
if err != nil {
136142
time.Sleep(15 * time.Second)
137-
workspace, err = client.MWSWorkspaces().Create(mwsAcctId, workspaceName, deploymentName, awsRegion, credentialsID, storageConfigurationID, networkID, "", isNoPublicIpEnabled)
143+
workspace, err = client.MWSWorkspaces().Create(mwsAcctId, workspaceName, deploymentName, awsRegion, credentialsID, storageConfigurationID, networkID, customerManagedKeyId, isNoPublicIpEnabled)
138144
if err != nil {
139145
return err
140146
}
@@ -214,6 +220,10 @@ func resourceMWSWorkspacesRead(d *schema.ResourceData, m interface{}) error {
214220
if err != nil {
215221
return err
216222
}
223+
err = d.Set("customer_managed_key_id", workspace.CustomerManagedKeyID)
224+
if err != nil {
225+
return err
226+
}
217227
err = d.Set("account_id", workspace.AccountID)
218228
if err != nil {
219229
return err
@@ -272,9 +282,10 @@ func resourceMWSWorkspacePatch(d *schema.ResourceData, m interface{}) error {
272282
credentialsID := d.Get("credentials_id").(string)
273283
storageConfigurationID := d.Get("storage_configuration_id").(string)
274284
networkID := d.Get("network_id").(string)
285+
customerManagedKeyId := d.Get("customer_managed_key_id").(string)
275286
isNoPublicIpEnabled := d.Get("is_no_public_ip_enabled").(bool)
276287

277-
err = client.MWSWorkspaces().Patch(packagedMwsId.MwsAcctId, idInt64, awsRegion, credentialsID, storageConfigurationID, networkID, isNoPublicIpEnabled)
288+
err = client.MWSWorkspaces().Patch(packagedMwsId.MwsAcctId, idInt64, awsRegion, credentialsID, storageConfigurationID, networkID, customerManagedKeyId, isNoPublicIpEnabled)
278289
if err != nil {
279290
return err
280291
}

website/content/Resources/mws_storage_configurations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
+++
2-
title = "multiworkspace_storage_configurations"
2+
title = "mws_storage_configurations"
33
date = 2020-04-20T23:34:03-04:00
44
weight = 15
55
chapter = false
66
pre = ""
77
+++
88

99

10-
## Resource: `multiworkspace_storage_configurations`
10+
## Resource: `mws_storage_configurations`
1111

1212
This resource to configure the root bucket for the multiple workspaces api.
1313

website/content/Resources/mws_workspaces.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ pre = ""
1111

1212
This resource to configure the vpc for the multiple workspaces api if the BYOVPC option is chosen.
1313

14+
{{% notice warning %}}
15+
This provider does not yet support the customer_managed_key resource yet so you will need to manually create that
16+
and provide the cmk object guid into the workspace api. You can see it on the argument reference below.
17+
{{% /notice %}}
18+
1419
{{% notice warning %}}
1520
It is important to understand that this will require you to configure your provider separately for the
1621
multiple workspaces resources
@@ -95,6 +100,9 @@ The following arguments are supported:
95100
#### - `network_id`:
96101
> **(Optional)** The ID of the workspace's network configuration object.
97102
103+
#### - `customer_managed_key_id`:
104+
> **(Optional)** The ID of the workspace's notebook encryption key configuration object.
105+
98106
#### - `is_no_public_ip_enabled`:
99107
> **(Optional)** Specifies whether secure cluster connectivity (sometimes called no public IP) is enabled on this workspace.
100108

0 commit comments

Comments
 (0)