You are setting up a new project environment and need to enable the Compute Engine API using the Google Cloud CLI (`gcloud`). Which of the following represents the correct sequence of steps to safely verify context, enable the API, and confirm activation?
- 1Set the current active Google Cloud project context using `gcloud config set project [PROJECT_ID]`.
- 2Check if the Compute Engine API is already active by running `gcloud services list --enabled`.
- 3Enable the Compute Engine service API by executing `gcloud services enable compute.googleapis.com`.
- 4Verify successful enablement by executing `gcloud services list --enabled --filter="NAME:compute.googleapis.com"`.
Answer
The correct sequence begins by targeting the proper project context with `gcloud config set project`, checking current enabled services with `gcloud services list --enabled`, enabling the specific service via `gcloud services enable compute.googleapis.com`, and finally verifying activation with a filtered `gcloud services list` command.
Enabling a service API requires selecting the target project first so that modifications affect the intended GCP resource. Inspecting existing enabled services before enabling and filtering the enabled list after enabling establishes standard operational hygiene for managing Service Usage in Google Cloud.
Step-by-Step Solution
Key Concept
Enabling Cloud Service APIs via gcloud CLI workflow