-
Notifications
You must be signed in to change notification settings - Fork 756
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
Support string interpolation in resource type string #413
Comments
@anthony-c-martin can we take care of this as part of #267? |
@alex-frankel No, we need to implement constant folding for that. |
Is there any way to implement a :latest tag for the ApiVersion? Having to manage and track what version of an API each resource in a deployment is using can be a pain and I often see customers neglect that once they have live code. |
@kuhlman-labs - With modules, module authors will be able to choose an apiVersion and the end user of the module only will have to pick a version of a particular module (which will likely be semantically versioned instead of using a date string). That might help alleviate some of this pain. We also are tracking issue #16 which would allow you to provide an apiVersion "mapping" file of some kind. |
To add additional information. Certainly there are RPs where when version is changed there is not actual breaking change but there are a lot of RPs where for example new properties are added, default value for property is changed from one to another. Some like kubernetes have drastic changes which will result in failed deployment. These are some of the reasons why it is dangerous. |
@alex-frankel @slavizh Thank you for the responses. From my perspective, I would advocate for giving the ability to find breaking changes the the RP API to users as easily as possible for a few reasons. If you're running IaC in separate environments ideally you would want to find any breaking changes as early as possible in your dev environment by always running the latest APIs and then pinning API versions to higher level environments to ensure stability. I also think that finding breaking changes can signal to a user that there may be new features for a RP that they may otherwise never become aware of. |
Regarding apiVersions as variables: Just wanted to point out that the Best Practices document for ARM templates has a line that says "Variables must not be used for apiVersions. The apiVersion affects the shape of the resource and often cannot be updated without updating all the resources that use a particular version." In addition, arm-ttk validation looks for apiVersions as explicit recent dates (and this is required for ARM templates that are used in Azure Marketplace publishing). cc @bmoore-msft |
@arsenvlad I would not consider many of those there best practices. These are more of quick start templates best practices because otherwise our bot will not be able to verify the templates properly. @kuhlman-labs not sure how you build your solutions but when we build them we put specific version and release them as packages. If we have 'latest' and we publish those with latest as soon as new version is released that is breaking the solution will stop working for those or make unexpected changes. When you run something in dev for sure you would want to know also what is the latest version as there is no notification channel or something when versions are released for RPs, nor there is change log. It is always to test these on your own if they are not documented or if they are documented check the version and compare it to previous one. |
I do think we need a better way to manage apiVersions throughout a template but I don’t think string interpolation in the definition is the right way to go about it. That string is your contract and the ability to reason over and manage that part of the declaration is pretty important, for humans and tooling. It will also lead to things like the implementation of “latest” and while I understand the initial reaction to dealing with apiVersions, no one is served over the long run by making an anti-pattern easy to implement. I’m pretty sure all of us have been through a breaking change due to some version upgrade (not related to arm templates) that we weren’t expecting. Debugging this is rarely simple and never seems to happen at a convenient time ;)) With bicep we have a clean slate (more or less) to go think about a better way to deal with apiVersions, we should exhaust that first. @arsenvlad @slavizh – re: the TTK - regardless of whether we agree on best practices, we should at least try to make sure the tool chain doesn’t contradict itself. |
Would it be better if we have some special syntax for versions?
The downside will be that you need to define those. Additional code you need to enter. On the plus side you do not have to define those on resources. If you define them in resources it will override the one specified via using. On the plus side this can make the usage of versions easier for best practice implementation. Any thoughts? |
What were you thinking the resource declaration would look like if I do the
|
@alex-frankel If we went down this path, we could have rules for choosing the default alias as well. For example, the default alias could be |
Not bad idea for the 'as' option. This could also fulfill some requirements around aliases for RPs. I am not big fan of that idea but if folks want that we can shoot two birds with one stone. The 'as' part could allow you to use two different versions for the same RP although I have met such scenario only for one RP. The security one which in one RP version allows you to set resource with name default in other it does not. |
I love the idea of using Microsoft.Network/virtualNetwork@2019-06-01'
resource network virtualNetwork = {
...
}
resource subnet virtualNetwork/subnet = {
...
} If the sub-resource type needed a different version number take it from the resource definition, otherwise default to the version of the alias. resource subnet virtualNetwork/subnet@2020-05-01 = {
...
} |
I'd like to jump in here since I filed a duplicate of this and share my thoughts. I really like the idea of To the point earlier that having a @latest or string interpolation might have undesired effects, I get that concern, but the current approach of just repeating these blocks of strings (especially several times even after loops are introduced) just isn't ideal, especially as I have to continue to maintain these scripts. |
@WhitWaldo - if you have the |
@bmoore-msft Exactly - I'm sorry, my response earlier wasn't as clear as I intended. Someone earlier had mentioned the use of @latest, but I prefer the use of Using/as lets me put the number in a single place and says that if I need to use an older version for some particular resource, I'm easily able to. It's better than simply inserting the version in via string interpolation because it puts the entire string in a single place (resource + version). If I as the developer change it there, I can conceivably just use the IDE to find all the places I've used that variable and take responsibility for updating accordingly. |
Got it - thanks for clarifying... (turns out that "latest" is actually a github username... sorry about all the "@ latest" in this thread) |
Seems like stale issue. Commenting to know if there is an update on this i.e, how to have string interpolation in resource type string for defining apiVersion as variable. Checked #622, but no update there as well. |
Is your feature request related to a problem? Please describe.
Allow defining RP API version as variable
When I try to do something like this:
It is not possible. I would like to define the API version for RP as variable. This is a common practice for us to define the API versions as variables for different resources. For example if we have two or more resources for storage accounts define we can easily switch the API version for them by just changing the variable. This also allows us to easily see the different API versions we use in a single template without having to scroll trough all resources.
The text was updated successfully, but these errors were encountered: