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

limited-window-74907

01/25/2024, 12:00 AM
Q: How can I do a
pulumi login
(to Pulumi Cloud) via the automation API? I have a use case where I sometimes am using Pulumi Cloud and sometimes S3, code in thread
I’m using the Go SDK, ProjectBackend
Copy code
import (
    ws "<http://github.com/pulumi/pulumi/sdk/v3/go/common/workspace|github.com/pulumi/pulumi/sdk/v3/go/common/workspace>"
)

proj, err := ws.LoadProject("./Pulumi.yaml"))
...
proj.Backend = &ws.ProjectBackend{
	URL: "???",
}
When I set the the backend URL to
s3://…
, that works. When I set the backend URL to empty string or don’t set it, Pulumi uses the backend currently logged in at the user level. In the specific case that I manually ran a
pulumi login
to Pulumi Cloud most recently on this machine, it works. I don’t consider this viable, since I will be executing in a variety of environments and have no control of the system Pulumi login state. When I set the backend URL to
<https://app.pulumi.com>
, I get the error
Copy code
error: getting user info from <https://app.pulumi.com>: unmarshalling response object: invalid character '\u003c' looking for beginning of value\n\n
Note that I am setting
PULUMI_ACCESS_TOKEN
, I have already tested that auth is not the issue. Judging from the code in the Pulumi CLI, there isn’t simply a URL I can pass in to indicate that I want to use Pulumi Cloud.
r

red-match-15116

01/25/2024, 3:36 AM
You'll want
<https://api.pulumi.com>
l

limited-window-74907

01/25/2024, 5:17 PM
Thank you very much, that was exactly what I was looking for! Will have a doc improvement PR up shortly
2 Views