'Deployed wrong app to Google Cloud, how to prevent?

When I run gcloud app deploy I get the message:

ERROR: (gcloud.app.deploy) The required property [project] is not currently set.
You may set it for your current workspace by running:

  $ gcloud config set project VALUE

or it can be set temporarily by the environment variable [CLOUDSDK_CORE_PROJECT]

Setting the project in my current workspace caused me to deploy the wrong app, so I don't want to do that again. I want to try deploying using the environment variable option listed above. How do I do this? What is the deploy syntax to use CLOUDSDK_CORE_PROJECT? I thought this would come from my app.yaml but haven't gotten it working.



Solution 1:[1]

You should configure it with your project using projectID.

gcloud config set project <PROJECT_ID>

You can find your projectID your GCP account. enter image description here

Solution 2:[2]

You should be able to pass the project as part of the app deploy command:

gcloud app deploy ~/my_app/app.yaml --project=PROJECT

Look at the examples in the Documentation.

Solution 3:[3]

I had the same error message recently in a job which worked fine before.
Old:

# Deploy template
.deploy_template: &deploy_definition
  image: google/cloud-sdk
  stage: deploy
  script:
    - echo $GOOGLE_KEY > key.json
    - gcloud auth activate-service-account --key-file key.json
    - gcloud config set compute/zone $GC_REGION
    - gcloud config set project $GC_PROJECT
    - gcloud container clusters get-credentials $GC_XXX_CLUSTER
    - kubectl set image deployment/XXXXXX --record

New:

# Deploy template
.deploy_template: &deploy_definition
  image: google/cloud-sdk
  stage: deploy
  script:
    - echo $GOOGLE_KEY > key.json
    - gcloud auth activate-service-account --key-file key.json
    - gcloud config set project $GC_PROJECT
    - gcloud config set compute/zone $GC_REGION
    - gcloud container clusters get-credentials $GC_XXX_CLUSTER
    - kubectl set image deployment/XXXXXX --record

I just change the order of compute/zone, and it is worked like before.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dilshan Dilip
Solution 2 grappler
Solution 3 β.εηοιτ.βε