gcloud compute instances list --filter="status=RUNNING" --format="value(name)". What is the output format you will get?--format="value(name)" flag outputs only the values of the 'name' field.The --format="value(name)" option tells gcloud to output only the values of the 'name' field as plain text, one per line, without any extra formatting like tables or JSON.
web-server in zone us-central1-a with a startup script located at startup.sh?The --metadata-from-file startup-script=startup.sh flag correctly uploads the contents of the startup.sh file as the startup script metadata for the VM.
app-server in three different zones: us-east1-b, us-west1-a, and europe-west1-b. Which approach ensures the script runs efficiently and handles errors gracefully?Running commands sequentially with error checking ensures each instance is created properly and any failures are logged. Parallel runs without checks risk missing errors. There is no copy command for instances, and you cannot specify multiple zones in one create command.
Activating a service account with a key file allows scripts to run with specific permissions securely without exposing personal credentials. Storing personal credentials or using anonymous authentication is insecure or not possible for resource management.
test-vm. Running the script multiple times causes errors because the instance already exists. What is the best way to modify the script to avoid errors and ensure idempotent behavior?Checking if the instance exists before creating it prevents errors and makes the script safe to run multiple times. Deleting unconditionally can cause unintended data loss. Ignoring errors or renaming instances is not clean or predictable.