Deployed wrong app to Google Cloud, how to prevent?
Asked Answered
S

3

8

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.

Somerville answered 24/7, 2020 at 18:21 Comment(0)
B
4

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

Bin answered 1/2, 2021 at 13:26 Comment(0)
G
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.

Gabriel answered 24/7, 2020 at 20:2 Comment(6)
What does your app.yaml look like in this case? And where is CLOUDSDK_CORE_PROJECT set? I don't see this anywhere in the documentation, just in the console messageSomerville
Can't you set the project id in the app.yaml and then just run gcloud app deploy? Why do we have to include the --project flag in the command? Can't gcloud read it from the app.yaml?Somerville
No, you cannot set project ID in app.yaml. Per @grappler answer you can either use gcloud app deploy ... --project=${PROJECT}, or you can set the environment variable CLOUDSDK_CORE_PROJECT=${PROJECT} gcloud app deploy ...Hypertrophy
So.. I work in many apps and now deploy to multiple gcloud app engines, any suggestions for a good workflow here? I feel like I'm missing something. In heroku it's impossible to deploy the wrong app because you push to a git remote.. not sure why google cloud can't have something in place like "hey, this is the wrong app for that remote"Somerville
I am looking for the same answer @nateM. Did you find a solution? Seems weird to have one main project when you use cloud for many sites and can push to the wrong one!Pizarro
No I haven't found a solution yet. In fact I almost deployed the wrong project to a production site again! We humans like to fat finger things.. help us out google!Somerville
T
1

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.

Titustityus answered 30/1, 2021 at 19:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.