This message was deleted.
# automation-api
s
This message was deleted.
m
Pulumi automation api is a wrapper for the pulumi CLI. If you can do it with the CLI directly, you can likely achieve it with the automation api.
Copy code
pulumi stack init org/project-1/sandbox
pulumi stack select org/project-1/sandbox
pulumi up
pulumi stack output
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/automation/#Workspace-stackOutputs
l
Thanks @millions-furniture-75402! At present it seems like I have to
select
using
LocalWorkspace
, which wants a path (and I can work around), but I'll dig into the API code and see if there's something more direct.
m
Here's some older code that might be a useful reference
Copy code
export class Gameserver {
  public createStack = async (gameserverStackName: string, configMap: ConfigMap): Promise<any> => {
    return await this.updateStack(gameserverStackName, configMap);
  }

  public destroyStack = async (gameserverStackName: string): Promise<any> => {
    const stack = await this.selectStack(gameserverStackName);
    const response = await stack.destroy({ onOutput: <http://console.info|console.info> });
    await stack.workspace.removeStack(stack.name);
    return response;
  }

  public redeployStack = async (gameserverStackName: string, configMap: ConfigMap): Promise<any> => {
    const stack = await this.selectStack(gameserverStackName);
    await stack.destroy({ onOutput: <http://console.info|console.info> });
    return await this.updateStack(gameserverStackName, configMap);
  };

  public updateStack = async (gameserverStackName: string, configMap?: ConfigMap): Promise<any> => {
    const stack = await this.selectStack(gameserverStackName);

    if (configMap) {
      await stack.setAllConfig(configMap);
    }

    return await stack.up({ onOutput: <http://console.info|console.info> });
  };

  public selectStack = async (gameserverStackName: string): Promise<any> => {
    <http://console.info|console.info>(gameserverStackName);
    const args: LocalProgramArgs = {
      stackName: gameserverStackName,
      workDir: upath.joinSafe(__dirname, ".."),
    };

    return await LocalWorkspace.createOrSelectStack(args);
  };
}
That was written for the original beta version of the automation API, but it should be largely the same, and help clarify the orchestration.
l
Yea I'm trying to avoid that
workDir
basically but it's not a dealbreaker
m
The automation api is tightly coupled with the pulumi cli. Another gotcha is the tight coupling with stack config. It will be manipulating stack YAML files on disk.
l
Yea, makes sense. It's OK -- I can live with the workspace directories. Thanks again for the help and replies! 🙂
👍 1