https://pulumi.com logo
#typescript
Title
# typescript
o

orange-kite-80991

11/08/2021, 12:10 AM
I'm looking for a data+code structure to read Pulumi Config data without declaring every individual name in code. It seems using --path gets close but all the examples show explicit named fields. My next attempt will be using --path to define an array of [name, value] pairs. regarding Config --path Anyone found a trick for reading all pulumi config data without naming each field in code? ... edit: the trick is to use
Copy code
pulumi.runtime.allConfig()
l

little-cartoon-10569

11/08/2021, 12:17 AM
Reading it to what? Do you mean, building up a map of nested key:value pairs?
o

orange-kite-80991

11/08/2021, 12:40 AM
Indeed. That seems the more reasonable option that pre-defining a rigid struct with all the duplicate declarations that entails.
More like a normal JSON or YAML key:value tree.
l

little-cartoon-10569

11/08/2021, 1:03 AM
pulumi.Config gives you that out of the box. Can you pass the entire object around and use it as-is?
o

orange-kite-80991

11/08/2021, 1:26 AM
My overall goal is to pass all the Config values into Dockerfile via ARG+ENV without naming every individual key. Do you have a way?
To answer your question, no I can't use the Config object as is. The config data needs to leave Pulumi as text.
l

little-cartoon-10569

11/08/2021, 1:29 AM
I believe I did something like that a while ago, then replaced it with simpler code. I'll have a quick hunt through old commits...
Found it!
pulumi.runtime.allConfig()
.
Copy code
const config = pulumi.runtime.allConfig();
for (let kv in config) {
  <http://pulumi.log.info|pulumi.log.info>(`I see ${kv}: ${config[kv]}`);
}
o

orange-kite-80991

11/08/2021, 1:57 AM
Thanks! I'll kick the tires.
WORKS! Even the secrets make it all the way thru to Docker. Thanks again!
👍 1
3 Views