https://pulumi.com logo
Title
l

limited-rainbow-51650

04/21/2021, 5:05 PM
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

bored-activity-40468

04/21/2021, 6:02 PM
Curious about this too. For C# I had to set that env bar before running the app.
b

billowy-army-68599

04/21/2021, 6:31 PM
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

red-match-15116

04/21/2021, 7:05 PM
Hmm… you might also have to set the
PULUMI_BACKEND_URL
env var to
<https://app.pulumi.com/><your-org>
l

limited-rainbow-51650

04/21/2021, 7:21 PM
@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

red-match-15116

04/21/2021, 7:29 PM
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
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

limited-rainbow-51650

04/21/2021, 7:55 PM
@red-match-15116 should I set
PATH
also via
LocalWorkspaceOption
?
r

red-match-15116

04/21/2021, 8:00 PM
Yup that makes sense to me!
l

limited-rainbow-51650

04/21/2021, 8:09 PM
@red-match-15116 Progress. I get another error now. So I guess your suggestion worked! Tnx.
r

red-match-15116

04/21/2021, 8:10 PM
:woohoo: