https://pulumi.com logo
Title
v

victorious-exabyte-70545

02/24/2023, 8:20 PM
Hi all. I have a question about getting information on a resource using get_? but only after the resource has been created. I have an issue where outputs for a resources (that are documented) are not a part of the resource object that I have created (another issue). For example, if I create a private endpoint resource, and use get_private_endpoint, I only want that to run after the private endpoint has been created. Is that possible?
b

billowy-army-68599

02/24/2023, 9:18 PM
if you pass an output from the private endpoint to the
get_private_endpoint
it should happen correctly There’s an open issue to make this more concise: https://github.com/pulumi/pulumi/issues/2545
v

victorious-exabyte-70545

02/24/2023, 9:36 PM
got it. So I could use <resource>.name or something. This would create a dependency on resource creation before the invoke of get_ is run?
b

billowy-army-68599

02/24/2023, 9:38 PM
Yep!
v

victorious-exabyte-70545

02/24/2023, 9:38 PM
Thanks so much!!!
I tried it and get incorrect type:
b

billowy-army-68599

02/24/2023, 9:49 PM
Use the output method get_private_endpoint_output
v

victorious-exabyte-70545

02/25/2023, 12:19 AM
That works. Now I want to take the output and give it to another get_ command. but I need the output manipulated.
endpoint = get_private_endpoint_output(
        private_endpoint_name=aks_private_endpoint.name,
        resource_group_name=f"{stack_name}-datascience"
    )

    get_network_interface_output(
        network_interface_name=endpoint.network_interfaces[0]['id'].split("/")[-1],
        resource_group_name=f"{stack_name}-datascience"
    )
I get
network_interface_name=endpoint.network_interfaces[0]['id'].split("/")[-1],
    TypeError: 'Output' object is not callable
Is this where I do an apply?
b

billowy-army-68599

02/25/2023, 12:31 AM
yep, you’ll need to id it inside an apply
v

victorious-exabyte-70545

02/25/2023, 1:35 AM
OMG it worked!!!!
endpoint = get_private_endpoint_output(
        private_endpoint_name=aks_private_endpoint.name,
        resource_group_name=f"{stack_name}-datascience"
    )

    nic = get_network_interface_output(
        network_interface_name=endpoint.apply(lambda e: e.network_interfaces[0]['id'].split("/")[-1]),
        resource_group_name=f"{stack_name}-datascience"
    )
Thanks!!!