Quick question: How to convert `pulumi.Output<...
# typescript
f
Quick question: How to convert
pulumi.Output<string>
to a
string
? given
Copy code
const pass = new random.RandomPassword("password", { length: 20, special: true },{additionalSecretOutputs: ["password"]}).result;
I want to use
pass
as a string to set other resources.
Copy code
const dbuser = new gcp.sql.User(`${user}-database-user`, {
    instance: instanceName,
    name: user,
    password: pass.apply(p => p.toString()),
    host: "cloudsqlproxy~%"
});
using
apply
like the following throughs errors
Copy code
pass.apply(p => p.toString()
r
The only way I found is to use `pulumi.interpolate`; I also couldn't make
apply
work; something like
Copy code
const dbuser = new gcp.sqlUser('...', {
  // ...,
  name: pulumi.interpolate`${name}`,
});
f
When I use what u suggest I got
Argument of type 'Output<string>' is not assignable to parameter of type 'string
interpolate
returns
Output<string>
so it doesn’t really solve my issue
r
But usually, you should be able to use
Output<string>
as input... 🤔
f
You should be able to pass this directly in like
password: pass
— did you get an error doing that?
f
I had a wrapper function on top of it. like this
Copy code
export function AddDBUser(user: string, pass: string, instanceName: string){ 
    return new gcp.sql.User(`${user}-database-user`, {
    instance: instanceName,
    name: user,
    password: pass,
});
}
The error was coming from that function. once I changed the arguments to
pulumi.Input<string>
it worked.
f
ah, okay — makes sense