https://pulumi.com logo
Title
p

polite-ocean-13631

05/17/2023, 2:36 AM
auto.create_or_select_stack(
    stack_name=stack_name,
    work_dir=work_dir,
    opts=auto.LocalWorkspaceOptions(
        project_settings=auto.ProjectSettings(
            name=pulumi_project_name,
            runtime="python",
            backend=auto.ProjectBackend(url=f"s3://{PULUMI_STATE_BUCKET}/{pulumi_state_key}?region={AWS_REGION}&awssdk=v2"),
        ),
    ),
)
Using the above automation API code, I'm getting the following error:
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:<http://yaml.org|yaml.org>,2002:python/object:pulumi.automation._project_settings.ProjectBackend'
Does anyone know why, and/or what I can do to fix this?
r

rhythmic-branch-12845

05/17/2023, 3:45 AM
not familiar with the automation API, but going with the error message it almost looks like as it says, it cannot infer a constructor for the "ProjectBackend". One way to test this out would be at the REPL. Assuming you have an
import pulumi.automation as auto
(looks like it?):
>>> import pulumi_automation as auto
>>> auto.ProjectBackend # does this give you an error?
If that gives you an error, then we have something to work with. Otherwise, i'd also keep exploring around what's going on with the backend argument
side note: how are you navigating the python documentation? I see https://www.pulumi.com/docs/reference/pkg/python/pulumi/#pulumi.automation.create_or_select_stack ... but I'm not finding much info on how to construct the
opts: LocalWorkspaceOptions
argument
p

polite-ocean-13631

05/17/2023, 1:19 PM
I haven't had much luck finding stuff in the Pulumi Python docs. Instead I usually rely on the type hints in my editor, and browsing the source code (right click > go to definition).
I'm able to run
auto.ProjectBackend()
without error, with and without providing the
url
argument. It only becomes a problem when running
stack.up
or
stack.preview
r

rhythmic-branch-12845

05/17/2023, 3:26 PM
p

polite-ocean-13631

05/17/2023, 3:26 PM
Yup
r

rhythmic-branch-12845

05/18/2023, 12:23 AM
gotcha. That's a good approach. Thanks! if
auto.ProjectBackend
does not give you an error, I'm afraid I'm at my wits' end... If you can provide a small complete program so others can reproduce it, I think that would help others look at it for you
p

polite-ocean-13631

05/18/2023, 12:25 AM
I worked around the error by using the
PULUMI_BACKEND_URL
environment variable documented here: https://www.pulumi.com/docs/cli/environment-variables/ Ideally using
auto.ProjectBackend
would work, but the env var is good enough for my purposes.