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

full-artist-27215

01/07/2022, 4:49 PM
Is there a way to set an object in a stack configuration file in one operation? That is, rather than doing
pulumi config set --path "obj.one" 1
and
pulumi config set --path "obj.two" 2
, I'd like to do something similar to
pulumi config set obj '{"one": 1, "two: 2}'
. However, that ends up setting
obj
to a string, rather than an object. There doesn't appear to be any kind of
--object
option to
config set
that might achieve this. This is made a bit more confusing by the fact that the output of
pulumi config
shows actual object values and JSON string values in the same way, while their representation in the raw YAML file is different. Is there any way to achieve this, short of manually iterating through the object structure and adding each leaf value individually?
b

billowy-army-68599

01/07/2022, 4:53 PM
@full-artist-27215 I think you're looking for the
pulumi config set-all
command?
f

full-artist-27215

01/07/2022, 4:55 PM
Unless I'm mistaken, that seems like it would require me to still iterate through my original object and specify each individual value as an argument, rather than passing one "object" at once.
🤔 Actually, I think I can use this
jq
to parse out what I need to pass to `pulumi`:
Copy code
jq '. as $in 
| reduce leaf_paths as $path (
    {};
    . + { ($path | map(tostring) | join(".")): $in | getpath($path) }
)
b

billowy-army-68599

01/07/2022, 5:01 PM
yeah we can definitely improve here and have plans to, but that should get you where you need to go
f

full-artist-27215

01/07/2022, 5:06 PM
cool, thanks @billowy-army-68599
3 Views