https://pulumi.com logo
Title
p

purple-arm-63328

11/16/2020, 9:07 PM
Hi! I'm new to Pulumi and I'm having trouble with the sometimes Output, sometimes Awaitable situation.
a

ambitious-father-68746

11/16/2020, 9:19 PM
Hi, are you trying to define a resource or to obtain information on a resource that already exists?
p

purple-arm-63328

11/16/2020, 9:19 PM
Info on an existing resource and use that on new resources.
a

ambitious-father-68746

11/16/2020, 9:20 PM
So you can do aws.ec2.get_subnet_ids(). You don't need to pass a resource name
You can see here that you have ways of creating new resources and also "Functions" which are mainly used to obtain information on resouces that don't have to be managed by Pulumi. https://www.pulumi.com/docs/reference/pkg/aws/ec2/
p

purple-arm-63328

11/16/2020, 9:21 PM
Yes, it returns an Awaitable that I don't know how to use.
a

ambitious-father-68746

11/16/2020, 9:21 PM
If you create a resource with Pulumi, then you already have all the information related to it.
Check the Outputs on that page. You have "id", "ids", "tags", "vpc_id" and "filters"
So something like this:
subnet_ids = aws.ec2.get_subnet_ids(...)
subnet_ids.ids
would then get you a set of all the subnet ids
p

purple-arm-63328

11/16/2020, 9:30 PM
But I get an Awaitable I cannot use directly. What am I missing?
a

ambitious-father-68746

11/16/2020, 10:02 PM
You're right, it does seems iffy. I'm trying and even with the example provided it doesn't work
OK, let's get back to the basics: what are you trying to do?
p

purple-arm-63328

11/16/2020, 10:14 PM
I'm testing out Pulumi to see if it's sensible to use. So far: no. 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.
I can get the subnet IDs as an Awaitable but I don't know how to await it.
I tried to instantiate a Vpc object and use
a_vpc.id.apply(...)
thing as a wrapper for the Awaitable but it just filled my RAM.
a

ambitious-father-68746

11/16/2020, 10:51 PM
It's really unfortunate. I personally think Pulumi has some rough edges, but it's the most capable tool. I'm sorry that you've hit this problem so early in your evaluation and I'm sorry that I haven't been able to help.
I don't think Awaitable is the problem here, it's just bad documentation (it's auto-generated from Terraform in this case)
p

purple-arm-63328

11/16/2020, 11:24 PM
A real programming lang makes a big difference for us but it does not seem to be well maintained. Maybe it's just Python and JS is working great.
a

ambitious-father-68746

11/17/2020, 9:22 AM
That has definitely not been my experience. Developers are usual on top of things and bugs are addressed in a timely manner.
I think you just hit a snag. I would suggest creating a bug report and see how it goes from there.
p

purple-arm-63328

11/17/2020, 1:04 PM
But the doc has invalid code and iterating over an Output (I suppose a common rookie mistake) has an open issue since July (https://github.com/pulumi/pulumi/issues/5028). Additionally, although the code is asynchronous, it does not use
asyncio
but instead implements a JS like interface.
❤️ 1