https://pulumi.com logo
Title
p

purple-arm-63328

11/16/2020, 9:32 PM
@gentle-diamond-70147 could you look at my second question?
g

gentle-diamond-70147

11/16/2020, 9:33 PM
Which one was that?
p

purple-arm-63328

11/16/2020, 9:36 PM
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

gentle-diamond-70147

11/16/2020, 9:48 PM
I'm afraid that's beyond my familiarity with Python.
p

purple-arm-63328

11/16/2020, 9:54 PM
Thanks.
c

clean-dentist-2515

11/16/2020, 9:59 PM
most things return an
Output
which is like a future or promise the idiom I've seen elsewhere in the docs is:
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

purple-arm-63328

11/16/2020, 10:11 PM
This particular case does not.
c

clean-dentist-2515

11/16/2020, 10:14 PM
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

purple-arm-63328

11/16/2020, 10:14 PM
No, it fails.
c

clean-dentist-2515

11/16/2020, 10:14 PM
oh 😞 I have no idea, sorry
p

purple-arm-63328

11/16/2020, 10:15 PM
🙏
c

clean-dentist-2515

11/16/2020, 10:30 PM
https://github.com/pulumi/pulumi/blob/78edb28590887593c91ffcb31baa52286150528f/sdk/python/lib/pulumi/output.py#L273 maybe...
output = Output.from_input(get_subnet_ids(...))
value = output.apply(lambda val: val)
...can work? 🤷‍♂️
p

purple-arm-63328

11/16/2020, 10:36 PM
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

gentle-diamond-70147

11/16/2020, 11:35 PM
@purple-arm-63328 can you share more about what you're trying to achieve?
p

purple-arm-63328

11/16/2020, 11:47 PM
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

gentle-diamond-70147

11/16/2020, 11:55 PM
Here's an example that might get you started down the right path.
p

purple-arm-63328

11/17/2020, 1:11 AM
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