This message was deleted.
s
This message was deleted.
g
Is this the right way to go about it?
Copy code
stack_name = 'jan/proj/core'
class MyZone(BaseModel):
    zone_id: str
    force_destroy: bool


async def fun():
    ref_zone = pulumi.StackReference(stack_name)
    print('lol')
    result = await ref_zone.outputs.future()
    print(result)
    my_zone = MyZone.parse_obj(result['my_zone'])
    print(my_zone)

   # ... contiune creating my resources here

loop = asyncio.get_running_loop()
loop.create_task(fun())
@billowy-army-68599 maybe you'd know?
b
no I don't think it's going to work because it's not known at runtime
r
Does something like this work?
Copy code
def create_ref_zone_pd(ref_zone):
    return MyZone(**ref_zone)

my_zone_pd = ref_zone.require_output.apply(create_ref_zone_pd)
g
@red-match-15116 Hmm this would basically put me in the bucket of creating resources inside
apply
because anything coming out of
apply
is an Output so I cannot use
my_zone_pd.zone_id
r
Do you mean you can’t use
my_zone_pd.zone_id
as an input to another resource? Because you can use an
Output
as an
Input
(since
Input
is the union of
Output[T]
and
T
)
g
The problem with that is that I do get an Output not a convenient object I created
@billowy-army-68599 This worked, but I do not know enough about async to say why it worked
Copy code
async def fun():
    ref_zone = pulumi.StackReference(stack_name)
    print('lol')
    result = await ref_zone.outputs.future()
    print(result)
    my_zone = MyZone.parse_obj(result['my_zone'])
    print(my_zone)
    ec2.SecurityGroup(
        f"mhh{my_zone.zone_id}"
    )

loop = asyncio.get_running_loop()
loop.create_task(fun())