-
Notifications
You must be signed in to change notification settings - Fork 762
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
Existing resource based on id (as opposed to name) #1722
Comments
@anthony-c-martin - something that we've discussed recently :) |
I started a discussion as well around this very thing: #1709 |
Adding for reference - some ideas of declaring existing resource as one-liner I did mention in #127 (comment), could be part of the fix for this issue. |
This comes up a lot when wiring up things like storage accounts and log analytics workspace -- they're often created in a different resource group or even a subscription, for various security reasons or just for having consolidation of logs in one place. This means that most templates would need the full resource ID fed in as a parameter, not a name. |
I think this makes sense. I think we could make this work in bicep fairly easy, but I am wondering if we should have native support for passing resource IDs around in the runtime. This way we would also get runtime enforcement of the IDs. (Which would catch accidentally passing the ID of a wrong type.) |
I've been advocating for Bicep to have a "strongType" capability vaguely similar to what Blueprints can do. That would enormously improve the utility of the entire template-based ecosystem. The Portal could provide a much nicer interface (selectors instead of text boxes), PowerShell could tab-complete on the actual resources available, parameters could be validated better, etc... |
Closing and tracking with #2245/#2246 which should solve this. In the meantime, you can use the var idToSplit = '/subscriptions/e93d3ee6-fac1-412f-92d6-bfb379e81af2/resourceGroups/alfran-redhat/providers/Microsoft.Compute/virtualMachines/adotfrank-rh'
var splitId = split(idToSplit, '/')
resource existingVm 'Microsoft.Compute/virtualMachines@2021-07-01' existing = {
scope: resourceGroup(splitId[2], splitId[4])
name: splitId[8]
} |
Is your feature request related to a problem? Please describe.
I have some arm templates where I take in resource IDs (instead of names). While most of these are in the same resource group (and as such, changing to use the name is pretty straight forward), some of them are not, and I then have to split up into providing both a name and a scope.
Describe the solution you'd like
I would like to be able to create an "existing resource" with a resource-id. I suggest allowing the use of the
existing
syntax with either(name, [scope])
or(id)
, allowing the following:The text was updated successfully, but these errors were encountered: