Skip to content
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

scope property in deployment() function #4698

Open
slavizh opened this issue Oct 1, 2021 · 4 comments
Open

scope property in deployment() function #4698

slavizh opened this issue Oct 1, 2021 · 4 comments
Labels
enhancement New feature or request intermediate language Related to the intermediate language

Comments

@slavizh
Copy link
Contributor

slavizh commented Oct 1, 2021

Is your feature request related to a problem? Please describe.
We have function like subscription() and soon to have managementGroup(). There are a few resources that allow to deployed at both subscription and management group scopes. The difference when these resources are deployed at these two scopes are minor. For example the main differences I have seen are:

  • cannot deploy resource group at mg level
  • policy definition and assignment names needs to be maximum 24 characters at management group level (at sub level it is higher number). No idea why this limit exists but it is there.
    With that said if you want to create one bicep solution that can deploy the applicable resources to both scopes it is good that you can use managementGroup() or subscription() function depending on the scope the deployment happens.

Describe the solution you'd like
the solution would be something like:

var someVar = deployment().scope =~ 'subscription' ? subscription().id : managementGroup().id
@slavizh slavizh added the enhancement New feature or request label Oct 1, 2021
@ghost ghost added the Needs: Triage 🔍 label Oct 1, 2021
@slavizh
Copy link
Contributor Author

slavizh commented Oct 1, 2021

/cc @alex-frankel @anthony-c-martin

@alex-frankel alex-frankel added the intermediate language Related to the intermediate language label Oct 6, 2021
@alex-frankel
Copy link
Collaborator

In order for this property to be useful, do we need to finish #788?

@anthony-c-martin
Copy link
Member

In order for this property to be useful, do we need to finish #788?

That was my motivation for supporting it, because it allows Bicep to generate resourceId expressions that are scope-agnostic.

Note that I was imagining a different implementation to @slavizh though - I was thinking it would return the actual value of the scope - e.g. /subscriptions/<subId>, /subscriptions/<subId>/resourceGroups/<rgName>, / or /providers/Microsoft.Management/managementGroups/<mgName>.

That would allow Bicep to codegen resourceId expressions with the following format:

"[extensionResourceId(
    deployment().scope,
    'My.Rp/myType',
    variables('resourceName')
)]"

@slavizh
Copy link
Contributor Author

slavizh commented Oct 11, 2021

@anthony-c-martin I guess we just need to think of all the possible options for such scenario. Though probably there still might be useful to be able to use subscription() or managementGroup() depending on the scope. As they might use some of the properties in those functions for other functions like uniqueString, concat, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request intermediate language Related to the intermediate language
Projects
None yet
Development

No branches or pull requests

3 participants