Back with n00b questions :slightly_smiling_face: ...
# general
Back with n00b questions 🙂 • Context: ◦ I'm using the Automation API and Python. ◦ Working with
. ◦ Seems the only way to bounce between regions is to set the
configuration. ▪︎ Please correct me if I'm wrong about setting that value. • Questions: ◦ Should the
config be changed between calls to
, can I expect the subsequent distribution to be deployed in the most resent setting? ◦ If using the stack config to exchange parameters between the local program and the Pulumi program, what is the most effective method of getting a
instance in the Pulumi program? ▪︎ I've considered
, and
but it seems like I'm missing a more obvious method. ▪︎ Edits: • I'm looking to set new values to the stack's config. • Can confirm that the
I believe you can set the region on the provider? Than you could just instantiate multiple providers and pass them to your distributions.
❤️ 1
I believe that will mean you don't have to do this config handling you're looking at, but to answer your second question - automation api is not meant to be used inside your pulumi program. I don't think that will work.
Ah, I totally didn't think about doing the provider thing. Sharp eye. I'll try that here in a bit. Stack shenanigans is working like I want it to within the Pulumi program, but you're probably right. Feels like it's the wrong thing to do. Probably should just interface with external storage from the Pulumi program. I'll probably refactor it and do it the right way again tomorrow. At least I'm learning about this slick system. Thanks for the tips!
I would expect that when a deployment starts it grabs the config and doesn't read it again after, so I'm surprised if that worked. But yes I would recommend against automation api inside your program. Good luck!
👍 1
Yeah, I just instantiated a
instance within the Pulumi program itself. That seems to interact with the stack's YAML file when running
Copy code
import pulumi
from pulumi import automation as auto
from pathlib import Path

# bad ideas
stack = auto.select_stack(

# set a config value
stack.set_config('stuff', auto.ConfigValue('things'))

# log the newly set value
It's probably working because I'm more-or-less using it as a method of sending output back to the automation program (less the
config). Definitely heeding your advice though.
Part of me was hoping it worked more like "RPC calls" when stuff was being put together. All speculation, though. I need to read the docs 😅
Yea that is just reading and writing straight to the json file. So I guess that working isn't surprising. The real question is if the ongoing deployment actually picks up your change, I would doubt that and be thoroughly surprised if it did
Automation API as it currently exists is really just a literal layer over the CLI you're used to so in its current form it is manipulating the same project directory you would manually. The RPC portion of automation api doesn't come into play until you start a deployment using it, because at that point it needs to communicate with the Pulumi CLI that is running under the hood as a separate process
Ah, that makes sense.