How do I convert eks cluster,Kubeconfig from AnyOu...
# golang
r
How do I convert eks cluster,Kubeconfig from AnyOutput to StringOutput in the following: k8sProvider, err := providers.NewProvider( ctx, "k8sprovider", &providers.ProviderArgs{ Kubeconfig: cluster.Kubeconfig, }, pulumi.DependsOn([]pulumi.Resource{cluster})) if err != nil { fmt.Println(err.Error()) return err } Here ProviderArgs expect StringOutput, cluster.Kubeconfig is an AnyOutput.
b
you should be able to cast it with
cluster.Kubeconfig.(pulumi.StringOutput)
r
I tried and get this error: invalid operation: cluster.Kubeconfig (variable of type pulumi.AnyOutput) is not an interface
Looks like this might be similar to this issue: https://github.com/pulumi/pulumi/issues/6073
Here is my workaround:
cluster.Kubeconfig.ApplyT(func(v interface{}) string {
jsonBytes, _ := json.Marshal(v)
return string(jsonBytes)
}).(pulumi.StringOutput)