nerdexam
Google

ASSOCIATE-CLOUD-ENGINEER · Question #322

You just installed the Google Cloud CLI on your new corporate laptop. You need to list the existing instances of your company on Google Cloud. What must you do before you run the gcloud compute instan

The correct answer is A. Run gcloud auth login, enter your login credentials in the dialog window, and paste the received E. Run gcloud config set project $my_project to set the default project for gcloud CLI.. Before using gcloud compute instances list, you must authenticate your gcloud CLI session using gcloud auth login and set the default Google Cloud project using gcloud config set project.

Submitted by saadiq_pk· Mar 30, 2026Setting up a cloud solution environment

Question

You just installed the Google Cloud CLI on your new corporate laptop. You need to list the existing instances of your company on Google Cloud. What must you do before you run the gcloud compute instances list command? (Choose two.)

Options

  • ARun gcloud auth login, enter your login credentials in the dialog window, and paste the received
  • BCreate a Google Cloud service account, and download the service account key. Place the key file
  • CDownload your Cloud Identity user account key. Place the key file in a folder on your machine
  • DRun gcloud config set compute/zone $my_zone to set the default zone for gcloud CLI.
  • ERun gcloud config set project $my_project to set the default project for gcloud CLI.

How the community answered

(34 responses)
  • A
    88% (30)
  • B
    3% (1)
  • C
    3% (1)
  • D
    6% (2)

Why each option

Before using `gcloud compute instances list`, you must authenticate your gcloud CLI session using `gcloud auth login` and set the default Google Cloud project using `gcloud config set project`.

ARun gcloud auth login, enter your login credentials in the dialog window, and paste the receivedCorrect

The `gcloud auth login` command is essential to authenticate your user account with Google Cloud, establishing the necessary permissions context for the CLI to interact with your resources.

BCreate a Google Cloud service account, and download the service account key. Place the key file

While service accounts are used for programmatic access, for a user on a corporate laptop, authenticating with their user account via `gcloud auth login` is the standard and simpler approach for interactive CLI use.

CDownload your Cloud Identity user account key. Place the key file in a folder on your machine

Cloud Identity user account keys are not a standard authentication mechanism for `gcloud CLI`; users authenticate interactively via a web browser flow initiated by `gcloud auth login`.

DRun gcloud config set compute/zone $my_zone to set the default zone for gcloud CLI.

Setting the default zone using `gcloud config set compute/zone` is important for commands that operate on zonal resources (like creating an instance), but `gcloud compute instances list` can list instances across all zones in a project even if a default zone isn't set, making it not a *must-do* before this specific command, though good practice for many other `gcloud compute` commands.

ERun gcloud config set project $my_project to set the default project for gcloud CLI.Correct

The `gcloud compute instances list` command operates within a specific project, so setting the default project using `gcloud config set project` ensures the command targets the correct environment without needing to specify `--project` every time.

Concept tested: gcloud CLI authentication and project configuration

Source: https://cloud.google.com/sdk/gcloud/reference/auth/login

Topics

#gcloud CLI setup#authentication#project configuration#Cloud SDK

Community Discussion

No community discussion yet for this question.

Full ASSOCIATE-CLOUD-ENGINEER Practice