Open JFolberth opened 10 months ago
Yeah, this is kind of a pain point.
As for allowing parameters in the module definition I guess the problem is not being able to restore the module and as such not providing intellisense/parameter validation, etc.
The registry part can be "fake-parametrized" by using aliases in the bicepconfig.json file, but since you can't have multiple bicepconfig files in the same directory that has limitations as well. (I haven't experimented building a folder hierarchy with config files.)
I currently work around the registry part by using a placeholder value like "registry": "${registry}.azurecr.io"
and doing a substitution with sed in the pipeline for the actual ACR name. Feels a bit hackish though. Still doesn't solve the problem of controlling the module version across environments either.
@ahelland and @JFolberth One of our goals with Bicep is to always ensure that we provide accurate completions and validation even when dealing with modules sourced from an external registry. Completely generic parameterization of the module sources makes providing that rather difficult.
I'm wondering if there is a way to simplify the problem and still provide sufficient completion and validation. Could answer the following questions about this scenario?
Let's say you configured your registry as follows and {registry}
has three values "one" and "two":
"registry": "${registry}.azurecr.io"
{registry}
but the contents of the registry were completely different and incompatible?Here are my initial thoughts @majastrz :
@ahelland Makes sense. I've got some additional questions:
bicep publish
again using the second or third registry?bicep publish
feels subjectively better. I've written VS Code tasks to automate the publish part so it's just a few clicks to loop through. I'm aware of ORAS, but haven't used it on the projects I'm working on.Posting to keep the thread alive as I mostly agree with @ahelland responses.
I think at the end of the day the substitution needs the ability to occur at CLI level. This would ensure the ability to automate the deployments w/ the appropriate configurations.
For publishing the modules I feel this is out of scope of the question. Modules being published would adhere to there own lifecycle and really don't want to open this up outside of the ask of how to accommodate leveraging a single bicep file for deployment across various environments which may contain different registry values.
I agree with the point about publish since bicep publish
takes the exact "path" where to publish the module. I also agree about having ability to override the placeholder values via CLI. It would provide quite a lot of flexibility especially since we're not quite ready to take the leap to supporting multiple bicepconfig.json files.
I'm wondering if this could be a good starting point:
Thoughts?
Sounds like a plan @majastrz
We're talking about exposing the registry specifically as a command line switch like --registry
and not everything in bicepconfig.json right?
Definitely need a working default for the Intellisense.
Out of curiosity - what takes so long when doing the bicep publish
? For publishing a single module locally it's not an issue. But when doing the publishing in a pipeline I have a couple options:
--force
parameter but that potenially breaks versioning so don't want to do that.The easiest script-wise is to just loop through the modules sub-directories and attempt all of them. Either they give the warning the module exists or a new version is published. Works fine, but adds time to the pipeline.
Oh well, not a technical problem per se I guess :)
Yes, this would be specific to the registry sections, but we could consider expanding it in the future. For the issue of publish taking a long time, can you open a separate issue?
I took off the labels so the bot doesn't close this.
Is your feature request related to a problem? Please describe. Yes. When hosting bicep modules in a registry would like to either a.) substitute the registry URL per environment or b.) substitute the tag in the module location for the specific environment/version.
This is an issue with teams who may have different module definitions for dev/test/prod or have the desire to run things like a beta module in their dev environment. Currently the module reference requires a path that cannot be interpopulated. Other IaC providers get around this with the
source
property in the module block.Describe the solution you'd like A clear and concise description of what you want to happen.
Something like: module appService '${parameters.registryURL}:${parameters.registryTag}'