Steps To Change The Project In GCP Using CLI Commands
Step 1: Goto GCP Cloud Console
Step 2: Create a Project
Step 3: Activate Cloud Shell from the GCP Console.
- Cloud Shell is the Command Line tool provided by GCP.
- Click on the top right button as shown below to activate Cloud Shell. We need to activate the Cloud Shell to interact with GCP using CLI commands.
Step4: List all the projects
- Once the Cloud Shell is activated, list all the projects using the below command:
gcloud projects list
- The above command will list all the projects in your GCP account as shown below.
- You can see the PROJECT_ID, NAME and PROJECT_NUMBER for all the projects. Kindly note the PROJECT_ID of the project to which you need to change.
- The above image shows that I have three projects in my GCP account. They are
1. My First Project
2. w3wiki Project and
3. geekyWebsite
- In the remaining section, I will walk you through how to change the project from Website for geek to w3wiki Project.
- Kindly note the PROJECT_ID of w3wiki Project is w3wiki-project1.
Step 5: Check the currently configured Project
Before changing the project, check the currently configured project using the below command
gcloud config list project
The above commands give the PROJECT_ID of the currently configured project as project = PROJECT_ID. The below image shows that I am in the project named “Website for geek” with PROJECT_ID as geekywebsite.
Step 6: Change the project using the below command
gcloud config set project PROJECT_ID
- For example, if I want to change the project from Website for geek to w3wiki Project I will use the below command
gcloud config set project w3wiki-project1
- w3wiki-project1 is the PROJECT_ID of w3wiki Project. You can check the ID from the previous all projects list image.
Step 7: Confirm the change
- This can be done by checking the currently configured project in our previous command
gcloud config list project
- As you can see the PROJECT_ID is now changed to w3wiki-project1 from the below image.
Congratulations! You have successfully changed the project using CLI commands.
How To Change The Project In GCP Using CLI Commands ?
Google Cloud Platform(GCP) offers various Cloud services such as cloud storage, cloud computing, deploying and scaling applications in the cloud e,c. GCP offers pay-per-use services. Apart from these, GCP offers many other services like hosting your websites in the cloud, running your own Operation System from the Cloud, and other cloud computing processes.