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

prehistoric-kite-30979

02/25/2021, 11:14 AM
Hi! Where/how are stack configs persisted with the automation API? In standard CLI based Pulumi, this is just the
stack-name.pulumi.yaml
file.
c

colossal-australia-65039

02/25/2021, 6:30 PM
Someone correct me if I'm wrong, but from playing around with the automation API it depends on how you are using it. For example, if you are using the API that refers to a workDir
Copy code
const stack = await LocalWorkspace.createOrSelectStack({
    stackName: stackName,
    workDir: upath.joinSafe(__dirname, "stack"),
  })
if you don't already have one, it will create the Pulumi.stackname.yaml file for you when you run the code. This file doesn't need to be added to git in this case since the "source of truth" is the code, not the file itself, UNLESS you want to check in encrypted secrets. In that case the source of truth for the secrets would be the Pulumi.stackname.yaml file, but for non-secrets it could still be solely from the code. I think most people using this may still check in the stack config file though because it seems like it's a bridge between the "old way" of Pulumi to the new way using the automation API. But if you use the inline API
Copy code
const stacks = await LocalWorkspace.createOrSelectStack({
    stackName: stackName,
    projectName: "myes",
    program: pulumiProgram
  })
it will not create the file for you. It's not needed as the information is just in your code. The point of the Automation API is to move away from config files and minimize CLI use, so it's intentional that these stack files are less important or obsolete with the automation API.
l

lemon-agent-27707

02/25/2021, 8:04 PM
I'll add one thing to the above that mostly covers it: You always have a
workDir
. If you don't specify one, we create one in a temp directory for you and this is where any
pulumi.stack.yaml
files would end up if they get created as a side effect of setting config.
Mike gives a good overview of it, in summary: • Local Programs: the workDir is the directory of your on-disk pulumi program • Inline Programs: typically you don't need to save your stack yaml files, as config operations are idempotent/managed by the automation program. If you do need to save them, you should specify a workDir and write some code to manage saving those pulumi.stack.yaml files as appropriate
p

prehistoric-kite-30979

02/26/2021, 4:14 PM
thanks! So I think (by design) I'll have to persist/manage the data external to the automation API server so I can make complete/idempotent requests