Is there a way to replicate the MAP variable in TF, in BICEP? In the ARM template reference, I see that "object" is similar in declaration to a MAP but different in usage.
tf - map example (https://gist.github.com/devops-school/1f3efed15d390748b208a109f9765e0c)
arm template object / bicep example (https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/data-types?tabs=bicep#objects)
Thanks!
Yes, there is an Object type in Bicep as well. It is similar to its ARM counterpart but also has some subtle differences. In Bicep, an object must be declared in multiple lines. Each property in an object consists of key and value. The key and value are separated by a colon (:). An object allows any property of any type.
In Bicep, the key isn't enclosed by quotes. Don't use commas in between properties.
param exampleObject object = {
name: 'test name'
id: '123-abc'
isCurrent: true
tier: 1
}
Property accessors are used to access properties of an object. They're constructed using the . operator.
var a = {
b: 'Dev'
c: 42
d: {
e: true
}
}
output result1 string = a.b // returns 'Dev'
output result2 int = a.c // returns 42
output result3 bool = a.d.e // returns true
You can also use the [] syntax to access a property. a.d.e can also be expressed as a['d'].e.
Reference: Objects in Bicep
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With