https://pulumi.com logo
#golang
Title
# golang
b

bored-table-20691

05/24/2021, 8:29 PM
I noticed some awkwardness in getting an
int
/
IntOutput
value from a stack reference. Specifically, in one stack I did a
ctx.Export("db-port", <http://pulumi.Int|pulumi.Int>(5432)
, and then in another stack I had a reference to it. Since there isn’t a
GetIntOutput
option, I ended up having to do it manually with
ApplyT
, and then found out that the value comes across as a
float64
(I’m assuming due to the JSON encoding). I ended up with this utility function:
Copy code
func getIntOutput(ref *pulumi.StackReference, key string) pulumi.IntOutput {
	output := ref.GetOutput(pulumi.String(key))
	return output.ApplyT(func(port interface{}) int {
		return int(port.(float64))
	}).(pulumi.IntOutput)
}
I wanted to see if this was expected and also if the above solution is reasonable.
b

billowy-army-68599

05/24/2021, 8:31 PM
this looks like a bug, can you file an issue for it?
b

bored-table-20691

05/24/2021, 8:31 PM
Will do.
let me know if I can clarify anything - I just reproduced this to verify the error messages
3 Views