why does requiring stack outputs return an `Output...
# typescript
b
why does requiring stack outputs return an
Output<T>
instead of just
T
or
Promise<T>
? stack outputs will be known at preview time but since they return
Output<T>
i can't use those values until deploy time
r
Output<T> is essentially like Promise<T>. Except that instead of
.then()
you have to use
.apply()
to access the unwrapped value.
b
yeah i know, but the output of an
apply
is another
Output<T>
whereas with a promise I can
await
it and access the underlying value at preview time
r
You can still access the value of Output at preview time if the value is known
You just have to do it within the apply
Is there something that isn’t doing what you expect?
b
let me throw together some example code
l
I don't think you can guarantee that stack outputs will be known at preview time. It wouldn't be safe to assume that the outputting stack is not currently being deployed...
Or even that the stack is local / on your machine. You could (and frequently, are) getting those outputs from a stack at api.pulumi.com or S3. These have the same async requirements as deploying to a remote API or S3...
b
yeah that makes sense but wouldn't that same issue occur at deploy time too? ie if I'm deploying a resource in
Stack A
using a stack output from
Stack B
, what happens if
Stack B
is deploying while
Stack A
is using that output?
how does
requireOutput()
behave in that scenario?
l
I, for one, am happy to trust our new Pulumi overlords! (that it'll be alright once Pulumi looks after resolving dependencies)
🪄 1
partypus 8bit 1