Note: This is a self-answered question, which is allowed here. If you have better solutions go ahead and post them.
Hypothetical automation for a web-based cloud school needs to test if students have some minimal competence before proceeding. Students must be able to start a Google Cloud VM, install apache on it, and expose port 80 to the public internet, before proceeding to the next task.
The question is not about how to set up apache. That's obvious.
The question is how to test if its been done.
So the first step is to detect the VM. We tell the students to call it something and we tell them the zone to use.
An early draft of an apache install detector -- executed on another VM inaccessible to the student but within the student's GCP project context -- could start like this:
#!/bin/bash
NAME="required-vm-name"
ZONE="us-central1-a"
IP=$(gcloud compute instances describe ${NAME} --zone ${ZONE} --format json | jq ".networkInterfaces[0].accessConfigs[0].natIP")
echo $IP
curl -v "http://${IP}"
but this produces the output
"1.2.3.4"
* Rebuilt URL to: http://"1.2.3.4"/
* Could not resolve host: "1.2.3.4"
* Closing connection 0 curl: (6) Could not resolve host: "1.2.3.4"
where I've redacted the address to 1.2.3.4 but kept all other output formatting.
Given the IP address is correct, and the debian apache2 test page displays properly at this address, why can't curl detect it? what's wrong? The correct IP works fine in Chrome.