scripting – How to edit Azure Bicep files programmatically?
We have a lot of .bicep
+ .bicepparam
files, and sometimes we have evolving ideas on how to structure those. This involves makes changes to many many files, to apply the new approach.
Some of these changes we can just do with text-based find-replace, either regex or normal. However, some changes require a bit more logic.
It would be ideal if we could have a script that can read in a .bicep file, run some logic on it, and then write back a modified version.
Pseudocode:
foreach (filepath in bicep_files)
bicep_model = read_bicep(filepath)
… custom logic here, make changes in model …
write_bicep(bicep_model, filepath)
With ARM / JSON, this is easy – there are many JSON serializers / deserializers out there. For bicep, I know of no such libraries / parsers.
Potential options I have considered:
Read more here: Source link