https://pulumi.com logo
#general
Title
# general
l

limited-rainbow-51650

07/19/2019, 2:07 PM
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

broad-football-5123

07/19/2019, 2:29 PM
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

limited-rainbow-51650

07/19/2019, 2:42 PM
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

broad-football-5123

07/19/2019, 2:48 PM
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

microscopic-florist-22719

07/19/2019, 3:18 PM
Yeah, I'd love to understand the scenario better.
b

better-rainbow-14549

07/19/2019, 3:49 PM
@broad-football-5123 FYI that string example can use pulumi.interpolate`http://${virtualMachine.dnsname}` now
b

broad-football-5123

07/19/2019, 3:50 PM
Yes. That’s further down in the documentation and my favorite.