Google Cloud Architecture Exam Practice Questions – GCloud CLI

As I was preparing for the Google Cloud Certified – Professional Cloud Architect exam, I found that gaining proficiency in the gcloud CLI (Command Line Interface) was absolutely essential. This exam evaluates one’s capability to design and plan cloud solution architecture, manage and provision the cloud solution infrastructure, design for security and compliance, and analyze and optimize technical and business processes among others.

The gcloud CLI is a primary tool for managing resources within Google Cloud Platform (GCP), and it’s extensively used to automate tasks by interacting with GCP services. M

I crafted with extensive help from ChatGPT, the following multiple-choice questions, which are curated to ensure they are in line with the current documentation to test and reinforce my understanding of gcloud CLI commands related to Compute Engine. These topics dovetail with the “Managing and provisioning solution infrastructure” and “Designing for security and compliance” sections of the exam guide. Not only did familiarity with these command line parameters prepare me for the exam, but it also equipped me to manage GCP resources proficiently in real-world scenarios.

So, as you peruse these questions and answers, remember they’re a reflection of my personal study and preparation for the Google Cloud Certified – Professional Cloud Architect exam. Happy studying!

Gcloud CLI – Exam Cheatsheet

Here are some of the main functionalities and example commands:

  1. Authentication
  2. Configuring settings
  3. Managing GCP Projects
  4. Managing Compute Engine instances
  5. Managing Kubernetes Engine clusters
  6. Managing App Engine applications
  7. Managing Cloud Storage
    • Copying many with multi-threading:
      • gsutil -m cp -r SOURCE_DIRECTORY gs://BUCKET_NAME: The -m flag enables multi-threading, and the -r flag is used to indicate that the operation should be recursive i for directories.
    • Slicing large files into components: This will slice files larger than the specified threshold (150MB in this example) into components that are uploaded in parallel. Once all components are uploaded, GCS composes them into a single object.
      • gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp LARGE_FILE gs://BUCKET_NAME
    • Transferring files with progress indication: If you are transferring large files and want to see the progress and speed of the transfer, you can use the -p option:
      • gsutil -p cp LARGE_FILE gs://BUCKET_NAME
  8. Managing IP Addresses
    • gcloud compute addresses list: Lists all of the reserved IP addresses in the active project.
    • gcloud compute addresses create ADDRESS_NAME --region=REGION: Reserves an IP address.
    • gcloud compute addresses delete ADDRESS_NAME --region=REGION: Releases a reserved IP address.
  9. Managing Cloud SQL instances
    • gcloud sql instances list: Lists all Cloud SQL instances in the active project.
    • gcloud sql instances create INSTANCE_NAME: Creates a new Cloud SQL instance.
    • gcloud sql instances delete INSTANCE_NAME: Deletes a Cloud SQL instance.
  10. Managing Dataflow jobs
    • gcloud dataflow jobs list: Lists all Dataflow jobs in the active project.
    • gcloud dataflow jobs run JOB_NAME --gcs-location=TEMPLATE_LOCATION: Runs a new Dataflow job from a template.
    • gcloud dataflow jobs cancel JOB_ID: Cancels a running Dataflow job.
  11. Managing Pub/Sub Topics and Subscriptions
    • gcloud pubsub topics list: Lists all Pub/Sub topics in the current project.
    • gcloud pubsub topics create TOPIC_NAME: Creates a new Pub/Sub topic.
    • gcloud pubsub subscriptions list: Lists all Pub/Sub subscriptions in the current project.
    • gcloud pubsub subscriptions create SUBSCRIPTION_NAME --topic=TOPIC_NAME: Creates a new Pub/Sub subscription on a specified topic.
  12. Managing Firestore Databases
    • gcloud firestore databases create --region=REGION: Creates a new Firestore database in the specified region.
    • gcloud firestore indexes composite list: Lists all composite indexes in the current Firestore database.
  13. Managing BigQuery
    • bq ls: Lists all BigQuery datasets in the current project.
    • bq mk DATASET_NAME: Creates a new BigQuery dataset.
    • bq query "SELECT * FROM [DATASET_NAME].[TABLE_NAME]": Runs a BigQuery SQL command.
  14. Managing Cloud Functions
    • gcloud functions list: Lists all Cloud Functions in the current project.
    • gcloud functions deploy FUNCTION_NAME --runtime=RUNTIME --trigger-http --allow-unauthenticated: Deploys a new Cloud Function with the specified runtime, which is triggered by HTTP requests, and allows unauthenticated access.
  15. Managing Cloud Run Services
    • gcloud run services list: Lists all Cloud Run services in the current project.
    • gcloud run deploy SERVICE_NAME --image=IMAGE_URL: Deploys a new Cloud Run service using a specified container image.

