Is there a way to create a project via Automation ...
# automation-api
m
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:
Copy code
const stack = await auto.LocalWorkspace.createOrSelectStack({ workDir: dbWorkDir, stackName }, { name: "cool-project" });
🔥 1
m
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
"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
Copy code
const projectName = req.body.project;
Copy code
$ curl --header "Content-Type: application/json"   --request POST   --data '{"id":"hello", "project": "my-project", "content":"hello world\n"}'   <http://localhost:1337/sites>