https://pulumi.com logo
Title
b

brave-angle-33257

04/05/2021, 10:37 PM
hi - trying to find an example of using automation API with s3 storage backend
Im running this inside of a lambda function with custom container, the container will have the STS tokens in the ENV from lambda, just need to figure out how to point the pulumi automation to the appropriate s3 bucket for state management
I think it's like this, will check:
const args = {
    stackName: <http://message.SK|message.SK>,
    projectName: "inlineNode",
    program: pulumiProgram,
    projectSettings: {
        backend: {
            url: "<s3://mycompany-bucket?region=us-west-2>"
        }
    }
};
const stack = await auto.LocalWorkspace.createOrSelectStack(args);
so, trying with that ^ I get:
PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions
do I need to do some type of automation API login? I cant seem to find any docs/examples for that
this seemed to work, not sure if there is a better way..
// Create our stack
        const args = {
            stackName: <http://message.SK|message.SK>,
            projectName: "inlineNode",
            program: pulumiProgram,
            projectSettings: {
                backend: {
                    url: "<s3://mycompany?region=us-west-2>",
                },
            },
        };

        // do the pulumi login
        execSync(`pulumi login --cloud-url "<s3://mycompany?region=us-west-2>"`);

        // create (or select if one already exists) a stack that uses our inline program
        const stack = await auto.LocalWorkspace.createOrSelectStack(args);
2021-04-05T23:13:39.161Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    successfully initialized stack
2021-04-05T23:13:39.161Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    installing plugins...
2021-04-05T23:13:39.257Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    plugins installed
2021-04-05T23:13:39.257Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    setting up config
2021-04-05T23:13:39.808Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    config set
2021-04-05T23:13:39.808Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    refreshing stack...
2021-04-05T23:13:41.238Z        7b22ae10-1893-4c34-96b8-7b6b76aa9163    INFO    Refreshing (3868a615-a53c-48ff-9099-..
g

gentle-diamond-70147

04/05/2021, 11:26 PM
pulumi login
is not yet supported in the automation api - https://github.com/pulumi/pulumi/issues/5591. So what you're doing is the best option until it gets added.
r

red-match-15116

04/06/2021, 3:44 AM
Yup @brave-angle-33257 what you’re doing is right. The other option is to set the
PULUMI_BACKEND_URL
environment variable - but either way works!
b

brave-angle-33257

04/06/2021, 3:52 AM
thank you both for confirming!