How should I configure the Pulumi platform access ...
# automation-api
l
How should I configure the Pulumi platform access token using the Automation API? What I have now:
stack.Workspace().SetEnvVar("PULUMI_ACCESS_TOKEN", req.Source.Token)
But I still get this error:
error: PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions
b
Curious about this too. For C# I had to set that env bar before running the app.
b
oh interesting, @red-match-15116 do we know if this should work? it sounds like the env var isn't get pushed to the forked process?
r
Hmm… you might also have to set the
PULUMI_BACKEND_URL
env var to
<https://app.pulumi.com/><your-org>
l
@red-match-15116 applied this: https://github.com/ringods/pulumi-resource/commit/486900cffb94f3a499092170fd651cbe97eb4153 with the same result:
error: PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions
token & organization are passed from Concourse itself. See an example of a pipeline configuration in the README: https://github.com/ringods/pulumi-resource/#full-example
r
Interesting… taking a look
okay figured it out. The env vars need to be set for the creation of the stack itself, so you gotta pass it in as a
LocalWorkspaceOption
👍 1
Copy code
stack, err := auto.UpsertStackLocalSource(
    ctx, 
    stackName, 
    r.PulumiSourceLocation, 
    auto.EnvVars(map[string]string{"PULUMI_ACCESS_TOKEN": req.Source.Token}),
)
ignore what I said about the backend_url thing coz you don’t need that, just the access token. It just needs to be set prior to the stack being created, so passing it in as a localworkspaceoption attaches the env var when creating the workspace for the stack
l
@red-match-15116 should I set
PATH
also via
LocalWorkspaceOption
?
r
Yup that makes sense to me!
l
@red-match-15116 Progress. I get another error now. So I guess your suggestion worked! Tnx.
r
woohoo