Hi everyone, As part of my stack config I want to ...
# azure
m
Hi everyone, As part of my stack config I want to reference full azure resource IDs that are later looked up in the code (using go azure native sdk). Is there way to do the lookup using the azure resource id sor do I have to manually parse and split the IDs into sub/rg/resource name?
q
m
thank you for your reply! So not exactly this. Let's say I have to instantiate my pulumi providers at runtime (because I am deploying resource on 2 differents kube clusters, aks to be precise), I would like to specify in my config "primaryCluster: /subscriptions/xxx/resourceGroup/yyy/..." (same as an ARN in aws). It seems that I then need to split the string to extract the xxx, yyy and so on and I am surprised not to see a pulumi routines that would do it. Otherwise my "workaround" is to specify all parts of the resource ID, i.e.
Copy code
primaryCluster:
  subscription: xxx
  resourceGroup: yyy
  name: zzz
q
oh, so you'd like to have something like such extension methods?
Copy code
public static Output<string> GetResourceGroupName(this DatabaseAccount databaseAccount)
{
    var resourceGroupName = databaseAccount.Id.Apply(id =>
    {
        var parts = id.Split('/');
        return parts.Length >= 5 ? parts[4] : "";
    });

    return resourceGroupName;
}
I create such when needed but it's walkaround too
👍 1
m
I guess I will end up doing it like you 😉 It's just that I would have prefer not to handle the split myself and I think the provider (azure-native for instance) it should be the one providing this functionnality