Is there a way to set an object in a stack configu...
# general
f
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
@full-artist-27215 I think you're looking for the
pulumi config set-all
command?
f
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
yeah we can definitely improve here and have plans to, but that should get you where you need to go
f
cool, thanks @billowy-army-68599