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?
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
Q01What is the highest level of the Google Cloud resource hierarchy?EasyQ02You need to enable the Compute Engine API in a new project using the command line. Which command ...EasyQ03You are setting up a new GCP environment. You need to grant a group of developers access to view ...MediumQ04You want to receive an email notification when your GCP spending exceeds $1000 this month. What s...EasyQ05You need to analyze your GCP billing data using complex SQL queries to understand cost trends acr...Medium
Expert