简体   繁体   中英

Google Cloud Platform - Specifying Project Name

I am trying to follow Google's instructions on deploying a Cloud Function from the command line. I cloned their sample project, but when I used gcloud functions deploy to deploy it, it complained that it failed to find attribute [project]. I had to provide that manually.

Where in their docs to they talk about setting the project attribute? I must've missed it, and it seems pretty important ...

This answer is in addition to @Kolban.

You can modify your gcloud settings at any time. Here are some common ones:

gcloud config set core/project my-project-id
gcloud config set compute/region us-central1

To list your projects:

gcloud projects list

To see your current settings:

gcloud config list

To see your authorization settings:

gcloud auth list

Then there are settings for individual services such as Cloud Run:

gcloud config set run/region us-central1

To get help to see the vast number of settings available:

gcloud config --help

All of this is documented. Just put a command into Google and a document link will appear. For example put this string into Google: "gcloud compute instances create". The first link takes you to the command documentation.

When you install the Google Cloud SDK (which provides the gcloud command), you have the opportunity to create one or more configurations (including the default). Think of these as "profiles" for your interaction with GCP. A configuration includes:

  • Your identity
  • Your default project
  • Your default region/zone

See the following article:

It sounds like you either didn't run gcloud init or didn't identify a project you wanted to use when you did run it. When you subsequently run gcloud commands and don't specify a project, then the current configuration project will be used. If you didn't set one, then that would explain the error encountered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM