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

Strongly-typed ResourceID #3230

Open
stan-sz opened this issue Jun 15, 2021 · 4 comments
Open

Strongly-typed ResourceID #3230

stan-sz opened this issue Jun 15, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@stan-sz
Copy link
Contributor

stan-sz commented Jun 15, 2021

Is your feature request related to a problem? Please describe.
Given a full resource ID to a child resource have the ability to create a resource ID of the parent.

Excerpted from #3173: some RPs provide a full resource ID to some other (child) resources. For example: Microsoft.Network/loadBalancers provides the full ip configuration resource ID in its properties 'backendAddressPools[0].properties.backendIPConfigurations[0].id' as:

{
  "id": "/subscriptions/<sub ID>/resourceGroups/<rg name>/providers/Microsoft.Compute/virtualMachineScaleSets/<vmss name>/virtualMachines/0/networkInterfaces/<nic name>/ipConfigurations/<ipconfig name>"
},

Describe the solution you'd like

  • Idea 1: have a type resourceID that can be initiated using a string (or the output of *resourceId() function). The type could allow .parent to obtain the parent resource ID.

  • Idea 2: similar to above but using a new parentResourceId(<child resource ID>) function

@anthony-c-martin
Copy link
Member

Great suggestion!

@ishepherd
Copy link

I'm interested in using these ResourceID objects in the resource existing scenario

resource foo 'foo@date' existing = {
  id = ResourceID
}

This would be a convenient way for modules to reference things created by other modules.
Only one module param required, instead of 3.

@alex-frankel
Copy link
Collaborator

I'm interested in using these ResourceID objects in the resource existing scenario

This should be resolved with #2245 and #2246

@jeskew jeskew pinned this issue Jun 6, 2022
@jeskew jeskew unpinned this issue Jun 6, 2022
@jeskew
Copy link
Member

jeskew commented Jun 8, 2022

I don't know if we have a great way to identify ID fields returned by resources. The specific field mentioned by @stan-sz (backendAddressPools[0].properties.backendIPConfigurations[0].id on a Microsoft.Network/loadBalancers resource) is a property named id on an object with the x-ms-azure-resource extension, but I'm not sure if that pattern is followed reliably enough by resource providers to be a good heuristic.

@jeskew jeskew self-assigned this Jun 8, 2022
@jeskew jeskew added this to Bicep Jun 8, 2022
@jeskew jeskew moved this to Todo in Bicep Jun 8, 2022
@jeskew jeskew removed their assignment Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

5 participants