What is the right way to convert pulumi.StringOutp...
# golang
m
What is the right way to convert pulumi.StringOutput to a native string in Go?
h
try this:
.ElementType().String()
b
you can’t convert a string output to a string
what you can do, is resolve the value and then use it as a string. You do that with
ApplyT
m
I have created an ipv6 address with the hcloud provider, to create a rdns record for it I need to append a 1 (for the first real ip address), how should this be done? With ApplyT the result is still an Output type.
b
use
pulumi.Sprintf
m
Like this?
Copy code
&hcloud.RdnsArgs{
			PrimaryIpId: ipv6.ID().ApplyT(strconv.Atoi).(pulumi.IntOutput),
			IpAddress:   pulumi.Sprintf("%s:1", ipv6.IpAddress),
			DnsPtr: pulumi.String(strings.Join([]string{
				stack.config.Name,
				stack.config.Domain,
			}, ".")),
		},
b
should work
m
Yay... That worked...
Is something like
ipv6.ID().ApplyT(strconv.Atoi).(pulumi.IntOutput)
really the pulumi way to go to get the numeric ID of another created resource?
b
that’s likely a bug in the provider tbh, but yes that’s the canonical way
m
Great, thanks for the help. I have alrrady found an issue on the provider repository where somebody mentioned this as a possible solution.