From a resource, I have an `Output<string>`....
# general
l
From a resource, I have an
Output<string>
. The value in it is the string version of a number. How can I get the number value as an input for another resource?
b
Outputs are similar to promises/futures, it can be accepted as an Input or if you want a value inside, you’ll need to use the apply method. https://www.pulumi.com/docs/reference/programming-model/#apply
Copy code
let url = virtualmachine.dnsName.apply(dnsName => "https://" + dnsName)
l
Tnx, this did it:
namespaceId: groups.safeimage.id.apply(s => +s)
👍 1
Side question: if you have an
Output<string>
, how can you get the
string
? Asking because the new
import
functionality does not accept an
Output<string>
b
I’ll have to ask someone about that. You can do
.get()
to get the underlying value but it will throw an execption if run during deployment or preview. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#OutputInstance-get
How are you getting these Outputs whose values you want to use in the import?
m
Yeah, I'd love to understand the scenario better.
b
@broad-football-5123 FYI that string example can use pulumi.interpolate`http://${virtualMachine.dnsname}` now
b
Yes. That’s further down in the documentation and my favorite.