Hi everyone. What would be the Pulumi way of refer...
# general
c
Hi everyone. What would be the Pulumi way of referencing subresources when creating a resource? I am trying to create an application gateway in Azure and I see that all the subresources are referenced explicitly in the examples, something I really need to avoid because their names should be dynamic based on environment and other parameters. Take the following example where I am adding subscriptionId and resourceGroup.name in the definition. I need to do the same with the application gateway name (appgw), frontend IP (appgwfip) and frontend port (appgwfp80), but so far I can only do that by referencing them explicitly as they are being created as part of the same resource:
Copy code
{
            frontendIPConfiguration: {
                id: pulumi.all([subscriptionId, resourceGroup.name])
                    .apply(([subscription, resourceGroup]) => `/subscriptions/${subscription}/resourceGroups/${resourceGroup}/providers/Microsoft.Network/applicationGateways/appgw/frontendIPConfigurations/appgwfip`)
            },
            frontendPort: {
                id: pulumi.all([subscriptionId, resourceGroup.name])
                    .apply(([subscription, resourceGroup]) => `/subscriptions/${subscription}/resourceGroups/${resourceGroup}/providers/Microsoft.Network/applicationGateways/appgw/frontendPorts/appgwfp80`)
            },
            name: `appgwhttplistener-${environmentLabel}`,
            protocol: "Http",
        },
f
hey @creamy-fall-88031, did you get anywhere with this? working on similar 🙂
c
Hey Ewan, sorry, Slack (unfortunately) is not my primary communication tool, so I tend to forget about it. Are you still working on this?
f
hey @creamy-fall-88031! I’ve shelved the work I was doing temporarily but will definitely need to do this at some point 🙂 I’d somewhat accepted the fact that I’m just going to have to construct the full resource IDs, unless you’ve found a smart way to achieve this?