Hi Pulumi, I'm trying to convert an Azure Secret ...
# general
n
Hi Pulumi, I'm trying to convert an Azure Secret to work with a VM extension for Azure Virtual Desktop in Golang. In the JSON, I require a password to auto-join the session hosts. To accomplish that I require the following (partial) JSON: {"Password":" "my-very-secret-key"} I retrieved the secret using keyvault.GetSecret(), however, I now need to convert a pulumi.StringOutput to a Go string for the JSON to be marshaled. pulumu.StringOutput will marshal empty. This is the actual relevant code:
Copy code
secret, err := keyvault.GetSecret(ctx, "my-secret", config.SessionHostConfig.KeyvaultSecretID, &keyvault.SecretState{})
	if err != nil {
		return err
	}
	
	type ADJoinExtensionProtectedConfig struct {
		Password string `json:"Password"`
	}

	jsonExtensionProtected := ADJoinExtensionProtectedConfig{
		Password: secret.Value, // Won't work StringOutput vs string mismatch
	}
	
	jsonExtensionProtectedResult, err := json.Marshal(jsonExtensionProtected)
	if err != nil {
		return err
	}
What would be the best way to accomplish this, any thoughts? Best regards, Jeroen
b
You cannot convert a output to a string, you need to resolve it inside an apply and then use it https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html
n
Thank you!