Being able to reference resources across modules? #1170
-
There's a lot of useful stuff you can do once you have a symbolic reference to a resource - property access, proper type validation, deploying extension resources, deploying child resources, and probably some other things I'm not thinking of. This is at odds with It's great that we have these capabilities within one file, but it feels a bit limiting that they are confined to within that file. This limits my ability to modularize my code. For example being able to define a reusable template that deploys an extension resource: // main.bicep
resource myParent 'My.Rp/parent@2020-01-01' = {
...
}
module deployExtensions './extensions.bicep' = {
...
params: {
// pass the ref to the parent
parent: parent
}
}
// access the ref for the extension resource
var extensionRef = deployExtensions.outputs.extension1 // extensions.bicep
// mockup for a resource reference parameter
param parent resource<'My.Rp/parent@2020-01-01'>
// access properties from parent with type safety
var myParentProp = parent.properties.foo
// deploy an extension resource
resource extension1 'My.OtherRp/extension@2020-01-01' = {
scope: parent
...
}
// mockup to output the resource reference
output myExtension resource<'My.OtherRp/extension@2020-01-01'> = extension1 Just wanted to start a discussion to see if this is potentially interesting to anyone, there are any potential other use-cases that I haven't thought of, or workarounds to do something similar today! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 17 replies
-
I think overall the scenario is super useful and we should support it. One big unknown in my mind right now is how we approach visibility of exported resources. Do we make that explicit or do we just expose everything? Based on feedback, I think we have users in both camps. |
Beta Was this translation helpful? Give feedback.
I think overall the scenario is super useful and we should support it. One big unknown in my mind right now is how we approach visibility of exported resources. Do we make that explicit or do we just expose everything? Based on feedback, I think we have users in both camps.