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

echoing-postman-88590

04/05/2022, 11:54 AM
Hi, consider the following
Pulumi.<stack>.yaml
file:
Copy code
config:
  config:one:
    key: val
  config:two:
    key: val
In order to read this config I have to:
Copy code
config = pulumi.Config(name="config")
config_one = config.require_object("one")
config_two = config.require_object("two")
Is there away to
for
loop`config`over each object? Thanks
l

limited-rainbow-51650

04/05/2022, 12:25 PM
@echoing-postman-88590 do you mean without knowing the keys
one
and
two
upfront?
e

echoing-postman-88590

04/05/2022, 12:44 PM
Yes
A sort of dynamic
config
l

limited-rainbow-51650

04/05/2022, 12:49 PM
I do it a bit differently. My config looks like:
Copy code
config:
  <projectname>:somekey:
  - role: admin
    username: user1
  - role: admin
    username: user2
Then
somekey
is a collection over which I can iterate. I'm using Typescript, so I do
config.requireObject<MyInterface[]>('somekey')
to retrieve the list of entries with a single call.
👍 1
e

echoing-postman-88590

04/05/2022, 1:32 PM
Yes, you are right just move one level deeper
11 Views