With automation API how can I set a config element...
# automation-api
c
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
c
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
would you mind opening an issue for that?
c
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
ahhh got it, it's all good now?
c
Yep
r
yup yup you’ve got that all right @crooked-pillow-11944