Skip to content

Commit

Permalink
add azurerm_databricks_workspace parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
notchairmk committed Jul 19, 2019
1 parent 2e0e891 commit 9cf1b5b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
23 changes: 23 additions & 0 deletions azurerm/resource_arm_databricks_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func resourceArmDatabricksWorkspace() *schema.Resource {
ValidateFunc: validate.NoEmptyStrings,
},

"parameters": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},

"managed_resource_group_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -105,13 +111,28 @@ func resourceArmDatabricksWorkspaceCreateUpdate(d *schema.ResourceData, meta int
managedResourceGroupID = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s", subscriptionID, managedResourceGroupName)
}

var newParams map[string]interface{}
if v, ok := d.GetOk("parameters"); ok {
params := v.(map[string]interface{})

newParams = make(map[string]interface{}, len(params))
for key, val := range params {
newParams[key] = struct {
Value interface{}
}{
Value: val,
}
}
}

workspace := databricks.Workspace{
Sku: &databricks.Sku{
Name: utils.String(skuName),
},
Location: utils.String(location),
WorkspaceProperties: &databricks.WorkspaceProperties{
ManagedResourceGroupID: &managedResourceGroupID,
Parameters: &newParams,
},
Tags: expandedTags,
}
Expand Down Expand Up @@ -179,6 +200,8 @@ func resourceArmDatabricksWorkspaceRead(d *schema.ResourceData, meta interface{}
}
d.Set("managed_resource_group_id", props.ManagedResourceGroupID)
d.Set("managed_resource_group_name", managedResourceGroupID.ResourceGroup)

d.Set("parameters", props.Parameters)
}

flattenAndSetTags(d, resp.Tags)
Expand Down
9 changes: 9 additions & 0 deletions azurerm/resource_arm_databricks_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func TestAccAzureRMDatabricksWorkspace_complete(t *testing.T) {
testCheckAzureRMDatabricksWorkspaceExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "managed_resource_group_id"),
resource.TestCheckResourceAttrSet(resourceName, "managed_resource_group_name"),
resource.TestCheckResourceAttr(resourceName, "parameters.%", "2"),
resource.TestCheckResourceAttr(resourceName, "parameters.customPrivateSubnetName", "privateSubnet"),
resource.TestCheckResourceAttr(resourceName, "parameters.customPublicSubnetName", "publicSubnet"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.Environment", "Production"),
resource.TestCheckResourceAttr(resourceName, "tags.Pricing", "Standard"),
Expand All @@ -148,6 +151,7 @@ func TestAccAzureRMDatabricksWorkspace_complete(t *testing.T) {
testCheckAzureRMDatabricksWorkspaceExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "managed_resource_group_id"),
resource.TestCheckResourceAttrSet(resourceName, "managed_resource_group_name"),
resource.TestCheckNoResourceAttr(resourceName, "parameters"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"),
resource.TestCheckResourceAttr(resourceName, "tags.Pricing", "Standard"),
),
Expand Down Expand Up @@ -258,6 +262,11 @@ resource "azurerm_databricks_workspace" "test" {
sku = "standard"
managed_resource_group_name = "acctestRG-%d-managed"
parameters = {
"customPrivateSubnetName" = "privateSubnet",
"customPublicSubnetName" = "publicSubnet"
}
tags = {
Environment = "Production"
Pricing = "Standard"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/databricks_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The following arguments are supported:

~> **NOTE** Azure requires that this Resource Group does not exist in this Subscription (and that the Azure API creates it) - otherwise the deployment will fail.

* `parameters` - (Optional) Specifies name and value pairs that define the workspace parameters. Allowed names include `customPrivateSubnetName`, `customPublicSubnetName`, `customVirtualNetworkId`, `enableNoPublicIp`, `relayNamespaceName`, `storageAccountName`, `storageAccountSkuName`, `vnetAddressPrefix`, `resourceTags`, `amlWorkspaceId`.

* `tags` - (Optional) A mapping of tags to assign to the resource.

## Attributes Reference
Expand Down

0 comments on commit 9cf1b5b

Please sign in to comment.