PSArm
PSArm copied to clipboard
Create a way to specify the nested template properly
PSArm probably needs a new keyword that allows for the definition of variables, parameters and outputs and then just links up the inner templates.
This probably wants to look something like:
# Arm is now the actual top level keyword
Arm {
# The old Arm is now Deployment or something similar
Deployment {
Resource {
}
}
}
Conversely, we could also just allow Arm
to nest within Arm
and then have the keyword detect nesting and redefine itself appropriately.
One other possibility is to have Publish-PSArmTemplate
or Export-PSArmTemplate
take more parameters or an object or perhaps a scriptblock.
One key challenge is being able to pass outputs back out of collected templates into the parent template, which requires a way to reference the collected templates at the top level (where they might not be known and don't have a convenient way to pass them around).
See also https://github.com/PowerShell/PSArm/issues/142, https://github.com/PowerShell/PSArm/issues/140, https://github.com/PowerShell/PSArm/issues/139.
I thought about this too. Without reading the docs or checking the code, I tried to define two arm blocks at the same level assuming maybe that would create two deployment resources.
On design decision I don’t understand is why are all arms templates put into deployment resources. This is not how bicep works.
I potentially like the idea of your first example but still think it’s unnecessarily confusing with the terms.
arm {
template {
}
# crazy but would be awesome
$someTemplate = template {
}
template {
Resource deployment {
Template $someTemplate
}
}
Parameter {
}
Output {
}
}
I wrote this syntax on a phone so it’s a bit janky but the general idea I think is good
Yeah template
makes sense.
On design decision I don’t understand is why are all arms templates put into deployment resources. This is not how bicep works.
Can you explain further here? I was under the impression that Bicep collects modules into deployment resources.
``` $someTemplate = template { ``` }
You can assign from any keyword today -- they just emit objects, there's nothing special about them. The problem is that the way PowerShell works you can either assign or emit them to the pipeline. So to get that template to be part of the larger one you have to do:
$template = Arm {
...
}
$template
they just emit objects, there's nothing special about them
What's more, you can actually manipulate the objects you get from them.
It's not something that's documented yet, since getting the essentials of the DSL UX right are more important.