https://pulumi.com logo
#general
Title
# general
b

bitter-dentist-28132

12/18/2019, 10:09 PM
are there any helper functions in any of the pulumi packages for converting javascript objects to yaml strings?
so i can, for instance, easily create a config map that ends up as a
config.yml
g

gentle-diamond-70147

12/18/2019, 10:11 PM
No, don't believe we have any built-in helpers for that. You can bring in third-party libraries though. 🙂
👍 1
w

white-balloon-205

12/19/2019, 2:04 AM
In particular - we ourselves use this package: https://www.npmjs.com/package/js-yaml
b

bitter-dentist-28132

12/19/2019, 6:12 PM
@white-balloon-205 it gave me an error about promises. I guess I'd have to
.apply
any pulumi input/output stuff?
darn, it really seems like i can't render yaml with a pulumi output 😞
g

gentle-diamond-70147

12/19/2019, 7:29 PM
can you share your code you're trying?
b

bitter-dentist-28132

12/19/2019, 8:23 PM
Copy code
let clientSecret = config.requireSecret('clientSecret');
const config = {client_secret: clientSecret};
const cm = new kx.ConfigMap("vouch-cm", {
    data: {"config.yml": yaml.dump(config)}
});
there's more structure to the config, but that's the relevant part
w

white-balloon-205

12/19/2019, 9:44 PM
I believe this should work:
Copy code
let clientSecret = config.requireSecret('clientSecret');
const cm = new kx.ConfigMap("vouch-cm", {
    data: {"config.yml": clientSecret.apply(s => yaml.dump({client_secret: s})}
});
b

bitter-dentist-28132

12/19/2019, 10:03 PM
it does not 😞
YAMLException: unacceptable kind of an object to dump [object Promise]
w

white-balloon-205

12/19/2019, 10:04 PM
Are you sure you used the code snippet above? I don't see how that code could produce that message.
b

bitter-dentist-28132

12/19/2019, 10:04 PM
woops! typo in the code. you're right, it does work.
thanks
👍 1