Hi, How do I get generated password from this <htt...
# getting-started
s
b
there are examples in that doc
what are you struggling with>
m
Hi there! The generated password is available on the
result
property: https://www.pulumi.com/registry/packages/random/api-docs/randompassword/#result_nodejs
It’s wrapped in a
pulumi.Output<string>
, though, so depending on what you’re trying to do with the value, you might need to use the
apply()
method to get at it — for example:
Copy code
const password = new random.RandomPassword("password", {
    length: 16,
    special: true,
    overrideSpecial: `_%@`,
});

password.result.apply(unwrapped => console.log({ unwrapped }));
if you’re trying to use the value as an input for another resource, though, you should be able to pass
password.result
to that resource, as in the example on that page (to @billowy-army-68599’s point):
Copy code
const example = new aws.rds.Instance("example", {
    instanceClass: "db.t3.micro",
    allocatedStorage: 64,
    engine: "mysql",
    username: "someone",
    password: password.result,
});
Does that help? More info on
pulumi.Input
and
pulumi.Output
is available in the docs: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/
s
Ty!! I set up password for DB
now I want to get the password so I can manually connect DB
m
Ah, ok yeah. So if your DB is accessible,
apply
should get you the raw string.
s
Is there a way to retrieve it without touching the pulumi code?
ok, I see so I need to change pulumi code and using apply
Ty!
m
Yeah. In this case because it’s a
RandomPassword
resource, the value is stored encrypted as well, so you’ll pretty much need to run Pulumi to get at it.
s
can I put this into output?? and use pulumi stack output --show-secrets to get it??
m
Indeed, that’ll work too!
s
Ty Ty!! That’s helpful!
👍 1