Hi, How can we read the value of secrets from the ...
# typescript
g
Hi, How can we read the value of secrets from the js code. I have declared couple of DB secrets, now after VM creation, I want to inject those secrets into the VM as init script and save them in a file. When I do
Copy code
let pg_password = config.requireSecret("PG_PASSWORD")
console.log("PG PASSWORD : ", pulumi.interpolate`PG_PASSWORD=${pg_password}`)
I am getting the output as shown below, instead of Secret value.
Copy code
OutputImpl {
      __pulumiOutput: true,
      resources: [Function (anonymous)],
      allResources: [Function (anonymous)],
      isKnown: Promise { <pending> },
      isSecret: Promise { <pending> },
      promise: [Function (anonymous)],
      toString: [Function (anonymous)],
      toJSON: [Function (anonymous)]
    }
How can i verify if its really working or not. I need to inject into my bash script which replaces {{PG_PASSWORD}} with the actual secret, but I am never able to get the actual secret value and its replacing with
[Secert]
instead.
q
The result of `pulumi.interpolate`PG_PASSWORD=${pg_password}`` is an
Output
, i.e. an eventually available value (akin to a
Promise
). You cannot directly log that, because it's not resolved at that point. If you want to make use of it, you have to use `apply`: `pg_password.apply((pw) => { console.log(
PG_PASSWORD=${pw}
) }`