Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAP type parameter / variable in BICEP?

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!

like image 217
Chief Avatar asked Sep 20 '26 07:09

Chief


1 Answers

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

like image 141
Bhargavi Annadevara Avatar answered Sep 22 '26 20:09

Bhargavi Annadevara