https://pulumi.com logo
Title
m

most-lighter-95902

01/15/2022, 11:37 PM
Is there a way to create a project via Automation API? I might be missing something, but the examples seem to hardcode
projectName
. I’m working on a project to manage devops setup for clients and trying to create a new project/client.
So it looks something like:
const stack = await auto.LocalWorkspace.createOrSelectStack({ workDir: dbWorkDir, stackName }, { name: "cool-project" });
🔥 1
m

most-lighter-95902

01/18/2022, 5:15 PM
OK great - I’ll try this thank you!
Wait this seems different from the REST API tutorial - does this still work for REST API use case?
m

millions-furniture-75402

01/18/2022, 6:00 PM
"seems different"? Can you provide more details and the reference you're referring to? From memory, the REST API example should be routing a request to application code that uses the Pulumi automation API to run Pulumi commands, probably inside of Lambda.
If you're asking how to pass a parameter and remove line 12 from here: https://github.com/pulumi/automation-api-examples/blob/main/nodejs/pulumiOverHttp-ts/ you want something like how stackName works: https://github.com/pulumi/automation-api-examples/blob/main/nodejs/pulumiOverHttp-ts/index.ts#L64
const projectName = req.body.project;
$ curl --header "Content-Type: application/json"   --request POST   --data '{"id":"hello", "project": "my-project", "content":"hello world\n"}'   <http://localhost:1337/sites>