Multiple Choice Questions

1. Which of the following commands is used to list all the active Compute Engine instances in your GCP project?

a. gcloud compute instances list
b. gcloud compute instances active
c. gcloud compute list instances
d. gcloud compute instances

Answer: a.
Explanation: The gcloud compute instances list command is used to list all active Compute Engine instances in your GCP project.

2. To set a default region and zone for your GCP project using gcloud CLI, which command would you use?

a. gcloud config set compute/region [REGION] && gcloud config set compute/zone [ZONE]
b. gcloud config set compute/region-and-zone [REGION] [ZONE]
c. gcloud config set compute/region compute/zone
d. gcloud compute set default-region-and-zone [REGION] [ZONE]

Answer: a.
Explanation: The gcloud config set compute/region and gcloud config set compute/zone commands are used to set the default region and zone for your GCP project.

3. If you want to SSH into a specific Compute Engine instance, which gcloud command would you use?

a. gcloud compute ssh [INSTANCE_NAME]
b. gcloud ssh compute instances [INSTANCE_NAME]
c. gcloud compute instances ssh [INSTANCE_NAME]
d. gcloud ssh compute [INSTANCE_NAME]

Answer: a.
Explanation: The command gcloud compute ssh [INSTANCE_NAME] is used to SSH into a specific Compute Engine instance.

4. To reserve a static external IP address, what is the correct gcloud CLI command?

a. gcloud compute addresses create [ADDRESS_NAME] –region=[REGION]
b. gcloud compute addresses reserve [ADDRESS_NAME] –region=[REGION]
c. gcloud compute reserve-ip [ADDRESS_NAME] –region=[REGION]
d. gcloud reserve-ip compute [ADDRESS_NAME] –region=[REGION]

Answer: a.
Explanation: The gcloud compute addresses create [ADDRESS_NAME] --region=[REGION] command is used to reserve a static external IP address in GCP.

5. How would you update the machine type of a specific Compute Engine instance?

a. gcloud compute instances set-machine-type [INSTANCE_NAME] –zone=[ZONE] –machine-type=[MACHINE_TYPE]
b. gcloud compute instances update-machine [INSTANCE_NAME] –zone=[ZONE] –machine-type=[MACHINE_TYPE]
c. gcloud compute set-machine-type instances [INSTANCE_NAME] –zone=[ZONE] –machine-type=[MACHINE_TYPE]
d. gcloud compute update instances machine-type [INSTANCE_NAME] –zone=[ZONE] –machine-type=[MACHINE_TYPE]

Answer: a.
Explanation: The gcloud compute instances set-machine-type [INSTANCE_NAME] --zone=[ZONE] --machine-type=[MACHINE_TYPE] command is used to change the machine type of a specific instance. The instance should be stopped before executing this command.

6. What is the correct gcloud CLI command to create a new Compute Engine instance?

a. gcloud compute instances create [INSTANCE_NAME] –zone=[ZONE]
b. gcloud compute create instance [INSTANCE_NAME] –zone=[ZONE]
c. gcloud create compute instances [INSTANCE_NAME] –zone=[ZONE]
d. gcloud compute new instance [INSTANCE_NAME] –zone=[ZONE]

