Azure / Azure/bicep

Allow merging-fucntionality on object union

Open
#11,329 1 comment 5 reactions 0 assignees View on GitHub
enhancement intermediate language Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe.**

In order to practice modular design, we often have the need to merge nested objects (as each part of the object is decomposed) in a recursive fashion.

For example, we decompose our Azure Databricks module into the following components (in separate yml-files):

1. Base module:
```yml
sku:
name: Premium
```
2. SCC/NPIP capability:
```yml
properties:
parameters:
enableNoPublicIp:
value: true # Enable Secure Cluster Connectivity (NPIP)
```
3. VNet injection capability:
```yml
properties:
managedResourceGroupId: subscriptionResourceId('Microsoft.Resources/resourceGroups', )
parameters:
customPrivateSubnetName:
value: private-subnet
customPublicSubnetName:
value: public-subnet
```
4. Private-link capability:
```yml
properties:
parameters:
publicNetworkAccess: 'Disabled' # Disable public access to the control plane (only private link)
requiredNsgRules: 'NoAzureDatabricksRules' # Omit NSG egress rule for Azure Databricks service tag (i.e. control plane public IP)
```

This way, our end-user can (in theory) pick the capabilities they need by merging the capabilities they need:

```bicep
var base = loadYamlContent('adb-workspace.base.yml')
var scc = loadYamlContent('adb-workspace.scc.yml')
var vnet = loadYamlContent('adb-workspace.vnet.yml')
var plink = loadYamlContent('adb-workspace.pling.yml')

var config = union(base, scc, vnet, plink) // This is currently not supported and requested in this feature request

resource adbWorkspace 'Microsoft.Databricks/workspaces@2023-02-01' = {
name: name
location: resourceGroup().location
sku: config.sku
properties: config.properties
}
```

However, the union function currently (rightfully) replaces values for existing keys, even if its corresponding values represent mergeable types, like objects (or arrays).

**Describe the solution you'd like**

It would be very helpful to provide an additional parameter to _union_ that (recursively) allows for these merges to take place. I assume the bicep function just wraps the ARM function, so this functionality should be implemented there.

Since bicep/ARM is a declarative IaC tool, manipulating declarative structures (like nested objects) in flexible ways would allow for better support for code quality and software design best-practices.

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; start by tracing the Bicep union function and the underlying ARM behavior referenced in the request. Establish the expected recursive handling of nested objects and arrays, including precedence, and verify the result against the Azure Databricks composition example.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.