https://pulumi.com logo
Title
b

brash-painting-89833

04/29/2023, 9:36 PM
Does anyone have any info on how to convert
pulumi.StringOutput
to base64?
b

bitter-energy-6777

04/30/2023, 2:57 PM
One way to do this could be to convert the
pulumi.StringOutput
to a string, convert the string to a byte slice, and create a
base64
encoded string from the byte slice:
// convert pulumi.StringOutput to a string
stringOutput := fmt.Sprintf("%v", <insert your pulumi.StringOutput>)

// convert string to byte slice
bytes := []byte(stringOutput)

// encode the byte slice in base64
encoded := base64.StdEncoding.EncodeToString(bytes)
b

brash-painting-89833

05/01/2023, 1:10 PM
thank you,i will try it here!
i must be doing something wrong, cause it seems i get an address
{0xc0003798f0}
i basically return this:
return pulumi.Sprintf(...)
inside i a string with some
%s
as
pulumi.StringOutput
arguments..
`func generateUserData(clusterEndpoint pulumi.StringOutput, certData pulumi.StringOutput, clusterName pulumi.StringOutput, extraRuntime string) pulumi.StringOutput {
	return pulumi.Sprintf(`
[settings.kubernetes]
api-server = "%s"
cluster-certificate = "%s"
cluster-name = "%s"

[settings.kubernetes.node-labels]
"extraRuntime" = "%s"
"host-os" = "bottle-rocket"
`, clusterEndpoint, certData, clusterName, extraRuntime)
}
Then:
userData := generateUserData(eksCluster.EksCluster.Endpoint(), eksCluster.EksCluster.CertificateAuthority().Data().Elem(), eksCluster.EksCluster.Name(), "default")
	stringOutput := fmt.Sprintf("%v", userData)
	fmt.Println(stringOutput)

	// convert string to byte slice
	bytes := []byte(stringOutput)

	// encode the byte slice in base64
	encoded := base64.StdEncoding.EncodeToString(bytes)
	fmt.Println(encoded)
i will, debug more wheni have some time