great-gigabyte-39962
05/17/2024, 4:00 AMauto.create_or_select_stack()
or auto.create_stack()
I receive the error PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions
. I want to use a local filesystem backend (I guess… I’d rather have an in-memory, disposable backend, see above, but ok). Can’t figure how to tell Pulumi that. All the docs I’ve seen say I should set a config on the stack, but this failure happens within the stack creation. I’ve even tried setting it in Pulumi.yaml
even though my aim is not to have a Pulumi.yaml at all (I want to drive it all from code). Still no go. What’s the key to convincing pulumi.automation not to require a pulumi login?modern-zebra-45309
05/17/2024, 9:11 AMLocalWorkspaceOptions
to auto.create_or_select_stack()
?
I can't find it in the Python SDK documentation, but you can look at the code here or look at the signature of LocalWorkspace
, which you can find here.
It allows you to define where you store your state etc. In your case, you'll want to make sure that the ProjectSettings
are correct (see the docs.) You pass it to create_or_select_stack
via opts
as described here.
If you do it like that, you don't need a Pulumi.yaml at all.brave-cartoon-40872
05/17/2024, 5:12 PMpulumi login --local
prior to running my Pulumi tests that use the automation API. I’m not sure if this is the best way to solve the problem but I similarly tried using LocalWorkspace
and could not resolve the issue.modern-zebra-45309
05/17/2024, 5:22 PMfrom pulumi import automation as auto
project_settings = auto.ProjectSettings(
name="local-project",
runtime="python",
backend=auto.ProjectBackend(url="<file://path/to/local/state>")
)
local_workspace_options = auto.LocalWorkspaceOptions(
project_settings=project_settings
)
stack = auto.create_or_select_stack(..., opts=local_workspace_options)