ASSOCIATE-CLOUD-ENGINEER practice question 12 of 35

You need to produce a list of the enabled Google Cloud Platform APIs for a GCP project using the gcloud command line in the Cloud Shell. The project name is my-project. What should you do?

Full set: 332 questions
Answer options
A: Run gcloud projects list to get the project ID, and then run gcloud services list --project . Correct answer
B: Run gcloud init to set the current project to my-project, and then run gcloud services list -- available.
C: Run gcloud info to view the account value, and then run gcloud services list --account .
D: Run gcloud projects describe to verify the project value, and then run gcloud services list --available.
Correct Answer:
A. Run gcloud projects list to get the project ID, and then run gcloud services list --project .
Explanation

The gcloud services list command is used to list the APIs and services for a Google Cloud project. By default, this command lists only the services that are currently enabled. To target a specific project, the --project flag must be used, followed by the project ID. Since the question provides the project name (my-project), the gcloud projects list command can first be used to retrieve the corresponding project ID, which is then used in the second command.

Why Incorrect

B: The --available flag lists all services that can be enabled, not the ones that are currently enabled, which contradicts the requirement. C: The gcloud services list command operates on a project, not a user account. It does not have an --account flag, making the command invalid. D: The --available flag lists all possible services, not just the enabled ones for the specified project, which is incorrect for this scenario.

References

1. Google Cloud SDK Documentation

gcloud services list: "By default

it lists all enabled services for the active project. To list all available services

use the --available flag." The documentation also specifies the use of the --project flag to "specify a project ID to operate on."

Source: Google Cloud. (n.d.). gcloud services list. Google Cloud SDK documentation. Retrieved from https://cloud.google.com/sdk/gcloud/reference/services/list

2. Google Cloud SDK Documentation

gcloud projects list: This command is used to "List projects for the active account." The output table includes PROJECTID

NAME

and PROJECTNUMBER

confirming its use for finding a project ID from a known project name.

Source: Google Cloud. (n.d.). gcloud projects list. Google Cloud SDK documentation. Retrieved from https://cloud.google.com/sdk/gcloud/reference/projects/list

3. Google Cloud Documentation

Enabling and disabling services: "To list the enabled services for a project

run the gcloud services list command... To list the services that are available to be enabled in a project

run the following command: gcloud services list --available" This page explicitly distinguishes between the default behavior (listing enabled services) and using the --available flag.

Source: Google Cloud. (n.d.). Enabling and disabling services. Service Usage documentation. Retrieved from https://cloud.google.com/service-usage/docs/enable-disable#listingservices

Scroll to Top