Given a google cloudshell, is there a way of finding out which region it is in?
Many thanks, Max
p.s. I know that I can poke around to find the IP address and geolocate it, for example this curl freegeoip.net/xml/$(curl ifconfig.co)
claims that the machine is in Vaduz, Liechtenstein. However I would somewhat expect that there is something like an IP address that I can curl to get the cloudconfig and that that would contain the region and availability zone.
Since Cloud Shell runs as a GCP VM, you can view your assigned region by running
curl -H "Metadata-Flavor: Google" metadata/computeMetadata/v1/instance/zone
inside the Cloud Shell session. This is documented in https://cloud.google.com/compute/docs/storing-retrieving-metadata.
In general, it's worth keeping in mind that Cloud Shell is globally distributed across multiple GCP regions. When a user connects for the first time, the system assigns them to the geographically closest region that can accommodate new users. While the users cannot manually chose their region, the system does its best to pick the closest region Cloud Shell operates in. If Cloud Shell does not initially pick the closest region or if the user later connects from a location that's geographically closer to a different region, Cloud Shell will migrate the user to a closer region on session end.