Search code examples
google-cloud-shell

How to choose a zone for Google Cloud Shell Session?


Since echo backs of typing character is very slow for me in Japan, it seems that instances of Google Cloud Shell sessions are in some us region.

How do I change the zone of an instance?


Solution

  • 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.

    Since Cloud Shell runs as a GCP VM, you can view your current 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.