<@UDEJ1F5SQ> could you look at my second question?
# python
p
@gentle-diamond-70147 could you look at my second question?
g
Which one was that?
p
Javier Ruere When using aws.ec2.getSubnetIds , how do I get the result? I tried to run_until_completion the Awaitable but the loop is already running. Is there a way to have the main be an async function?
g
I'm afraid that's beyond my familiarity with Python.
p
Thanks.
c
most things return an
Output
which is like a future or promise the idiom I've seen elsewhere in the docs is:
Copy code
real_value = some_output.apply(lambda val: val)
apply
gives you the chance to modify the returned value I'm not sure if there's a shortcut for when you just want the resolved value unchanged I don't think you have to interact with any async event loop stuff directly
p
This particular case does not.
c
https://github.com/pulumi/pulumi-aws/blob/master/sdk/python/pulumi_aws/ec2/get_subnet_ids.py it returns a
AwaitableGetSubnetIdsResult
? if you try to access properties on that object like
.ids
do they return an
Output
?
p
No, it fails.
c
oh 😞 I have no idea, sorry
p
🙏
c
https://github.com/pulumi/pulumi/blob/78edb28590887593c91ffcb31baa52286150528f/sdk/python/lib/pulumi/output.py#L273 maybe...
Copy code
output = Output.from_input(get_subnet_ids(...))
value = output.apply(lambda val: val)
...can work? 🤷‍♂️
p
I tried something like that but not exactly. It still didn't work. Eventually I need to iterate over the values anyway... I don't know what to do.
g
@purple-arm-63328 can you share more about what you're trying to achieve?
p
The particular test I'm running requires to get one VPC (not managed), get some subnets (not managed) and create a Spot Fleet in there configured to use the selected subnets. I need the IDs of the subnets for the LaunchConfiguration and I need to specify one subnet ID per LaunchConfiguration AFAICS.
g
Here's an example that might get you started down the right path.
p
Thank you. I'll give it a try.
Thanks for that. There was an additional problem where iterating over an Output would result in all memory being used. By inverting the iteration and using an
apply
, it started working. 🙏
👍 1