How can I get the underlying value of an `Output`?
# general
b
How can I get the underlying value of an
Output
?
b
You can not get at the raw value during a
pulumi update
because in some cases it may not be known (for example, during a preview). You can, however, take any Output<T> and call .apply on it. Apply takes a function which gets the underlying value and allows you to transform it and then wraps the result in an Output<T>.
If you are capturing an output in like a cloud function and need the underlying value, you can call .get() on it, which gives you the raw value
but .get() will throw if you call it during a pulumi update.
If you want to log some value, to help debugging you can do: (<some-output>).apply(console.log); To log the value, but, if the value is not known (again, during a preview, for example) the apply simply won't run.
b
Thanks, somehow I figured that out in the meanwhile. 🙂
p
The actual raw value is only available in JS/TS, in Python it can only be an Input to another Pulumi resource.