https://pulumi.com logo
Title
p

prehistoric-house-26852

05/14/2023, 1:06 AM
Hi all, I have a use case where i'm using random.NewRandomPassword to generate password for a Kafka user. Using this to avoid recreation.
password, err := random.NewRandomPassword(ctx, "password", &random.RandomPasswordArgs{
		Length:          <http://pulumi.Int|pulumi.Int>(PasswordLength),
		Special:         pulumi.Bool(true),
		OverrideSpecial: pulumi.String("!#$%&*()-_=+[]{}<>:?"),
	})

	if err != nil {
		return nil, err
	}
	args.Password = password.Result

	user, err := kafka.NewUserScramCredential(ctx, fmt.Sprintf("%s", args.Username), args, pulumi.Provider(provider))
	if err != nil {
		return nil, err
	}
	ctx.Export("id", user.ID())
	ctx.Export("updatedAt", pulumi.StringPtr(fmt.Sprintf("%d", time.Now().Unix())))
	ctx.Export("password", password.Result)
For our usecase, we want to export this to context. However, it seems the passowrd.Result is rendered as [secret] instead of the actual string. Is there a way to get the actual string? I also tried
password.Result.ApplyT(func(pwd string) error {
		ctx.Export("password", pulumi.String(pwd))
		return nil
	})
but this does not seem get executed at all
b

billowy-army-68599

05/14/2023, 3:37 PM
@prehistoric-house-26852 you should just be able to do
ctx.Export()
and then use
pulumi stack output --show-secrets
p

prehistoric-house-26852

05/14/2023, 11:44 PM
Thanks We have a wrapper around pulumi, will look into this