Hard1 markMultiple Choice

GCP ACE · Question 09 · Domain 1.3: Installing and configuring the CLI

You are writing a bash script that creates a Compute Engine instance. The script needs to run without user interaction and output ONLY the external IP address of the newly created instance in JSON format. How should you format the gcloud command?

Answer options:

A.

gcloud compute instances create ... --silent --output=json

B.

gcloud compute instances create ... --quiet --format="json(networkInterfaces[0].accessConfigs[0].natIP)"

C.

gcloud compute instances create ... --no-prompts --json-only

D.

gcloud compute instances create ... --quiet | grep IP

How to approach this question

Identify the flags for disabling prompts (`--quiet`) and formatting output (`--format`).

Full Answer

B.gcloud compute instances create ... --quiet --format="json(networkInterfaces[0].accessConfigs[0].natIP)"✓ Correct
gcloud compute instances create ... --quiet --format="json(networkInterfaces[0].accessConfigs[0].natIP)"
The `--quiet` (or `-q`) flag disables all interactive prompts, which is essential for scripts. The `--format` flag allows you to change the output format (e.g., to json, yaml, csv) and use projections to select specific fields, such as the NAT IP address.

Common mistakes

Not knowing the `--format` flag capabilities or using standard Linux pipes when a native flag exists.

Practice the full GCP Associate Cloud Engineer Practice Exam 1

50 questions · hints · full answers · grading

More questions from this exam