Hi! I'm new to Pulumi and I'm having trouble with ...
# python
p
Hi! I'm new to Pulumi and I'm having trouble with the sometimes Output, sometimes Awaitable situation.
a
Hi, are you trying to define a resource or to obtain information on a resource that already exists?
p
Info on an existing resource and use that on new resources.
a
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
Yes, it returns an Awaitable that I don't know how to use.
a
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:
Copy code
subnet_ids = aws.ec2.get_subnet_ids(...)
subnet_ids.ids
would then get you a set of all the subnet ids
p
But I get an Awaitable I cannot use directly. What am I missing?
a
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
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
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
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
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
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