-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource.bicep
21 lines (20 loc) · 916 Bytes
/
resource.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as _resourceType from '../types/resource.bicep'
@description('''
Adds an iteration identifier element to the properties of each resource, based on the index of a resource in the unIterizedResourceCollection.
If the iteration identifier element already exists, it skips setting the element for that object in the collection.
''')
@export()
func makeIteratedResourceCollection(
unIterizedResourceCollection _resourceType.resourceFormat[],
iterationIdentifier string,
startIndexAt int
) _resourceType.resourceFormat[] =>
map(
range(0, length(unIterizedResourceCollection)),
i => {
name: unIterizedResourceCollection[i].name
properties: contains(unIterizedResourceCollection[i].properties, iterationIdentifier)
? unIterizedResourceCollection[i].properties
: union(unIterizedResourceCollection[i].properties, { '${iterationIdentifier}': startIndexAt + i })
}
)