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 SUBCOMMAND [GLOBAL_OPTIONS]

Common SUBCOMMANDS include:

  • list: List all active projects.
  • create: Create a new project.
  • delete: Mark a project for deletion.
  • describe: Display details about a project.
  • get-iam-policy: Get the IAM policy for a project.
  • set-iam-policy: Set the IAM policy for a project.
  • add-iam-policy-binding: Add an IAM policy binding to a project.
  • remove-iam-policy-binding: Remove an IAM policy binding from a project.
  • update: Update a project's attributes.

PARAMETERS

SUBCOMMAND
    The specific operation to perform on a project. Each subcommand has its own set of arguments and options.

--filter=EXPRESSION
    Apply a resource filter to limit the output of list operations based on property values.

--format=FORMAT
    Specify the output format (e.g., json, yaml, text, table) for command results.

--limit=INTEGER
    Maximum number of resources to list (e.g., with list subcommand).

--sort-by=FIELD
    Sort list output by the specified field (e.g., list subcommand).

--project=PROJECT_ID_OR_NUMBER
    The ID or number of the project to operate on. Often required for specific operations like describe or delete.

--quiet
    Disable interactivity and prompt for input. Automatically assume 'yes' to prompts.

--help
    Display help for the command group or a specific subcommand.

DESCRIPTION

gcloud projects is a command group within the Google Cloud CLI (gcloud CLI), specifically designed for managing Google Cloud projects.

It provides comprehensive functionalities to:

  • List existing projects.
  • Create new projects.
  • Delete projects.
  • Describe project details.
  • Manage Identity and Access Management (IAM) policies, including getting, setting, adding, and removing bindings for project-level permissions.
  • Update project attributes.
This command group is essential for administrators and developers working with Google Cloud, enabling programmatic control over project lifecycles and access permissions. It allows users to interact directly with the Cloud Resource Manager API from the command line, facilitating automation and scripting of project-related tasks.

CAVEATS

  • Permissions: Operations like create, delete, and set-iam-policy require specific IAM permissions (e.g., resourcemanager.projects.create, resourcemanager.projects.delete) on the organization or billing account.
  • Project Deletion: Project deletion is irreversible after a 30-day grace period during which the project is quarantined. During this period, the project can be undeleted.
  • Billing: Creating projects does not inherently incur costs, but provisioning resources within them will typically require an active billing account and may generate charges.
  • API Enablement: Certain actions or managing specific resources within a project might require the corresponding Google Cloud APIs to be enabled within that project first.

RESOURCE HIERARCHY AND PROJECTS

Google Cloud projects are a fundamental building block of the Google Cloud resource hierarchy. They serve as distinct organizational containers for all Google Cloud resources (e.g., Compute Engine instances, Cloud Storage buckets, BigQuery datasets), billing, and Identity and Access Management (IAM) policies. Understanding and effectively managing projects is crucial for robust resource organization, cost management, and access control within Google Cloud environments.

DEFAULT PROJECT CONFIGURATION

Many gcloud commands operate on a default project, which can be conveniently set using gcloud config set project PROJECT_ID. This configuration simplifies command invocation by eliminating the need to explicitly specify the --project flag for every command that targets a specific project, unless an override is required for a particular operation.

HISTORY

The gcloud CLI is the primary command-line interface for Google Cloud, evolving from earlier specialized tools. The gcloud projects command group has been a core component since the early days of the gcloud CLI, reflecting the foundational role of projects in the Google Cloud resource hierarchy.

Its functionality has consistently expanded over time to cover more aspects of project management, including comprehensive IAM policy control, integration with the Cloud Resource Manager API, and alignment with Google Cloud's evolving best practices for resource organization.

SEE ALSO

gcloud auth(1), gcloud config(1), gcloud compute(1), gcloud iam(1), gcloud organizations(1)

Copied to clipboard