Google Cloud Resource Manager Tutorial
Introduction
The Google Cloud Resource Manager is a service that allows you to manage and organize your Google Cloud resources. It provides programmatic access to manage projects, folders, and organizations, enabling you to create, modify, and delete these resources.
Setting Up
Before you start using the Resource Manager, you need to set up a Google Cloud project and enable the Resource Manager API.
Enable the Resource Manager API:
gcloud services enable cloudresourcemanager.googleapis.com
Creating a Project
Projects are the basic organizational unit in Google Cloud. Each project has a name, ID, and number. You can create a project using the Cloud Console, gcloud command-line tool, or the Resource Manager API.
Using the gcloud command-line tool:
gcloud projects create PROJECT_ID --name="PROJECT_NAME"
Example output:
{ "projectNumber": "123456789012", "projectId": "my-sample-project", "lifecycleState": "ACTIVE", "name": "My Sample Project" }
Listing Projects
You can list all the projects associated with your account using the gcloud command-line tool or the Resource Manager API.
Using the gcloud command-line tool:
gcloud projects list
Example output:
PROJECT_ID NAME PROJECT_NUMBER my-sample-project My Sample Project 123456789012
Updating a Project
You can update the name and labels of an existing project using the gcloud command-line tool or the Resource Manager API.
Using the gcloud command-line tool:
gcloud projects update PROJECT_ID --name="NEW_PROJECT_NAME"
Deleting a Project
Deleting a project removes it from your Google Cloud account. This action cannot be undone. You can delete a project using the gcloud command-line tool or the Resource Manager API.
Using the gcloud command-line tool:
gcloud projects delete PROJECT_ID
Creating and Managing Folders
Folders provide an additional layer of organization and are used to group projects. Folders can be nested within other folders and are part of the hierarchy within an organization.
Creating a folder using the gcloud command-line tool:
gcloud resource-manager folders create --display-name="FOLDER_NAME" --organization=ORGANIZATION_ID
Managing Organizations
Organizations represent a company and are the root node in the Google Cloud resource hierarchy. They contain folders and projects. Managing an organization involves setting policies and permissions across all resources within the organization.
Conclusion
The Google Cloud Resource Manager allows you to efficiently manage and organize your cloud resources. By leveraging projects, folders, and organizations, you can create a structured and secure environment for your applications and services.