Extract subscription ID, resource group name, and resource name from resource ID? #8850
Answered
by
SvenAelterman
SvenAelterman
asked this question in
Q&A
-
I know there are some open issues for creating new functions that can reference existing resources using their resource ID. In the meantime, if I have a resource ID as a parameter (I would know which resource type it is), can I extract the subscription ID, resource group, and resource name from a resource ID string so I can define it as an existing resource? |
Beta Was this translation helpful? Give feedback.
Answered by
SvenAelterman
Nov 7, 2022
Replies: 1 comment 4 replies
-
This is a workaround I currently use, but it feels brittle:
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @rebuildtech,
What I am really trying to accomplish is create a symbolic reference to an existing resource. What I have (as input to a module) is a full resource ID.
It's not currently possible to define an existing resource using a full resource ID. So, I am looking for a method to parse that into its component pieces, such as the subscription, resource group, and resource name.
The
split
function works, but because it relies on hardcoding the array index of each element, it feels brittle.