Google cloud shell command to get the default PROJECT_ID – GCP
This tutorial guides you on how to get the default project_id of Google Cloud Platform and export it to a variable. So that the resulting variable which contains the PROJECT_ID can be used in the other commands or scripts.
Get the default PROJECT_ID GCP
Project ID is the unique identifier of your project in GCP (Google Cloud Platform). It can be used by Google APIs. If you don’t specify it will be created automatically.
If you would like to get the default project_id from the GCP cloud shell, then run the following gcloud command.
$ gcloud info --format='value(config.project)' sne5g21
Then, if you would like to export the default project_id to a variable called PROJECT_ID, so that you can use them in other commands or scripts, you need to run the following export command.
sneppets@cloudshell:~ (sne5g21)$ export PROJECT_ID=$(gcloud info --format='value(config.project)')
Verify if the variable is set with the default project_id.
sneppets@cloudshell:~ (sne5g21)$ echo $PROJECT_ID sne5g21
Note, we are trying to use –format flag with gcloud info command to achieve this. For more details about gcloud info command and gcloud wide flags supported, please check this link gcloud info details.
Locate the project ID from console
To locate your Project ID through GCP console follow the below steps:
- First, go to the GCP Console.
- From the projects list, the Names and ID’s for all the projects you are member of are displayed. You can find the project_id from this list as well.
That’s it. You had learnt how to get the default project_id using gcloud info command and from GCP console.
Hope it helped 🙂
- How to Explore Docker Container’s File System ?
- Docker EXPOSE Port only to the Host on Google Cloud
- Get Docker Container’s IP Address from the Host
- Copy Files between Host and Docker Container
- What is ImagePullBackOff status on a Kubernetes pod ?
- Set or change root password in Ubuntu Linux
- How to list all Containers running in Kubernetes Pod ?
- How to find which users belongs to a specific group in linux
- Give write permissions for specific user or group for specific folder in linux
- How to remove an image tag from docker hub ?
- Build a Docker Image with a Dockerfile and Cloud Build in GCP?
- How to create GCP project on Google Cloud Platform
- MariaDB – How to set max_connections permanently ?
- Create GCP project on Google Cloud Platform
- Is it possible to change Google Cloud Platform Project ID ?
- Create non-root SSH user account and provide access to specific folders
- Delete docker repository from the docker hub
- Delete or unset clusters contexts and users entries from kubectl config