Good morning! I'm having a hard time to get value ...
# dotnet
f
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
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
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
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
it should keep the generated password in the state file so that shouldn't happen