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

ripe-shampoo-80285

05/24/2021, 12:52 AM
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

billowy-army-68599

05/24/2021, 12:54 AM
you should be able to cast it with
cluster.Kubeconfig.(pulumi.StringOutput)
r

ripe-shampoo-80285

05/24/2021, 1:03 AM
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)
6 Views