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

steep-florist-33509

03/29/2021, 6:28 PM
Hey, I have this block to get the IP address of the loadbalancer:
Copy code
loadBalancerIP := chart.GetResource("extensions/v1beta1/Ingress", "server", "default").
	ApplyT(func(input interface{}) pulumi.StringOutput {
		ingress := input.(*v1beta1.Ingress)
		return ingress.Status.LoadBalancer().Ingress().Index(<http://pulumi.Int|pulumi.Int>(0)).Ip().Elem()
	})

ctx.Export("loadBalancerIP", loadBalancerIP)
The IP shows as expected from the
Export
but I want to use the IP in a DNS record:
Copy code
_, err = dns.NewRecordSet(ctx, "serverRecordSet", &dns.RecordSetArgs{
  Rrdatas: pulumi.StringArray{loadBalancerIP},
  [snip]
loadBalancerIP is of type
pulumi.Output
, not
pulumi.StringOutput
so it isnโ€™t accepted. Anybody have a hint on how I can handle the conversion?
โœ… 1
b

billowy-army-68599

03/29/2021, 7:32 PM
i think you might be able to do
loadBalancerIP.(pulumi.StringOutput)
s

steep-florist-33509

03/29/2021, 7:42 PM
thanks for the feedback, applying the type directly like this I get a panic
Copy code
interface conversion: pulumi.Output is pulumi.AnyOutput, not pulumi.StringOutput
when running
pulumi up
w

white-balloon-205

03/29/2021, 7:59 PM
Looks like you are running into https://github.com/pulumi/pulumi/issues/6073. As noted in the latest comment there - you should be able to workaround that with this:
Copy code
// To workaround #6073, convert from `interface{}` to `string`
x1 := x.ApplyT(func(v interface{}) string {
    return v.(string)
}).(pulumi.StringOutput)
๐Ÿ™Œ 2
s

steep-florist-33509

03/29/2021, 8:12 PM
Thanks! That solved my issue!
g

green-musician-49057

03/29/2021, 8:58 PM
Hah I was running into a similar issue, praise be!
๐Ÿ‘ 2
3 Views