Thread
#getting-started
    c

    creamy-fall-88031

    4 months ago
    Hi all. General TypeScript related question. I need to reference user managed identity as seen in the following code snippet taken from the docs:
    identity: {
            type: azure_native.network.ResourceIdentityType.UserAssigned,
            userAssignedIdentities: {
                "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1": {},
            },
        },
    Now, I'm trying to change resource path in the example above with something more dynamic, so did the following:
    let userIdentity = pulumi.all([subscriptionId, resourceGroup.name, userAssignedIdentity.id])
                       .apply(([subscriptionId, resourceGroup, usrAssignedIdentity]) => `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/${usrAssignedIdentity}`)
    And then used it as follows:
    identity: {
        type: azure_native.network.ResourceIdentityType.UserAssigned,
        userAssignedIdentities: {
            ${userIdentity} : {},
        },
    },
    But this doesn't seem to be working when the variable
    {$userIdentity}
    is on the left of the colon sign. I'm getting the following error:
    error: Code="LinkedInvalidPropertyId" Message="Property id 'userIdentity' at path '' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."
    Can someone please help me with the proper way to do this ?
    o

    orange-policeman-59119

    4 months ago
    You're using typescript? Try creating the object that has the key (the object after "userAssignedIdentities😊 inside an Apply block
    Like:
    userAssignedIdentities: userIdentity.apply(x => ({
      [x]: {}
    })
    c

    creamy-fall-88031

    4 months ago
    And that did the trick. Thank you very much!
    o

    orange-policeman-59119

    4 months ago
    Yeah! That Azure API is a weird one, a map with keys and empty objects 🤦‍♂️
    In case it ever comes up again or you see something similar, the Pulumi engine generally expects keys of objects or maps in all languages to be strings, not Output<string>
    c

    creamy-fall-88031

    4 months ago
    I still have nightmares because of ARM templates. So I don't complain too much. This is much better and quite refreshing. 😄