Creating and Managing Google Cloud Platform Projects

Google Cloud Platform projects forms the basis for creating, enabling, and using all Cloud Platform services including managing APIs, enabling billing, adding and removing collaborators, and managing permissions for Cloud Platform resources.

This page explains how to create and manage Cloud Platform projects using the Google Cloud Resource Manager API and the Google Cloud Platform Console.

Before you begin

Read an overview of the Cloud Platform project.

Creating a project

You can create a new project using the Cloud Platform Console or the projects.create() method.

Console

To create a new project:

API

Create Project Request:

POST https://cloudresourcemanager.googleapis.com/v1/projects/
Authorization: *************
Content-Type: application/json

{
    "projectId": "our-project-123",
    "name": "my project",
    "labels": {
    "mylabel": "prod"
},
}

Create Project Response:

{
    "name": "operations/pc.123456789",
}

Get Operation Request:

GET https://cloudresourcemanager.googleapis.com/v1/operations/pc.123456789
Authorization: *************
Content-Type: application/json

Get Operation Response:

{
    "name": "operations/pc.123456789",
    "done": true,
    "response": {
        "@type": "type.googleapis.com/google.cloudresourcemanager.v1.Project",
        "projectNumber": "464036093014",
        "projectId": "our-project-123",
        "lifecycleState": "ACTIVE",
        "name": "my project",
        "labels": {
        "mylabel": "prod"
        },
    "createTime": "2016-01-07T21:59:43.314Z",
    }
}

PYTHON

...

operation = crm.projects().create(
body={
    'project_id': flags.projectId,
    'name': 'my project'
}).execute()

...

Identifying projects

To interact with Cloud Platform resources, you must provide the identifying project information for every request. A project can be identified in two ways: project ID, or a project number. A project ID is the customized name you chose when you created the project, or when you activated an API that required you to create a project ID. A project number is automatically generated by the server. Both the project ID and project number can be found on the Dashboard of the project. To get the project ID and the project number:

  1. Go to Google Cloud Platform Console.
  2. Select your project.

Both the project ID and project number are displayed on the Dashboard of the project:

The project number and project ID are unique across Google Cloud Platform. If another user owns a project ID for their project, you won't be able to use the same project ID.

A project ID is different than a project name. The project name is a human-readable way to identify your projects, but it is not used by any Google APIs. In this example, the project name is Example and the project ID is example-project-a.

When you choose your project ID (or any resource names), avoid providing sensitive information in your names.

Getting an existing project

You can get an existing project using the Cloud Platform Console or the projects.get() method.

Console

To view a project via the Cloud Platform Console:

  • Go to the Google Cloud Platform Console.
  • Click on the projects drop-down in the top right corner. (The drop-down label will be be name of your project you're currently viewing).
  • Select the project you wish to view.

API

Request:

GET
https://cloudresourcemanager.googleapis.com/v1beta1/projects/our-project-123

Response:

{
    "projectNumber": "464036093014",
    "projectId": "our-project-123",
    "lifecycleState": "ACTIVE",
    "name": "my project",
    "labels": {
        "mylabel": "prod"
    },
    "createTime": "2016-01-07T21:59:43.314Z",
}

PYTHON

...

project = crm.projects().get(projectId=flags.projectId).execute()

...

Listing projects

You can list all projects you own using the Cloud Platform Console or the projects.list().

Console

To list projects using the Cloud Platform Console:

  • Go to the Google Cloud Platform Console.
  • All your projects are listed in the projects drop-down in the top right corner. Use the Filter by project name or project ID textbox to filter projects.
  • Click Manage all projects to list all your projects. Use the Filter by name, ID, or label textbox to filter your projects.

API

Request:

GET https://cloudresourcemanager.googleapis.com/v1beta1/projects

{
    "name": "project a"
}

Response:

{
    "projects": [
    {
        "projectNumber": "951040570662",
        "projectId": "google.com:api-project-951040570662",
        "lifecycleState": "ACTIVE",
        "name": "project a",
        "createTime": "2013-11-13T20:31:53.308Z"
    }
    ]
}

The following code snippet lists all projects with a red label:

Request:

GET
https://cloudresourcemanager.googleapis.com/v1beta1/projects

{
    "labels": {
    "color": "red"
    }
}

Response:

{
    "projects": [
    {
        "projectNumber": "350831539566",
        "projectId": "my-project-b",
        "lifecycleState": "ACTIVE",
        "name": "project b",
        "labels": {
            "color": "red"
        },
        "createTime": "2012-02-18T23:11:57.831Z"
    }
    ]
}

PYTHON

...

filter = name:"project a"
projects = crm.projects().list(filter=filter).execute()

...

The following code snippet lists all projects with a red label:

filter = 'labels.color:red'
projects = crm.projects().list(filter=filter).execute()

Updating projects

You can update projects using the Cloud Platform Console or the projects.update(). Currently the only fields that can be updated are the project name and labels. For more information see the project API reference page.

Console

To update a project's field using the Cloud Platform Console:

  • Go to the Google Cloud Platform Console.
  • From the Select a project drop-down, click Manage all projects.
  • Click the edit icon next to the project to update the project's name.
  • Click Labels to edit labels. For more information on using labels see the Using Labels page.

API

To update a project:

The following code snippet updates the name of the project to "myproject":

Request:

    PUT https://cloudresourcemanager.googleapis.com/v1beta1/projects/my-project-123

    {
        "name": "myproject"
    }

Response:

    {
        "projects": [
        {
            "projectNumber": "951040570662",
            "projectId": "my-project-123",
            "lifecycleState": "ACTIVE",
            "name": "myproject",
            "createTime": "2013-11-13T20:31:53.308Z"
        }
        ]
    }

PYTHON

...

project = crm.projects().get(projectId=flags.projectId).execute()
project['name'] = 'myproject'
project = crm.projects().update(
projectId=flags.projectId, body=project).execute()

...

Shutting down projects

You can shut down projects using the Cloud Platform Console or the projects.delete().

To shut down a project:

  • The project must not have a billing account associated with it.
  • The project must have a lifecycle state of ACTIVE.

Console

To shut down a project using the Cloud Platform Console:

  • Open the Settings page in the Google Cloud Platform Console.

    Open the Settings page

  • Click Select a project.

  • Select a project you wish to delete, and click Open.

  • Click Delete Project.

  • Enter the Project ID and click Shut down.

API

The following code snippet deletes the specified project:

Request:

DELETE
https://cloudresourcemanager.googleapis.com/v1beta1/projects/my-project-123

PYTHON

...

project = crm.projects().delete(projectId=flags.projectId).execute()

...

Send feedback about...

Google Cloud Resource Manager Documentation
Google Cloud Resource Manager Documentation