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

silly-stone-79070

05/27/2020, 8:10 AM
Hi all, I have used pulumi a fair amount in JS. But I have recently started using it in golang. In the golang implementation how do I use outputs, e.g the IP address of a network interface as an input for another object? So far I have been running an Apply on the output, then exporting using
ctx.Export
and finally to use it doing
ctx.GetConfig
. This just seems like jumping through hoops though so surely there is a better way I don't know about? Cheers
f

famous-jelly-72366

05/27/2020, 8:25 AM
Out of interest, why did you switch to golang? Personally using TS, but also have golang coding exp.
s

silly-stone-79070

05/27/2020, 8:31 AM
We recently did a project in golang it really enjoyed it so thought we would use it for this new project. I have actually just found that after the Apply func you can do:
Copy code
rancherInstanceInternalIP := rancherInstance.NetworkInterfaces.ApplyT(func(iface []compute.InstanceNetworkInterface) *string {
			return iface[0].NetworkIp
		}).(pulumi.StringPtrInput)
// The change I have made here is adding .(pulumi.StringPtrInput) to make it a usable input
i

important-appointment-55126

05/27/2020, 3:03 PM
@silly-stone-79070 can’t you just use the value directly at the point you need the input? Pulumi should figure out the details on resolving it itself
s

silly-stone-79070

05/27/2020, 3:56 PM
I ended up going with typescript as I found the whole experience of pulumi in go more effort
f

famous-jelly-72366

05/29/2020, 7:17 AM
TS in vscode is a very nice DevX :)