Hello All, can you help me I am trying to create p...
# general
h
Hello All, can you help me I am trying to create pem file from a private key using pulumi interpolate but I got error this is my code
Copy code
// Create a Key to allow SSH connection
const sshKeyPrivate = new tls.PrivateKey("bastion", {
    algorithm: "RSA",
})

export const privateKey = sshKeyPrivate.privateKeyPem;

const privateKeyInterP = pulumi.interpolate `${privateKey}`;

fs.writeFileSync("key.pem", privateKeyInterP);
and this is the error on the key.pem
Copy code
Calling [toString] on an [Output<T>] is not supported.

To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`

See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi.
b
you can’t use
pulumi.interpolate
like that, you can’t assign an output value to a string value. Try this
Copy code
privateKey.apply((pem) => {
  fs.writeFileSync("key.pem", pem);
})
(untested)
h
It worked, thanks