-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Make it easier to import sets of constants #3039
Comments
After reading #2656 I think the attached example would be better written as
which changes the usage to That doesn't make any effective difference to the other points in the suggestion but it does highlight how making it easier to import objects form a module can help with readability in the main file. |
@NeilMacMullen - would you consider this to be a dup of #893? |
I'd say the most important thing here would be enabling intellisense for whatever "constants" are produced. I think the best way to do this would be to allow a bicep file that only has a var (or output) to be "imported" in a special way that won't actually run the bicep file or include it as a nested template, but read the vars and make the var available to intellisense, and then transpile the resulting match into the ARM. Whether that's a decorator on the file indicating it's meant to be a constant, or a special module or import syntax that specifies that as well, would be fine. Typescript syntax would work well here. Example: rbacRoles.bicep
main.bicep
Result: 'aaaaa-bbbbb-cccc-dddd' and as soon as I typed If rbacroles.bicep contained any resource statements, it would immediately throw an error saying that a module imported as a constant can only contain vars, functions, and var outputs that can be evaluated locally. |
Related to #1895 , here's an example file I generate with Powershell that I would like to import in a way that it never actually ends up in the ARM, but would enable me to add intellisense to my bicep per the approach I discussed above. |
Hey folks - this is something I would love to have available, in whatever form it takes. Just wondering if anybody knows there has been progress that might not be reflected here. Example scenario: Say we have a centrally managed set of network configs -- IP ranges, subnet IDs, etc. -- that occasionally change, and are out of the hands of people using Bicep. If we have shared Bicep modules then those modules should to be able to refer to the centrally managed values somehow. So when we re-run the deployment, it picks up the changes and applies them. If I put these constants into a module, which is then used by one or more other modules, I'm worried there will be name conflicts. Using the loadXXX functions would be fine -- but currently it appears those functions only work with relative/local paths, which defeats the purpose. |
I am going to close this since we've largely completed the work with the |
Is your feature request related to a problem? Please describe.
I am currently attempting to set up a role-assignment. This currently looks like...
The fact that I have to look up "magic" GUIDS for the role definition is frustrating. It would be far preferable to be able to write something like:
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', rbac.keyVaultSecretsUser)
Describe the solution you'd like
Ideally, BICEP would already "know" about all the RBAC role guids and other constants that are likely to be used in deployments. However I can understand why this might be "out of scope". :-)
#1895 address the specific issue of RBAC guids. The rest of this suggestion list provides a mechanism for addressing other sources of constant-sets, including those not known by the BICEP team...
An alternative to built-in sets would be to make available a set of modules that allow users to manually import these. For example, see the attached file which attempts to "export" all known RBAC guids. These modules could be contributed to by the user community (i.e. available in the repo here) which would require a small amount of admin overhead and some policy decisions on naming/content/format etc.
The attached module simply contains code in this format...
Unfortunately consuming it requires an unfortunate amount of ceremony....
It would be desirable if there was a more convenient way to do this (perhaps with a different keyword). E.g.
Further, it would be highly desirable if the VS Code intellisense could cope with this. At the moment it's unable to chain through the module import; ie it won't supply completions for
roles
in the example above.It would also be desirable if some syntax were available to allow intellisense hints to be provided for variables so that VS Code could show the descriptions of the imported constants.
The text was updated successfully, but these errors were encountered: