https://pulumi.com logo
#dotnet
Title
# dotnet
f

future-kite-91191

02/19/2020, 8:04 AM
Good morning! I'm having a hard time to get value of an
Output<string>
Copy code
var randomStringResult = string.Empty;
            var randomString = new RandomPassword("random", new RandomPasswordArgs() { Length = 63 }).Result.Apply(v => randomStringResult = v);
I'm probably missing something obvious here? I need to generate a random password and need access to the generated string result
b

better-rainbow-14549

02/19/2020, 9:24 AM
it depends what you're using the generated result for
in general you'd use it within the actual apply method, but you shouldn't create new pulumi resources in there since they would be missing from any 'preview' steps
💯 1
t

tall-librarian-49374

02/19/2020, 10:36 AM
It’s not possible, because the generated value won’t be known until
up
is done with this resource. Any usage of the value has to stay within
Apply
m

millions-journalist-34868

02/20/2020, 3:43 PM
Speaking of
RandomPassword
, is there a way to keep the previous generated password ? When I use
RandomPassword
, each time I do a
pulumi up
a new password will be generated and my resources will all have to be updated even if nothing else has changed. I want to generate a password with radom instead of specifying one in my yaml stack file but I don't wan't it to change each time.
b

better-rainbow-14549

02/20/2020, 3:44 PM
it should keep the generated password in the state file so that shouldn't happen