Hello! I'm attempting to use the automation API to...
# python
a
Hello! I'm attempting to use the automation API to set an array in my yaml config file. I have a python list of
['us-east-1', 'us-east-2', 'ap-northeast-1', ...etc...]
and the end goal would be something like this in my config yaml
Copy code
aws:regions:
    - "ap-northeast-2"
    - "ap-northeast-3"
    - ...etc...
My python snippet is
Copy code
stack.set_config(f"aws:regions", auto.ConfigValue(value=regions))
but that throws
TypeError: expected str, bytes or os.PathLike object, not list
What is the best/correct way to set yaml arrays with the python automation API? Thanks you!
I was able to get this kind of working with JSON with the exception of a strangely formatted yaml
Copy code
config:
  aws:regions: '["us-east-1", "eu-central-1", "ap-southeast-2", "ap-northeast-1"]'
automation.py
Copy code
stack.set_config(f"{project}:regions", auto.ConfigValue(value=json.dumps(regions)))
pulumi.py
Copy code
regions = json.loads(config.require("regions"))