I am toying around a bit with GCP cloud shell editor which I start by visiting https://shell.cloud.google.com/?show=ide (which I installed as an PWA) and would like to debug a simple Flask AppEngine app. The app is using Cloud Logging. It runs fine in the terminal window when I first do:
gcloud config set project myproject
However if I want to use the builtin debugging I get errors because gcloud config set project myproject
has not been set in that new window. So my question is how do I make sure that gcloud config set project myproject
is run at startup of each console? I already tried running a preLaunchTask
but since that is run in a separate console it does not help
Update (26 Jan 2021)
Also toyed around with trying to change the .bashrc
automatically when opening a project by using a task that is triggered by folderOpen
and then writes the relevant gcloud command to a script which is called by .bashrc
as shown below
{
"version": "2.0.0",
"tasks": [
{
"label": "Set GCP Project",
"type": "shell",
"command": "echo "set -x; gcloud config set project [MYPROJECT]" > $HOME/set_gcp_project",
"runOptions": {
"runOn": "folderOpen"
},
"presentation": {
"reveal": "never",
"panel": "shared"
},
"problemMatcher": []
}
]
}
However Cloud Shell does not support these automated tasks. It works fine in VSCode. However it is still a nuisance because if in the GCP console I open a terminal or it opens it when you click on a run in cloud shell it sets the project to whatever project I had last opened in the Cloud Shell Editor
question from:
https://stackoverflow.com/questions/65863297/gcp-how-to-make-sure-that-gcp-project-is-set-in-cloud-shell-editor 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…