hey friends - if I have a secret that I want to wr...
# typescript
hey friends - if I have a secret that I want to write to a file, for example as input to cloud-init - how do I do that? I get an error that says I should use
... but that doesn't seem to actually let me wind up with a string 🙂
You can provide the return object from the
directly to a resource input - e.g.
on an
my problem is I'm composing it with other data, I suspect - so my userdata is an interpolated string, and I can't get a value of out
that seems to ever show up in that string
do I need to basically nest
, and then pass the resulting output (which will eventually resolve to what pulumi needs) to the userData?
You can use
to combine multiple values into an interpolated string. Here's a contrived, but functional example:
Copy code
const config = new pulumi.Config()
const mySecret = config.requireSecret("mySecret");

// create the string `vpc-abc123: asdf1234`
const userData = pulumi.all([vpc.id, mySecret]).apply(([vpcId, secret]) => `${vpcId}: ${secret}`);
But if you only have a single output that you're interpolating you can use `pulumi.interpolate`:
Copy code
// create the string `password: asdf1234`
const userData = pulumi.interpolate`password: ${mySecret}`
I see - they're promises
thank you so much @gentle-diamond-70147 - that solved my problem!
🎉 1
👍 1
@flaky-father-99093 there’s also a helpful little library for generating cloud init manifests in typescript that joe wrote: https://github.com/joeduffy/pcloudinit