Answer: a.
Explanation: The gcloud compute instances create [INSTANCE_NAME] --zone=[ZONE] command is used to create a new Compute Engine instance in GCP.

7. How do you delete a Compute Engine instance using the gcloud CLI?

a. gcloud compute instances delete [INSTANCE_NAME] –zone=[ZONE]
b. gcloud compute delete instances [INSTANCE_NAME] –zone=[ZONE]
c. gcloud compute instances remove [INSTANCE_NAME] –zone=[ZONE]
d. gcloud delete compute instances [INSTANCE_NAME] –zone=[ZONE]

Answer: a.
Explanation: The gcloud compute instances delete [INSTANCE_NAME] --zone=[ZONE] command is used to delete a Compute Engine instance in GCP.

8. How do you assign a specific service account to a Compute Engine instance at creation time?

a. gcloud compute instances create [INSTANCE_NAME] –service-account=[SERVICE_ACCOUNT] –scopes=[SCOPES]
b. gcloud compute instances create [INSTANCE_NAME] –assign-service-account=[SERVICE_ACCOUNT] –scopes=[SCOPES]
c. gcloud compute instances create –service-account [INSTANCE_NAME] –scopes=[SCOPES]
d. gcloud compute instances –service-account create [INSTANCE_NAME] –scopes=[SCOPES]

Answer: a.
Explanation: When creating a Compute Engine instance, the --service-account flag is used to assign a specific service account to the instance.

9. How would you add a network tag to an existing Compute Engine instance?

a. gcloud compute instances add-tags [INSTANCE_NAME] –tags=[TAG_NAME] –zone=[ZONE]
b. gcloud compute instances create [INSTANCE_NAME] –tags=[TAG_NAME] –zone=[ZONE]
c. gcloud compute instances add-tags –tags [INSTANCE_NAME] –zone=[ZONE]
d. gcloud compute instances –tags add-tags [INSTANCE_NAME] –zone=[ZONE]

Answer: a.
Explanation: The gcloud compute instances add-tags [INSTANCE_NAME] --tags=[TAG_NAME] --zone=[ZONE] command is used to add a network tag to an existing Compute Engine instance.

10. To list all the disks in your GCP project, which command would you use?

a. gcloud compute disks list
b. gcloud compute list disks
c. gcloud list compute disks
d. gcloud disks compute list

Answer: a. gcloud compute disks list
Explanation: The gcloud compute disks list command is used to list all the disks in your GCP project.

11. What does the -m option in the gsutil cp command enable?

a. File slicing
b. Multi-threading
c. File compression
d. All of the above
Answer: b. Multi-threading**.
Explanation: The `-m` option enables multi-threading in `gsutil` which allows it to perform multiple operations in parallel. This can significantly speed up tasks such as copying or moving large numbers of files or large-sized files.

12. How can you enable slicing of large files during uploads in gsutil?

a. Using the -slice option
b. Setting the GSUtil:slice_upload_threshold configuration
c. Using the -o GSUtil:parallel_composite_upload_threshold option
d. Slicing is enabled by default in gsutil
Answer: c.
Explanation: Using the -o GSUtil:parallel_composite_upload_threshold option. This option enables you to slice files larger than the specified threshold into components that are uploaded in parallel. Once all components are uploaded, Google Cloud Storage composes them into a single object. This can help to speed up the upload of large files.

13. Which command would you use to copy a large file to a Google Cloud Storage bucket with multi-threading and file slicing enabled?

a. gsutil -m cp LARGE_FILE gs://BUCKET_NAME
b. gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp LARGE_FILE gs://BUCKET_NAME
c. gsutil -m -o GSUtil:parallel_composite_upload_threshold=150M cp LARGE_FILE gs://BUCKET_NAME
d. gsutil -s cp LARGE_FILE gs://BUCKET_NAME
Answer: c.
Explanation: This command enables both multi-threading (-m option) and file slicing for large files (-o GSUtil:parallel_composite_upload_threshold=150M option), making it more efficient for uploading large files to Google Cloud Storage.


Posted

in

by