2
votes

How can a project be created in Google cloud with API on a web server? I came across this documentation to create projects and I want to authenticate using the service account key but I can't give project creation role/permission to create a project. I'm using googleapis node js client

I need to create a Dialogflow agent and for that need to create a GCP project.

1
Put more thought into your question. Which web server? Which cloud service is the web server running on? Which language? Did you read the documentation for the SDKs? If yes, which one and which part are you having problems with?John Hanley
@JohnHanley. Thanks, John for pointing out. I edited the question.Pulkit Gambhir
Why you cant give "project creation role/permission to create a project" ? If you need to create a PROJECT you need at least "resourcemanager.projects.create" Access Control for Projects using IAMArmando Cuevas

1 Answers

0
votes

I know this is late but in case anyone else is wondering, I had a similar issue and it's just that service accounts can't create a project without a parent. You can use the sample code from here and then get the attributes needed for resource here.

const request = {
    resource: {
        "projectId": "our-project-123",
        "name": "my project",
        "labels": {
          "mylabel": "prod"
        },
        "parent": {
            "type": string,
            "id": string
        }
    },

    auth: authClient,
  };