https://pulumi.com logo
#python
Title
# python
i

icy-dress-83371

03/29/2021, 7:06 PM
HI all, excuse my stupidity here, but I am trying to work off of an Azure example that is written in typescript (which I am not supoer competent in) wonder if anyone could help convert this pulumi block to python:
Copy code
const resourceId = (resource: string) =>
  pulumi
    .all([resourceGroup.name, currentSubscription])
    .apply(
      ([resourceGroupName, subscription]) =>
        `/subscriptions/${subscription.subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Network/applicationGateways/${applicationGatewayName}/${resource}/${defaultName}`
    );
Basically, I am trying to build a resource string, where part of the values are coming from other pulumi components, while some are plain python variables. I don't have a ton of experience with python lamdas either, so I am a bit stuck
h

handsome-state-59775

03/29/2021, 7:18 PM
Copy code
pulumi.Output.all(resource_group.name, current_subscription).apply(
        lambda args: # do whatever here with args[0] and args[1]
)
try this out?
i

icy-dress-83371

03/29/2021, 7:21 PM
thanks @handsome-state-59775 I ended up skipping the lambda and trying out pulumi's output.concat.
👍🏽 1
Copy code
def get_resource_id(resource_type):
    return Output.concat("/subscriptions/",subscription_id,"/resourceGroups/",resource_group.name,"/providers/Microsoft.Network/applicationGateways/",application_gateway_name,"/",resource_type,"/",default_name)
👍 1
s

some-elephant-30417

04/04/2021, 8:47 AM
I would pass all parameters to the
get_resource_id
instead of depending on variables outside of its scope though