LinuxCommandLibrary

gcloud-projects

Manage Google Cloud projects

TLDR

Create a new project

$ gcloud projects create [project_id|project_number]
copy

List all active projects
$ gcloud projects list
copy

Display metadata for a project
$ gcloud projects describe [project_id]
copy

Delete a project
$ gcloud projects delete [project_id|project_number]
copy

Add an IAM policy binding to a specified project
$ gcloud projects add-iam-policy-binding [project_id] --member [principal] --role [role]
copy

SYNOPSIS

gcloud projects <COMMAND> [--filter=FILTER] [--format=FORMAT] [--limit=LIMIT] [--page-size=PAGE_SIZE] [--sort-by=SORT_BY] [--uri] [--folder=FOLDER_ID] [--organization=ORGANIZATION_ID] [GCLOUD_WIDE_FLAG …]

PARAMETERS

--filter
    Boolean filter expression to apply (e.g., name:*prod*)

--format
    Output format: table,json,yaml,etc.

--limit
    Max number of projects to return

--page-size
    Number of projects per page request

--sort-by
    Comma-separated fields to sort by (e.g., createTime)

--uri
    Output full resource URIs

--folder
    Restrict to projects under specific folder ID

--organization
    Restrict to projects under organization ID

DESCRIPTION

gcloud projects is a key command group in the Google Cloud CLI (gcloud), used to create, list, describe, update, delete, and manage IAM policies for GCP projects.

Projects serve as the foundational containers for all GCP resources, including Compute Engine VMs, Cloud Storage buckets, BigQuery datasets, and more. This command enables developers and administrators to handle project lifecycle operations efficiently from the terminal.

Key operations include:
List all accessible projects with filtering and pagination.
Create new projects with optional labels and parent folders/organizations.
Describe project metadata like creation date and billing info.
Update project names, labels, or parent hierarchy.
• IAM policy management for access control.

Usage requires prior authentication via gcloud auth login and appropriate IAM roles (e.g., Project Viewer for listing, Owner for creation/deletion). It's integral for multi-project environments, CI/CD pipelines, and infrastructure automation with tools like Terraform.

Output can be customized with --format flags for JSON, YAML, or tables, facilitating scripting and integration.

CAVEATS

Requires IAM permissions (e.g., resourcemanager.projects.list); deletions are permanent after 30-day grace period; rate limits apply to API calls.

SUBCOMMANDS

create, delete, describe, get-iam-policy, list, set-iam-policy, undelete, update

EXAMPLES

gcloud projects list --limit=10
gcloud projects create my-project --name="My Project"

HISTORY

Introduced in Google Cloud SDK v0.1 (2013) alongside Cloud Resource Manager API; evolved with Folder/Organization support (2017); now supports advanced filtering and async operations in SDK v400+.

SEE ALSO

gcloud(1), gcloud config(1)

Copied to clipboard