https://pulumi.com logo
#automation-api
Title
# automation-api
c

crooked-pillow-11944

09/16/2021, 12:07 PM
With automation API how can I set a config element that has a path?:
Copy code
pulumi config set --path '["parent.name"].["nested.name"]' value will set the value of parent.name to a map nested.name: value.
b

billowy-army-68599

09/16/2021, 12:11 PM
c

crooked-pillow-11944

09/16/2021, 1:52 PM
I'm still unsure how to set structured configuration. I'm using Python and I've tried a few different techniques but all I get is:
Copy code
TypeError: expected str, bytes or os.PathLike object, not dict
I think I got it - finally succeeded in applying updates with a generic json blob. I'll try to put the data that I want there now
Can I iterate over the contents of the config value using standard dictionary methods?
Nope -
'str' object has no attribute 'items'
Looks like I'll need to convert from json back to dict
b

billowy-army-68599

09/16/2021, 2:22 PM
would you mind opening an issue for that?
c

crooked-pillow-11944

09/16/2021, 2:25 PM
I don't think this is an issue - the Config object returns a string In this case it's a JSON string which needs to be converted to a dictionary, which is what I did:
Copy code
mydict = {'project1': 'vpc','project2': 'rds'}
infra_projects = json.dumps(mydict)
....
infra_projects = config.require('infra_projects')
infra_projects_dict = json.loads(infra_projects)
...
for k,v in infra_projects_dict.items():
      create_codebuild_project(k, codepipeline_bucket, v)
👍🏽 1
The process to load a list is very similar
b

billowy-army-68599

09/16/2021, 2:42 PM
ahhh got it, it's all good now?
c

crooked-pillow-11944

09/16/2021, 3:02 PM
Yep
r

red-match-15116

09/16/2021, 4:00 PM
yup yup you’ve got that all right @crooked-pillow-11944