https://pulumi.com logo
Title
e

elegant-smartphone-60282

08/25/2022, 12:07 PM
Hey i have this code
public_subnets = dis_stack.get_output("public_subnets")

subnets_list = public_subnets.apply(lambda id: id)
but it returns an output object, how can i do that i get a list ?
f

freezing-van-87649

08/25/2022, 12:36 PM
you can't, it's like working with futures. You can use the output in an apply, but you can't just get the actual value. What are you trying to accomplish?
e

elegant-smartphone-60282

08/25/2022, 12:37 PM
passing the subnets list to an ELB resource as input
f

freezing-van-87649

08/25/2022, 12:38 PM
Can't you just pass it as is (wrapped in an Output) to the ELB resource?
e

elegant-smartphone-60282

08/25/2022, 12:38 PM
1 min ill send you the error i ge
t
AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'
but when i print the type of the public_subnets i get this
print(type(public_subnets))
<class 'pulumi.output.Output'>
f

freezing-van-87649

08/25/2022, 12:41 PM
So Output is a wrapper object. I think the issue might be that you have an Output[Str] when you want an Output[List[str]]
you could maybe try adding some debugging/print statements in the apply lambda to see what the actual value is
e

elegant-smartphone-60282

08/25/2022, 12:42 PM
the output is an output from another stack that i exported it like this
pulumi.export("public_subnets", public_subnets.ids)
f

freezing-van-87649

08/25/2022, 12:43 PM
I'm not sure how output serialization/deserialization works
p

powerful-lunch-15492

08/25/2022, 12:43 PM
if you stop with a break point inside the applys lambda you will have a string. because that runs inside pulumi engine.
e

elegant-smartphone-60282

08/25/2022, 12:44 PM
i dont understand @powerful-lunch-15492
how ?
p

powerful-lunch-15492

08/25/2022, 12:51 PM
check this
pritunl_output = instance.public_ip.apply(
            lambda public_ip: {
                "host": f"https://{public_ip}",
            },
        )
pulumi.export("pritunl-data", pritunl_output)
instace is an ec2 instace
import ipdb
clusters = aws.eks.get_clusters()
def method(args):
    ipdb.set_trace()
    print(args)

pulumi.Output.all(clusters).apply(
    lambda args: method(args),
)
for example
e

elegant-smartphone-60282

08/25/2022, 12:53 PM
umm, nvm guys i figured it out thanks any way
👍 1